1.定义一个参数,返回根据判断什么条件是否显示值; 2.var a = '<%=(String)request.getAttribute("type")%&>'; 代码如下 var legend_list=[];//判断类型为4时则显示mgetval值 if(a=="4") { legend_list=[ {name: '预测值', textStyle:{color:"#ffffff"} }, {name:'实际值', textStyle:{color:"#ffffff"}}, {name:'目标值', textStyle:{color:"#ffffff"}}, ]; } else{ legend_list=[ {name: '预测值', textStyle:{color:"#ffffff"} }, {name:'实际值', textStyle:{color:"#ffffff"}} ]; } var option = { title: { text: '', textStyle: { color: '#ffffff' }, }, legend: { data:legend_list }, tooltip: { trigger: 'axis' }, xAxis: [{ type: 'category', axisLabel: { show: true, textStyle: { color: '#ffffff' } }, axisTick:{ show:false, }, splitLine:{show: false}, boundaryGap: false, data: ['一月', '二月', '三月', '四月', '五月', '六月', '七月','八月','九月','十月','十一月','十二月'] }], grid :{ borderWidth :'0px' }, yAxis: [{ type: 'value', axisLabel: { show: true, textStyle: { color: '#ffffff' } }, splitLine:{show: false} }], series: [ { name: '实际值', type: 'line', itemStyle: { normal: { areaStyle: { type: 'default' } } }, data: [<%=factval%>] }, { name: '预测值', type: 'line', itemStyle: { normal: { areaStyle: { type: 'default' } } }, data: [<%=targetval%>] }, { name: '目标值', type: 'line', itemStyle: { normal: { areaStyle: { type: 'default' } } }, data: [<%=mgetval%>] }] }; mychar.setOption(option); window.onresize=mychar.resize;

posted on 2017-09-11 14:21  何丸子  阅读(641)  评论(0编辑  收藏  举报