admin管理员组文章数量:1410697
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 plete 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.
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 plete 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.
Share Improve this question edited Mar 20, 2014 at 10:30 Mark Walters 12.4k6 gold badges35 silver badges48 bronze badges asked Mar 14, 2014 at 10:56 Ck MauryaCk Maurya 2,2552 gold badges20 silver badges27 bronze badges 2- 2 on a sidenote: what does this have to do with PHP exactly? Please don't tag questions with tags that don't have anything to do with it. – Tularis Commented Mar 14, 2014 at 11:04
- @Tularis I agree, I guess the OP added this because the parameters to the function were PHP variables. I've removed this tag as it is misleading. – Mark Walters Commented Mar 14, 2014 at 11:15
1 Answer
Reset to default 5The 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.
本文标签: javascriptUncaught reference errorfunction is not definedStack Overflow
版权声明:本文标题:javascript - Uncaught reference error - function is not defined - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744306149a2599803.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论