How to change zoom level of amStockChart programmatically?

185 Views Asked by At

I want to change the zoom level of my amStockChart from 1H to 1W through javascript code (without clicking the period selector buttons). I am using amcharts 3 and am not able to find a way to do this. My chart is a normal one like any of the example from amCharts website. Also I am not pasting my chart config here as it will not add any value to the question as this is not config dependent.

2

There are 2 best solutions below

1
Kashyap Kotak On BEST ANSWER

May be you can try this:

yourChartObject.periodSelector.periods[yourDesiredZoomLevel].button.click();
0
xorspark On

You have to set the selected property of the period in your periodSelector's periods array and call setDefaultPeriod afterward to simulate the click.

  chart.periodSelector.periods[0].selected = true;
  chart.periodSelector.setDefaultPeriod();

You'll need to unset the selected property of any other previously selected period, of course.