Question

I would like to scroll the amcharts flex stock chart programmatically on it's horizontal axis, in other words along the time axis.

I need to do this, because I need to scroll one period at a time and would like to hook this up to keyboard events.

I couldn't find anything in the documentation here: http://flex.amcharts.com/stock_class_reference/com/amcharts/stock/package-detail.html

I've also tried mucking around with the period selector to see whether I can change the values on it, but no luck there.

Was it helpful?

Solution

You should simply set some interval and zoom chart each time. For example:

private function initialZoom():void
{
    var firstDate:Date = dataSet.dataProvider[0].date;
    var endDate:Date = new Date(firstDate);
    endDate.setDate(endDate.getDate() + 20);
    chart.zoom(firstDate, endDate);
    setInterval(zoomChart, 1000);
}

private function zoomChart():void
{
    var startDate:Date = new Date(chart.startDate);
    var endDate:Date = new Date(chart.endDate);

    startDate.setDate(startDate.getDate() + 1);
    endDate.setDate(endDate.getDate() + 1);

    chart.zoom(startDate, endDate);
}

initialZoom should be called on dataUpdated event fired by AmStockChart. Note, you shouldn't set any period as "selected" in order this to work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top