JqPlot 在数据点上添加点击事件

JqPlot add click event on data points(JqPlot 在数据点上添加点击事件)
本文介绍了JqPlot 在数据点上添加点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 jqplot http://www.jqplot.com/tests/cursor-highlighter.php.我已经成功地将它安装在我的框架中.但我需要在图表中的数据点上推送一个点击事件.

I am trying to use jqplot http://www.jqplot.com/tests/cursor-highlighter.php. I have successfully installed it in my framework. But i need to push a click event on the data points in the chart.

这是我目前的代码,

<script class="code" type="text/javascript">
    $(document).ready(function () {
        var line1 = [['23-May-08', 578.55], ['20-Jun-08', 566.5], ['25-Jul-08', 480.88], ['22-Aug-08', 509.84],
      ['26-Sep-08', 454.13], ['24-Oct-08', 379.75], ['21-Nov-08', 303], ['26-Dec-08', 308.56],
      ['23-Jan-09', 299.14], ['20-Feb-09', 346.51], ['20-Mar-09', 325.99], ['24-Apr-09', 386.15]];
        var plot1 = $.jqplot('chart1', [line1], {
            title: 'Πωλήσεις από 23-May-08 μέχρι 24-Apr-09',
            axes: {
                xaxis: {
                    renderer: $.jqplot.DateAxisRenderer,
                    tickOptions: {
                        formatString: '%b&nbsp;%#d'
                    }
                },
                yaxis: {
                    tickOptions: {
                        formatString: '€%.2f'
                    }
                }
            },
            highlighter: {
                show: true,
                sizeAdjust: 9.5
            },
            cursor: {
                show: false
            }

        });

        $.jqplot.eventListenerHooks.push(['jqplotClick', myClickHandler]);

    });

    function myClickHandler(ev, gridpos, datapos, neighbor, plot) {alert(1);}

</script>

这是我添加点击事件的尝试

this is my attempt to add the click event

$.jqplot.eventListenerHooks.push(['jqplotClick', myClickHandler]); and

 function myClickHandler(ev, gridpos, datapos, neighbor, plot) {alert(1);}

推荐答案

哈哈,我找到了 :).答案是:

lol i have found it :). The answer was :

<script class="code" type="text/javascript">
    $(document).ready(function () {
        var line1 = [['23-May-08', 578.55], ['20-Jun-08', 566.5], ['25-Jul-08', 480.88], ['22-Aug-08', 509.84],
      ['26-Sep-08', 454.13], ['24-Oct-08', 379.75], ['21-Nov-08', 303], ['26-Dec-08', 308.56],
      ['23-Jan-09', 299.14], ['20-Feb-09', 346.51], ['20-Mar-09', 325.99], ['24-Apr-09', 386.15]];
        var plot1 = $.jqplot('chart1', [line1], {
            title: 'Πωλήσεις από 23-May-08 μέχρι 24-Apr-09',
            axes: {
                xaxis: {
                    renderer: $.jqplot.DateAxisRenderer,
                    tickOptions: {
                        formatString: '%b&nbsp;%#d'
                    }
                },
                yaxis: {
                    tickOptions: {
                        formatString: '€%.2f'
                    }
                }
            },
            highlighter: {
                show: true,
                sizeAdjust: 9.5
            },
            cursor: {
                show: false
            }
        });


        /* CLICK CODE START*/
        $('#chart1').bind('jqplotDataClick',
            function (ev, seriesIndex, pointIndex, data) {                
                alert(1);
            }
        );
        /* CLICK CODE END*/

    });

</script>

这篇关于JqPlot 在数据点上添加点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Update another component when Formik form changes(当Formik表单更改时更新另一个组件)
Formik validation isSubmitting / isValidating not getting set to true(Formik验证正在提交/isValiating未设置为True)
React Validation Max Range Using Formik(使用Formik的Reaction验证最大范围)
Validation using Yup to check string or number length(使用YUP检查字符串或数字长度的验证)
Updating initialValues prop on Formik Form does not update input value(更新Formik表单上的初始值属性不会更新输入值)
password validation with yup and formik(使用YUP和Formick进行密码验证)