创建高库存放大/缩小按钮 [英] Creating highstock zoom-in/out button

查看:54
本文介绍了创建高库存放大/缩小按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到以下问题-我正在尝试使用放大/缩小按钮创建高库存图形,但是缩放有些问题.当我大多数情况下按此按钮时,图表会缩放到正确的时间间隔,但是,当我再按几次按钮后,图表就会开始出现怪异的现象-动画不正确或无法缩放,或者缩放到错误的时间间隔.

I have the following problem - I'm trying to create highstock graphic with zoom-in/zoom-out buttons, but something is wrong with the zooming. When i press the button most of the times the chart zooms to the correct time interval, however, after I press the button a couple more times, the chart starts to behave weird - the animations aren't correct or it doesn't zoom or it zooms to the wrong interval.

这是缩放功能:

var xAxis = graphic.xAxis[0];
var minimum = xAxis.dataMin;
var maximum = xAxis.dataMax;

var newMin = 0;
var newMax = 0;

//when zooming out

newMin = xAxis.min - 360000;
newMax = xAxis.max + 360000;

//when zooming in

//newMin = xAxis.min - 360000;
//newMax = xAxis.max + 360000;

if (newMin < minimum)
    newMin = minimum;

if (newMax > maximum)
    newMax = maximum;

if (newMin > newMax) {
    alert("min bigger than max");
}

console.log("newMin: " + newMin + "    newMax: " + newMax);

xAxis.setExtremes(newMin, newMax);                       

这是一个小提琴: http://jsfiddle.net/E5kth/3/

  • jquery-1.6.4
  • jquery鼠标滚轮-3.1.6
  • 高库存-1.3.7

预先感谢;]

这是一个新的视频,对问题有更好的解释: https://www.dropbox.com/s/5x1k5b0lbtqw81u/highstock_ordinal-false_bug_converted.avi 为了获得更好的质量-下载视频后,Dropbox流的质量会降低.

Here is a NEW video with better explanations of the problem: https://www.dropbox.com/s/5x1k5b0lbtqw81u/highstock_ordinal-false_bug_converted.avi for better quality - download the video, dropbox streaming is with low quality.

推荐答案

我准备了一个简单的示例,该示例该如何完成, http://jsfiddle.net/3vB5B/.它从图表获得范围,然后在24小时内减小范围.

I prepared simple example how it should be done, http://jsfiddle.net/3vB5B/. It get range from chart and then reduce range on 24 hours.

$('#btn').click(function(){

            var min = chart.xAxis[0].getExtremes().min,
                max = chart.xAxis[0].getExtremes().max;

            chart.xAxis[0].setExtremes((min + 12 * 3600 * 1000),(max - 12 * 3600 * 1000)); //12 hrs on min and 12hrs on max, summarised it is one day.

});

这篇关于创建高库存放大/缩小按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆