xhtml引用amcharts.js文件,当第一次访问到该页面时做了判断,判断当有数据时,创建AmPieChart饼状图if(datesource != "[]"){
//document.getElementById(divid).style.display="block";
var chart = new AmCharts.AmPieChart();
chart.addTitle(title,13);
chart.dataProvider = eval('(' + datesource + ')');
chart.titleField = "catergory";
chart.valueField = "value";
chart.outlineColor = "#FFFFFF";
chart.colorField = "colorField";
chart.outlineAlpha = 0.8;
chart.outlineThickness = 2;
// this makes the chart 3D
chart.depth3D = 15; //厚度
chart.angle = 60; //饼图倾斜角度
chart.fontSize = 13; //字体
chart.labelRadius = 20; //文字与饼图之间的距离
// WRITE
chart.write(divid);
}问题:当在页面进行第一次条件查询时,能够显示饼状图,并且没有任何脚本错误,但是当第二次查询时,发生脚本错误注释:点击查询按钮时,没有进入后台,richfaces标签的,a4j:commandButton标签的事件好像是屏蔽掉了还是什么情况。其他浏览器没有这样的问题,IE9也没有问题javascriptxhtml脚本ie8
//document.getElementById(divid).style.display="block";
var chart = new AmCharts.AmPieChart();
chart.addTitle(title,13);
chart.dataProvider = eval('(' + datesource + ')');
chart.titleField = "catergory";
chart.valueField = "value";
chart.outlineColor = "#FFFFFF";
chart.colorField = "colorField";
chart.outlineAlpha = 0.8;
chart.outlineThickness = 2;
// this makes the chart 3D
chart.depth3D = 15; //厚度
chart.angle = 60; //饼图倾斜角度
chart.fontSize = 13; //字体
chart.labelRadius = 20; //文字与饼图之间的距离
// WRITE
chart.write(divid);
}问题:当在页面进行第一次条件查询时,能够显示饼状图,并且没有任何脚本错误,但是当第二次查询时,发生脚本错误注释:点击查询按钮时,没有进入后台,richfaces标签的,a4j:commandButton标签的事件好像是屏蔽掉了还是什么情况。其他浏览器没有这样的问题,IE9也没有问题javascriptxhtml脚本ie8
if(datesource != "[]"){
chart && chart.clear()
chart = new AmCharts.AmPieChart();
是呀,我测过没加 chart.clear() 清空一下,多刷下会报 SCRIPT16389: 未指明的错误。
amcharts.js, 行59 字符365,加了 chart.clear() 就可以了你要把 chart 设成全局变量
是呀,我测过没加 chart.clear() 清空一下,多刷下会报 SCRIPT16389: 未指明的错误。
amcharts.js, 行59 字符365,加了 chart.clear() 就可以了你要把 chart 设成全局变量
刚才我试了一下,chart.clear()肯定是有这个方法的,但是点击a4j:commandButton按钮进行查询的时候,在前台就提示脚本错误,就是上面的图,根本就没有进后台,连前台的js函数都没有进
你第一次初始放在 AmCharts.ready( function(){
chart = new AmCharts.AmPieChart();
。。
} ) 以后数据更新调用
chart.dataProvider = chartData;
chart.validateData()