使用 zoomToDates 的 AM 图表初始视图 [英] AM Charts initial view using zoomToDates
问题描述
被这个问题难住了.
我在 zoomToIndexes 上找到了一些其他帮助,但我无法让 zoomToDates 在我的页面上工作.
I found some other help on zoomToIndexes, but I cant get the zoomToDates to work on my page.
实时页面是b2资源urq销售
我正在尝试将初始视图设置为从 2000 年显示到当前.. 我想在图表中添加一些 80 年代早期的原始销售数据,但不希望图表最初显示过去 30 多年..
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..
任何帮助将不胜感激!
推荐答案
zoomToDates
将真正的 JavaScript Date 对象作为参数:
zoomToDates
takes real JavaScript Date objects as parameters:
chart.zoomToDates(new Date(2005, 0, 1), new Date(2015, 11, 31));
您可以使用图表的 rendered
事件来加载时也预缩放":
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));
});
请注意,Date() 构造函数参数(第二个参数)中的月份是从零开始的.意思是一月是 0,二月 - 1,等等.
Note, that months in Date() constructor parameter (second parameter) are zero-based. Meaning January is 0, February - 1, etc.
这篇关于使用 zoomToDates 的 AM 图表初始视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!