Mari
Mari

Reputation: 39

Always having the year display at my origin of a graph in AMCharts

Good day all I am having a bit of trouble. I have a graph that ranges from 2012 to 2015. I need my year to display at my origin once I zoom in. At this stage my the year only displays at the beginning of every year. It takes the place of January. Is it possible to do this?

chart3.addListener("zoomed", function(e) {
    var date = $( ".chartdiv3 .amChartsPeriodSelector .amChartsInputField" )
        .map(function() {
            return $(this).val();
        }).get();
    $(this).html(date.join(' <i style="color: #F47C00;">to</i> '));
    chart3.panels[0].titles[1].text = "period - " + date[0] + " to " +     date[1];
    chart3.panels[0].validateData();
});
chart3.write('chartdiv3');

Upvotes: 0

Views: 231

Answers (1)

gerric
gerric

Reputation: 2297

Ok. So changing the labelFunction depending on zoom is pretty easy. Just take a look at this fiddle. (I used this as template).

The other approach is not as easy as i thought. You can modify the labels when the zoomed event is fired, however i haven't found a way to get the year for the first label. (it's an amcharts object containing the svg but no date, just the plain text for the label)

Upvotes: 1

Related Questions