How do I interface with Amcharts from outside chart creation functions?

Viewed 2216

If I create an amchart, and in creation I set the hidden value of one of the data sets to true:

function loadChart(container, chartstodisplay) {

    AmCharts.ready(function () {
        //Do all my regular chart creation here

        //but make sure hidechart shows up hidden
        if(key == 'hidechart'){
            graphs[key].hidden = true;
        }                           

        //now write the chart
        chart.write(container);
    });
}

Now here I am later in my page, and I have some html that is associated with the chart etc. For example, I have a link that if you hover over, I want "hidechart" to now be visible, please realize this functionality is completely separate from the legend blocks that AMcharts creates that you can click to hide/unhide, this is separate on page html.

$(document).ready(function(){

    $('#some_parent').on('click','span.unhide',function(){
        //now go back to the hidden chart element from above and change
        graph['hidechart'].hidden = false;
        //obviously that doesn't work
     })

})

So is there any context in which I can reach and influence the charts and graphs? How do I have to approach this?

2 Answers
Related