资源描述:
《echart学习总结140708》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、series:[{name:'降雨量',type:'bar',xAxisIndex:0,--xAxis坐标轴数组的索引,指定该系列数据所用的纵坐标轴yAxisIndex:1,--yAxis坐标轴数组的索引,指定该系列数据所用的纵坐标轴data:(function(){varoriData=[0.126,0.69,0.182,0.349,0.231,0.146,0.128,0.167,0.1,0.075,0.071,0.071,0.117,0.01,0.002];varlen=oriData.length;while(len--
2、){--用于将数据颠倒显示oriData[len]*=-1;}returnoriData;})()}]tooltip:{--多条线时显示多个信息trigger:'axis',formatter:function(v){returnv[0][1]+'
'+v[0][0]+':'+v[0][2]+'(m^3/s)
'+v[1][0]+':'+-v[1][2]+'(mm)';}},----显示加载动画clearTimeout(loadingTicket);loadingTicket=setTimeout(functi
3、on(){myChart.hideLoading();myChart.setOption(option);},2200);option={legend:{orient:'horizontal',//'vertical'x:'right',//'center'
4、'left'
5、{number},y:'top',//'center'
6、'bottom'
7、{number}backgroundColor:'#eee',borderColor:'rgba(178,34,34,0.8)',borderWidth:4,padding:10,//
8、[5,10,15,20]itemGap:20,textStyle:{color:'red'},selected:{'降水量':false},data:[{name:'蒸发量',icon:'image://../asset/ico/favicon.png',textStyle:{fontWeight:'bold',color:'green'}},'降水量','最高气温','最低气温']},xAxis:{data:['周一','周二','周三','周四','周五','周六','周日']},yAxis:[{type:'value',
9、axisLabel:{formatter:'{value}ml'}},{type:'value',axisLabel:{formatter:'{value}°C'},splitLine:{show:false}}],series:[{name:'蒸发量',type:'bar',data:[2.0,4.9,7.0,23.2,25.6,76.7,135.6]},{name:'最高气温',type:'line',yAxisIndex:1,data:[11,11,15,13,12,13,10]},{name:'降水量',type:'b
10、ar',data:[2.6,5.9,9.0,26.4,28.7,70.7,175.6]}]};//动态添加默认不显示的数据varecConfig=require('echarts/config');myChart.on(ecConfig.EVENT.LEGEND_SELECTED,function(param){varselected=param.selected;varlen;varadded;if(selected['最低气温']){len=option.series.length;added=false;while(le
11、n--){if(option.series[len].name=='最低气温'){//已经添加added=true;break;}}if(!added){myChart.showLoading({text:'数据获取中',effect:'whirling'});setTimeout(function(){option.series.push({name:'最低气温',type:'line',yAxisIndex:1,data:[-2,1,2,5,3,2,0]});myChart.hideLoading();myChart.se
12、tOption(option);},2000)}}});varecConfig=require('echarts/config');functioneConsole(param){varmes='【'+param.type+'】';if(typeofparam.seriesI