function getCityTYJBarChart(dom,title,legendData,xAxisData,yAxisData){ // 使用 require( [ 'echarts', 'echarts/chart/bar' // 使用柱状图就加载bar模块,按需加载 ], function (ec) { // 基于准备好的dom,初始化echarts图表 var myChart = ec.init(dom); $("#ckjcjg_ytj_charts_bar").width('65%'); $("#ckjcjg_ytj_charts_bar").height('285px'); var option = { tooltip: { show: true }, title : { text: title, x:'center', subtext:'检查表类别:'+legendData }, dataZoom : { show : true, realtime : true, start : 0, end : 100, dataBackgroundColor:'rgba(0,0,0,0)', y:25 }, toolbox: { show : false, feature : { mark : {show: true}, dataView : {show: true, readOnly: false}, magicType : {show: true, type: ['line', 'bar']}, restore : {show: true}, saveAsImage : {show: true}, }, orient : 'vertical' }, xAxis : [ { type : 'category', data : xAxisData, axisLabel:{ interval:0, rotate:45, margin:2, textStyle:{ color:"#222" } } } ], yAxis : [ { type : 'value' } ], series : [ { "name":legendData, "type":"bar", "data":yAxisData, itemStyle: { normal: { color: function (value){ return "#"+("00000"+((Math.random()*16777215+0.5)>>0).toString(16)).slice(-6); }, label: { show: true, position: 'top', formatter: function(a){ if(a.value!=0){ return a.value; } else{ return ""; } } } } } } ] }; // 为echarts对象加载数据 myChart.setOption(option); } ); }