angular.js中使用echars,第一次点击饼图页面,饼图正常显示,点击app同级页面后,再回到饼图页面,饼图显示空白,但是F5刷新后,饼图可以看见。请问是什么问题?困扰很久!
配置项如下
我是在angular.js中使用echars图标的饼图,首次加载饼图出现,
饼图在参数页面内!
当点击曲线,温度,状态等页面后,再点击参数页面(饼图在参数页面)后,饼图区域显示空白!!F5刷新后饼图会再次出现!~!!请高手帮忙!
下面是我代码!只是正常的饼图代码。
var myChart = echarts.init(document.getElementById('parameter_main'));
// 指定图表的配置项和数据
var labelTop = {
normal : {
label : {
show : true,
position : 'center',
formatter : '{b}',
textStyle: {
baseline : 'bottom'
}
},
labelLine : {
show : false
}
},
};
var labelFromatter = {
normal : {
label : {
formatter : function (params){
// console.log(params)
if (params.seriesIndex == 0){
if(params.value > 100 || params.value < 0){
return 100;
}
else{
return (100-params.value).toFixed(2);
}
}
else if(params.seriesIndex == 1){
//console.log(params.seriesIndex,'==1')
if(params.value > 20 || params.value < 0){
return 20;
}
else{
return 20-params.value;
}
}
else if(params.seriesIndex == 2){
if(params.value > 10 || params.value < 0){
return 10;
}
else{
return 10-params.value;
}
}
else if(params.seriesIndex == 3){
if(params.value > 400){
return 400;
}
else{
return 400-params.value;
}
}
},
textStyle: {
baseline : 'top'
}
}
},
}
var labelBottom = {
normal : {
color: '#ccc',
label : {
show : true,
position : 'center'
},
labelLine : {
show : false
}
},
emphasis: {
color: 'rgba(0,0,0,0)'
}
};
var radius = [30, 40];
options = {
legend: {
data:[]
},
series : [
{
type : 'pie',
center : ['25%', '25%'],
radius : radius,
x: '0%', // for funnel
itemStyle : labelFromatter,
data : [
{name:'other', value: 100-char_xishu, itemStyle : labelBottom},
{name:'挤压系数',value:char_xishu,itemStyle : labelTop}
]
},
{
type : 'pie',
center : ['75%', '25%'],
radius : radius,
x:'20%', // for funnel
itemStyle : labelFromatter,
data : [
{name:'other', value:20-char_sudu, itemStyle : labelBottom},
{name:'挤压速度', value:char_sudu,itemStyle : labelTop}
]
},
{
type : 'pie',
center : ['25%', '75%'],
radius : radius,
x:'40%', // for funnel
itemStyle : labelFromatter,
data : [
{name:'other', value:10-char_yali, itemStyle : labelBottom},
{name:'填充压力', value:char_yali,itemStyle : labelTop}
]
},
{
type : 'pie',
center : ['75%', '75%'],
radius : radius,
x:'60%', // for funnel
itemStyle : labelFromatter,
data : [
{name:'other', value:400-char_houdu, itemStyle : labelBottom},
{name:'压余厚度', value:char_houdu,itemStyle : labelTop}
]
}
]};
// 使用刚指定的配置项和数据显示图表。
//console.log(option,char_xishu,char_sudu,'option')
//myChart.clear();
// myChart.refresh();
myChart.setOption(options);