我有一个 jqplot 图表作为 Backbone.js 视图的一部分。图表及其数据都加载正常,但鼠标突出显示并单击图表似乎没有注册。它在 jqplot 示例中运行良好。只有当我将它添加到我的 Backbone.js 框架时,它才会停止工作。
我尝试使用“jqplotDataHighlight”和“jqplotClick”,但它们都不会触发事件,但是“jqplotDataUnhighlight”工作正常。我无法弄清楚为什么一个有效而另一个无效。
//part of Backbone.js View....
var l2 = [11, 9, 5, 12, 14];
var l3 = [4, 8, 5, 3, 6];
var l4 = [12, 6, 13, 11, 2];
//this event never triggers
this.$('#plot3').bind('jqplotDataHighlight',
function (ev, seriesIndex, pointIndex, data) {
alert('highlight');
$('#info1b').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
});
//unhighlight event work just as expected
this.$('#plot3').bind('jqplotDataUnhighlight',
function (ev) {
alert("this worked: unhighlight")
$('#info1b').html('Nothing');
});
//chart load fine, showing all data
this.$('#plot3').jqplot([l2, l3, l4],{
stackSeries: true,
showMarker: false,
seriesDefaults: {
fill: true
},
axes: {
xaxis: {
renderer: $.jqplot.CategoryAxisRenderer,
ticks: ["Mon", "Tue", "Wed", "Thr", "Fri"]
}
}
});
});