You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.4 KiB
84 lines
2.4 KiB
/**
|
|
* @param config
|
|
* config.x
|
|
* config.y
|
|
* config.id
|
|
* config.type : line
|
|
* config.xunit
|
|
* config.yunit
|
|
* config.yunit_c
|
|
* @returns
|
|
*/
|
|
function echartInit(config){
|
|
var myChart = echarts.init(document.getElementById(config.id));
|
|
var option ='';
|
|
if(config.type == 'line'){
|
|
// 折线图
|
|
option = {
|
|
tooltip : {
|
|
trigger: 'axis',
|
|
formatter: function(params) {
|
|
return tom( config.xunit!=null,config.xunit+": ","" ) + params[0].name + '<br/>'
|
|
+ params[0].seriesName + ' : ' + params[0].value + ' '+ gdv(config.yunit_c) ;
|
|
}
|
|
},
|
|
// toolbox: {
|
|
// show : true,
|
|
// feature : {
|
|
// saveAsImage : {show: true}
|
|
// }
|
|
// },
|
|
grid: {y:30, x2:50,y2: 70,x: 65},
|
|
xAxis: {
|
|
name: gdv(config.xunit) ,
|
|
type: 'category',
|
|
data: config.x,
|
|
axisLabel:{
|
|
formatter:function(params) {
|
|
return params.replace(/.{10}(?!$)/g, (a) => a + '\n')
|
|
}
|
|
}
|
|
},
|
|
yAxis: {
|
|
name : gdv(config.yunit)+ tom(config.yunit_c!=null,'('+config.yunit_c+')','' ) ,
|
|
type: 'value',
|
|
axisLabel : {
|
|
formatter: '{value} ' // +gdv(config.yunit_c)
|
|
},
|
|
// min:800 ,
|
|
// splitNumber:10
|
|
},
|
|
dataZoom : {
|
|
show : true,
|
|
realtime : true,
|
|
start : 0,
|
|
end : 100
|
|
},
|
|
series: [{
|
|
name:gdv(config.yunit),
|
|
data: config.y,
|
|
type: 'line',
|
|
smooth: true,
|
|
// markPoint : {
|
|
// data : [
|
|
// {type : 'max', name: '最大值'},
|
|
// {type : 'min', name: '最小值'} ]
|
|
// },
|
|
// markLine : {
|
|
// data : [
|
|
// {type : 'average', name: '平均值'} ]
|
|
// }
|
|
}]
|
|
};
|
|
if(config.stepStyle==true){
|
|
option.series[0].smooth=false;
|
|
option.series[0].step='start';
|
|
option.series[0].markPoint=null;
|
|
option.series[0].markLine=null;
|
|
}
|
|
}
|
|
if(!validater.empty(config.option)){
|
|
$.extend(option,config.option);
|
|
}
|
|
myChart.setOption(option);
|
|
}
|