the*_*mhz 3 javascript jquery jquery-plugins
我正在尝试使用jqplot http://www.jqplot.com/tests/cursor-highlighter.php.我已经在我的框架中成功安装了它.但我需要在图表中的数据点上推送点击事件.
到目前为止这是我的代码,
<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 %#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>
Run Code Online (Sandbox Code Playgroud)
这是我尝试添加click事件
$.jqplot.eventListenerHooks.push(['jqplotClick', myClickHandler]); and
function myClickHandler(ev, gridpos, datapos, neighbor, plot) {alert(1);}
Run Code Online (Sandbox Code Playgroud)
the*_*mhz 21
大声笑我发现它:).答案是:
<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 %#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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15007 次 |
| 最近记录: |