function generatePieChart(chartData, counter='', diffSeparator=''){
var chart;
var legend;
//chartData = "["+chartData+"]";
AmCharts.ready(function () {
// PIE CHART
chart = new AmCharts.AmPieChart();
chart.dataProvider = chartData;
chart.titleField = "stage";
chart.valueField = "enquiryCount";
chart.depth3D = 10;
chart.angle = 10;
// LEGEND
legend = new AmCharts.AmLegend();
legend.align = "center";
legend.markerType = "circle";
chart.balloonText = "[[title]]<br><span style='font-size:14px'><b>[[value]]</b> ([[percents]]%)</span>";
//chart.addLegend(legend);
// WRITE
chart.write("chart_div_"+diffSeparator+"_"+counter);
});
}
generatePieChart(<?=$data?>,'<?=$i?>','o');
I am trying to generate graphs as it needs to be generated 10 times. So, instead of placing the complete jquery, i created the generation section to a function as you can see. Then while calling the function, it is providing me error saying "Uncaught reference error". I also checked many of the post's describing different solution. I tried all of them but none of them worked. And the most annoying thing is that, the same script works in firefox but not in chrome.
The following line is not valid JavaScript
function generatePieChart(chartData, counter='', diffSeparator='') {
Remove the =''
from the parameters.
The parameters will default to the datatypes of the values passed in to the function when it is called. Which in your example are strings anyway.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With