javascript Amcharts adding listeners

trante picture trante · Apr 10, 2013 · Viewed 9.3k times · Source

I have two functions like this:

    function zoomChart() {
        chart.zoomToIndexes(0, 20000);
    }

    function zoomAtStartToLast90() {
        var dataLength = am_chartData.length;
        chart.zoomToIndexes(dataLength - 90, dataLength - 1);
    }

When I draw the chart at the beginning, I want to see last 90 records. So I need to call for zoomAtStartToLast90() function, but when I make an update on chart I want to see all 20k records, so I will call for zoomChart().

inside AmCharts.ready(function () { I call this: chart.addListener("dataUpdated", zoomChart);

But where can I call zoomAtStartToLast90() function ? If I add it to addListener, chart is zoomed to last 90 records. Is it possible to call some function just after creeating chart ?

Answer

Sandeep picture Sandeep · Apr 12, 2013

to trigger a function just after creating chat you can use init event..

REF: AMcharts Docs