1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 折线图echats

折线图echats

时间:2022-11-04 14:00:11

相关推荐

折线图echats

jsp

<div id="chartContainer" style="width:98%;height:48%"></div>

js

//初始化图表require.config({paths : {echarts : basePath+'/libs/echarts'}});require([ 'echarts','echarts/chart/bar', 'echarts/chart/line'],DrawEChart);function DrawEChart(echarts) {option = {title : {'text':'用电量'},tooltip : {trigger: 'axis', // x轴参数axisPointer : { // 坐标轴指示器,坐标轴触发有效type : 'shadow'// 默认为直线,可选为:'line' | 'shadow'}},legend: {x:'right',data:['用电量预测值', '用电量预测最大值', '用电量预测最小值']},toolbox: {show : true,orient: 'vertical',x: 'right',y: 'center',feature : {magicType : {show: true, type: ['line', 'bar', 'stack', 'tiled']},restore : {show: true},saveAsImage : {show: true}}},calculable : true,xAxis : [{type : 'category',data : ['']}],yAxis : [{'type':'value','name':'万千瓦时'}],series : [{name:'用电量预测值',type:'line',data:[]},{name:'用电量预测最大值',type:'line',data:[]},{name:'用电量预测最小值',type:'line',data:[]}]};$.ajax({type : "get",cache : false,url : basePath + "/sumServlet.do?action=chartData",dataType : "json",success : function(result) {console.log(Object.keys(result).length);for(var key in result){console.log("属性:" + key + ",值:"+ JSON.stringify(result[key]));if(result["Axis"].length>0){option.xAxis[0].data = result["Axis"];option.series[0].data = result["powerFore"];option.series[1].data = result["powerForeMax"];option.series[2].data = result["powerForeMin"];}}myChart = echarts.init(document.getElementById('chartContainer'));myChart.setOption(option); // myChart.setTheme(theme);}});}

servlet

PrintWriter out = response.getWriter();JSONObject data = new JSONObject();data = this.sumService.chartData();logger.info("datachart:" + data.toString());out.write(data.toString());out.flush();out.close();

service

...data.put("powerFore", powerForeArray);data.put("powerForeMax", powerForeMaxArray);data.put("powerForeMin", powerForeMinArray);data.put("Axis",xArray);//年份...

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。