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 在数据点上添加点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

相关文档推荐

Google apps script get range of bytes from binary file(谷歌应用程序脚本从二进制文件中获取字节范围)
Sending Multiple attachments with Google Script from Google Drive(使用 Google 脚本从 Google Drive 发送多个附件)
Distributing Google Apps Scripts for Sheets in your company network(在您的公司网络中分发适用于表格的 Google Apps 脚本)
Upload file to my google drive from anyone using javascript(使用 javascript 将文件从任何人上传到我的谷歌驱动器)
quot;Shared Drivequot; support in Google Apps Script(“共享驱动器Google Apps 脚本中的支持)
Angular 2+ HTTP POST and GDrive API. Resumable file upload with name(Angular 2+ HTTP POST 和 GDrive API.带名称的可恢复文件上传)