If I want to add some interactivity to the chart that I created with Apex I need to add an event listener like this:
// Create new chart
var chart = new AnyChart();
// Add event handler for point event
But I am using the wizard chart created from the APEX GUI, so I did not create the anychart object in my code such as
I would have to know the object name that was created for my chart by APEX.
Then I could code :
Can anyone help?
Give the chart region a static id, then you can use this to get the chart object:
Where "chart1" is the static id, and "chart1_chart" is an element being created in the region. Thus, just concatenate your static id with "_chart". "object" will select the anychart object element.
Excellent I can go further now but hit another problem.
I set the id of the chart region to p41chart, and I checked then page source an I saw that it had a id="p41chart_chart" so I am on the right track.
I created a button which is running a Dynamic Action.
In the dynamic action attached to this button a write this code
var chart=AnyChart.getChartById($("#p41chart_chart object"));
On Selection Type of Dynamic Action I set DOM Object with value p41chart_chart
When I press the button I am getting
Ah sorry, I forgot something (Copy-paste blundering). The point of giving the region a static id is indeed to retrieve the object element, though not to get the anychart object with it. The getChartById expects the id of the object element, not that element itself. So:
And that'll correctly fetch you the AnyChart object!