本文介绍了使用zoomToDates的AM Charts初始视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在这个问题上有点难过.

我在zoomToIndexes上找到了其他帮助,但是我无法在页面上使用zoomToDates.

实时页面为 b2资源urq销售

我正在尝试将初始视图设置为从2000年显示到当前..我想在图表中拍打80年代初期的一些原始销售数据,但不希望图表最初显示最近30多年. >

任何帮助将不胜感激!

解决方案

zoomToDates 将真实的JavaScript Date对象作为参数:

chart.zoomToDates(new Date(2005, 0, 1), new Date(2015, 11, 31));

您可以使用图表的 rendered 事件进行预缩放"以及加载时:

var chart = AmCharts.makeChart("chartdiv", {
  // your chart config
  // ...
});

chart.addListener("rendered", function(event) {
  event.chart.zoomToDates(new Date(2005, 0, 1), new Date(2015, 11, 31));
});

请注意,Date()构造函数参数(第二个参数)中的月份从零开始.意思是一月是0,二月-1,依此类推.

Been stumped on this for a little bit.

I found some other help on zoomToIndexes, but I cant get the zoomToDates to work on my page.

Live page isb2 resource urq sales

Im trying to set the initial view to show from 2000 to current.. I want to slap some original sales data from early 80's in the graph, but dont want the graph to initially show the last 30+ years..

Any help would be MUCH appreciated!

解决方案

zoomToDates takes real JavaScript Date objects as parameters:

chart.zoomToDates(new Date(2005, 0, 1), new Date(2015, 11, 31));

You can use chart's rendered event to "pre-zoom" on load as well:

var chart = AmCharts.makeChart("chartdiv", {
  // your chart config
  // ...
});

chart.addListener("rendered", function(event) {
  event.chart.zoomToDates(new Date(2005, 0, 1), new Date(2015, 11, 31));
});

Note, that months in Date() constructor parameter (second parameter) are zero-based. Meaning January is 0, February - 1, etc.

这篇关于使用zoomToDates的AM Charts初始视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 17:57