问题描述
我真的很感谢有人能帮我解决这个问题。我们使用Jqplot来绘制一些统计数据和缩放功能。
具体而言,我们希望使用
中的示例
和
我们需要做的一件事是重新计算我们在页面上显示的一些值,如标准偏差,平均值等等,以便放大后图中可见的点。
为此,我们需要获取(在)剩余的数据点列表因此理想情况下,我们正在寻找一种方法,它在放大后返回图中可见的
当前数据集。
我看了提供API文档,但似乎没有这样的方法可用。所以我会很感激,如果有人帮助我如何处理这个问题。
谢谢.... Amit
很多挖掘代码的方法,并没有任何简单的方法来获取这些数据,但是,有一种方法。
在下面的解决方案中,我有一个 zoomChart jqPLot obj,它充当我的主jqPLot的缩放代理,称为图表即可。据推测,如果你没有代理服务器,只要你绑定到正确的对象上,这应该可以工作。
我正在做的是绑定jqplotZoom'事件的自定义函数,在缩放操作完成后调用该函数。
zoomChart.target.bind ('jqplotZoom',函数(ev,gridpos,datapos,plot,cursor){
var plotData = plot.series [0] .data;
for(var i = 0; i< plotData.length ; i ++){
if(plotData [i] [0]> = chart.axes.xaxis.min&& plotData [i] [0]< = chart.axes.xaxis.max){
//原始数据集位于缩放区域内
//您可以将这些数据点保存到新数组
//此新数组将包含您的缩放数据集
/ /例如:zoomDataset.push(plotData [i]);
}
}
});
这是否合理?基本上, chart.axes.xaxis
包含缩放区域的边界, plot.series [N] .data $ c $
请注意,我使用 chart
因为我最初创建 var chart = $ .jqplot(chartDiv,...
您应该使用任何变量名称给你的情节。
希望这有助于!
I really appreciate if someone can help me out on this. We are using Jqplot to plot some statistical data and like the zooming functionality.
Specifically we want to use the examples in
http://www.jqplot.com/deploy/dist/examples/zoom1.html and
http://www.jqplot.com/deploy/dist/examples/zoomOptions.html
One of the thing we need to do is to recalculate some values we display on the page like standard deviation, mean etc for the points visible in the graph after zooming in. For this we need to get the list of data points that are there (remain) on the graph after we zoomed in. So ideally we are looking at a method which returns thecurrent data set visible in the graph after I zoomed in.
I looked up the API documentation, but no such method seems to be available. So I would really appreciate if somebody helps with how I should proceed with this.
Thanks....Amit
Ok, so after a lot of digging through the code, there is not really any simple way to get this data, but, there is a way.
In the solution below, I have a zoomChart jqPLot obj that acts as a zoom-proxy to my main jqPLot, called chart. Presumably, if you don't have a proxy, this should work just as well, as long as you bind to the right object.
What I'm doing is binding a custom function to the 'jqplotZoom' event, which is called after a zoom action has been completed.
zoomChart.target.bind('jqplotZoom', function(ev, gridpos, datapos, plot, cursor){
var plotData = plot.series[0].data;
for (var i=0; i< plotData.length; i++) {
if(plotData[i][0] >= chart.axes.xaxis.min && plotData[i][0] <= chart.axes.xaxis.max ) {
//this dataset from the original is within the zoomed region
//You can save these datapoints in a new array
//This new array will contain your zoom dataset
//for ex: zoomDataset.push(plotData[i]);
}
}
});
Does this make sense? Essentially, the chart.axes.xaxis
contains the bounds of the zoomed area, and the plot.series[N].data
is all your original data in the chart format.
Note that I used chart
because I originally created var chart = $.jqplot("chartDiv", ...
You should use whatever variable name you gave your plot.Hope this helps!
这篇关于放大jqplot后在画布中获取数据点列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!