如何保存(preserve)海军报图上更新的缩放状态与AJAX缩放、海军、图上、状态

由网友(一朵枯花能代表我的心情)分享简介:我有一个简单的应用程序,民意调查数据库进行数据的每一分钟。当新的数据被取出,我使用AJAX更新图表。但是,每当我更新的图形(重新绘制它添加了绘制数据的新值)变焦的当前状态将丢失。更新图形之前,我想preserve最新的变焦位置。更新图之后,我希望图形放大到其保存的位置。这很重要,因为重新缩放每一分钟都是那么刺激。这可能...

我有一个简单的应用程序,民意调查数据库进行数据的每一分钟。当新的数据被取出,我使用AJAX更新图表。但是,每当我更新的图形(重新绘制它添加了绘制数据的新值)变焦的当前状态将丢失。更新图形之前,我想preserve最新的变焦位置。更新图之后,我希望图形放大到其保存的位置。这很重要,因为重新缩放每一分钟都是那么刺激。这可能吗?

I have a simple application which polls database for data every minute. When new data is fetched, I am updating the graph using ajax. However, whenever I update the graph (re-plot it with new values added to plot data) the current state of zoom is lost. Before updating the graph, I want to preserve the latest zoom position. After updating the graph, I want to zoom the graph to its saved position. This is important because re-zooming every minute is irritating. Is this possible?

推荐答案

在您重新积得到当前的变焦之前获得新的数据和 它添加到更新的选项。

Here is the answer by Joshua Varner 1

When you get your new data before you re plot get the current zoom and add it to the options on update.

// Get the current zoom
var zoom = plot.getAxes();

// Add the zoom to standard options
var zoomed = {};
$.extend(zoomed,options);
zoomed.xaxis.min = zoom.xaxis.min;
zoomed.xaxis.max = zoom.xaxis.max;
zoomed.yaxis.min = zoom.yaxis.min;
zoomed.yaxis.max = zoom.yaxis.max;

// draw/save the plot
plot = $.plot($("#graph"), d, zoomed);
阅读全文

相关推荐

最新文章