简体   繁体   English

仅显示最近2个月的amcharts

[英]Display only last 2 months in amcharts

I want to display only last 2 months data in amcharts. 我只想显示过去2个月的数据。 If user want previous data then he should scroll.. 如果用户需要以前的数据,则应滚动。

How can i do that? 我怎样才能做到这一点? Display only last 2 months in amcharts. 仅显示最近2个月的amcharts。 See image. 见图片。 So i want data of only Nov, Oct and Sep or half september, Not till March. 所以我只想要11月,10月和9月或9月下半月的数据,直到3月。 Please guide. 请指导。

在此处输入图片说明

You can zoom to the point you want to start show the data to the last data item. 您可以缩放到要开始显示数据到最后一个数据项的位置。 Please check the code below: 请检查以下代码:

// Add the event listener
chart.addListener("init", zoomChart);

function zoomChart(e) {
  var chart = e.chart;
  var dataProvider = chart.dataProvider;

  // Zoom to the last 60 data items
  e.chart.zoomToIndexes(dataProvider.length - 60, dataProvider.length - 1);
}

Please check the example below. 请检查以下示例。 It uses a different approach where it shows the first day of the previous month. 它使用不同的方法显示上个月的第一天。

https://codepen.io/team/amcharts/pen/820eb490acae7b3a9f1346fc2144e27a?editors=1010 https://codepen.io/team/amcharts/pen/820eb490acae7b3a9f1346fc2144e27a?editors=1010

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM