我是jQuery flot的新手,我有两个图表我想连接两个用于缩放和选择功能,
代码:
// now connect the two
$("#time_chart").bind("plotselected", function(event, ranges) {
// clamp the zooming to prevent eternal zoom
if (ranges.xaxis.to - ranges.xaxis.from < 0.00001) {
ranges.xaxis.to = ranges.xaxis.from + 0.00001;
}
if (ranges.yaxis.to - ranges.yaxis.from < 0.00001) {
ranges.yaxis.to = ranges.yaxis.from + 0.00001;
}
// do the zooming
plot = $.plot("#time_chart", time_series,
$.extend(true, {}, options, {
xaxis: {
min: ranges.xaxis.from,
max: ranges.xaxis.to
},
yaxis: {
min: ranges.yaxis.from,
max: ranges.yaxis.to
}
})
);
// don't fire event on the overview to prevent eternal loop
time_overview.setSelection(ranges, true);
});
$("#time_overview").bind("plotselected", function(event, ranges) {
plot.setSelection(ranges);
});
请参阅演示:
我的图表正确显示了数据,但我觉得连接这两个数据我犯了一些错误。
$.plot("#time_chart", time_series,
$.extend(true, {}, options, {
传递time_series
时。
请帮帮我。
答案 0 :(得分:1)
经过一些修正后,请参阅updated fiddle。
<强>的变化:强>
将http://www.flotcharts.org/flot/jquery.flot.selection.js
添加到外部资源。
$.plot($("#time_chart"), [time_series], time_options);
var plot = $.plot($("#time_chart"), [time_series], time_options);
plot = $.plot("#time_chart", time_series,
plot = $.plot("#time_chart", [time_series],
$.extend(true, {}, options, {
$.extend(true, {}, time_options, {