gpt4 book ai didi

javascript - jquery flot 缩放选择不适用于图表

转载 作者:行者123 更新时间:2023-11-30 00:17:07 25 4
gpt4 key购买 nike

我是 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);
});

请看演示:

http://jsfiddle.net/w47agnq2/

我的图表正确显示了数据,但我觉得将两者联系起来是我做错了。

$.plot("#time_chart", time_series,
$.extend(true, {}, options, {

同时传递 time_series

请帮帮我。

最佳答案

经过一些更正后它可以工作,请参阅 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, {

关于javascript - jquery flot 缩放选择不适用于图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34327939/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com