|
|
@ -5,6 +5,8 @@ |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
<script> |
|
|
|
|
|
|
|
import echarts from "echarts"; |
|
|
|
|
|
|
|
|
|
|
|
require("echarts/theme/macarons") |
|
|
|
require("echarts/theme/macarons") |
|
|
|
export default { |
|
|
|
export default { |
|
|
|
props: { |
|
|
|
props: { |
|
|
@ -21,6 +23,15 @@ export default { |
|
|
|
return { |
|
|
|
return { |
|
|
|
// 表单参数 |
|
|
|
// 表单参数 |
|
|
|
form: {}, |
|
|
|
form: {}, |
|
|
|
|
|
|
|
color1: ['#FA8072', '#0fec7d', '#ab36fc','#ffbd89', |
|
|
|
|
|
|
|
'#CD9B1D','#ff7f50', '#EE1289', '#ee9c9c', |
|
|
|
|
|
|
|
'#06e8d6', '#de79c2','#bebe0f', '#00F5FF', |
|
|
|
|
|
|
|
'#f50000', '#00CD66', '#c400fa', '#eca86c'], |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
color2: [ '#B22222', '#04793e', '#7705a4','#8a5c08', |
|
|
|
|
|
|
|
'#8B6914', '#a93f07', '#8B0A50', '#755252', |
|
|
|
|
|
|
|
'#078075', '#cd5c5c', '#8B8B00', '#6b8e23', |
|
|
|
|
|
|
|
'#590404', '#3cb371', '#48005d', '#5e4310'] |
|
|
|
}; |
|
|
|
}; |
|
|
|
}, |
|
|
|
}, |
|
|
|
created() { |
|
|
|
created() { |
|
|
@ -59,13 +70,19 @@ export default { |
|
|
|
xAxisType = 'category'; |
|
|
|
xAxisType = 'category'; |
|
|
|
yAxisBoundaryGap = [0,'5%']; |
|
|
|
yAxisBoundaryGap = [0,'5%']; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
let color = this.color1 |
|
|
|
|
|
|
|
var color2 = this.color2; |
|
|
|
var option = { |
|
|
|
var option = { |
|
|
|
title : { |
|
|
|
title : { |
|
|
|
text : title, |
|
|
|
text : title, |
|
|
|
subtext : '', |
|
|
|
subtext : '', |
|
|
|
x:'center' |
|
|
|
x:'center', |
|
|
|
|
|
|
|
textStyle:{ |
|
|
|
|
|
|
|
//文字颜色 |
|
|
|
|
|
|
|
color:'#464b50', |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
colors:[], |
|
|
|
color:color, |
|
|
|
tooltip : { |
|
|
|
tooltip : { |
|
|
|
trigger: 'axis', |
|
|
|
trigger: 'axis', |
|
|
|
formatter: function (params) { |
|
|
|
formatter: function (params) { |
|
|
@ -91,32 +108,57 @@ export default { |
|
|
|
feature : { |
|
|
|
feature : { |
|
|
|
mark : {show: true}, |
|
|
|
mark : {show: true}, |
|
|
|
// dataView : {show: true, readOnly: false}, |
|
|
|
// dataView : {show: true, readOnly: false}, |
|
|
|
restore : {show: true}, |
|
|
|
restore: { |
|
|
|
saveAsImage : {show: true} |
|
|
|
iconStyle: { |
|
|
|
|
|
|
|
borderColor: '#000' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
saveAsImage: { |
|
|
|
|
|
|
|
iconStyle: { |
|
|
|
|
|
|
|
borderColor: '#000', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
}, |
|
|
|
}, |
|
|
|
y:'center', |
|
|
|
y:'center', |
|
|
|
orient:'vertical' |
|
|
|
orient:'vertical' |
|
|
|
}, |
|
|
|
}, |
|
|
|
dataZoom: { |
|
|
|
// dataZoom: { |
|
|
|
show: true, |
|
|
|
// show: true, |
|
|
|
start : 0, |
|
|
|
// start : 0, |
|
|
|
end: 100 |
|
|
|
// end: 100 |
|
|
|
}, |
|
|
|
// }, |
|
|
|
legend : { |
|
|
|
legend : { |
|
|
|
data : legend, |
|
|
|
data : legend, |
|
|
|
x: 'right' |
|
|
|
right: 10, |
|
|
|
|
|
|
|
top:20, |
|
|
|
|
|
|
|
textStyle: { |
|
|
|
|
|
|
|
color: "#333" |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
itemWidth: 15, |
|
|
|
|
|
|
|
itemHeight: 8, |
|
|
|
}, |
|
|
|
}, |
|
|
|
grid: { |
|
|
|
grid: { |
|
|
|
top: '10%', |
|
|
|
left: '5%', |
|
|
|
y2: 70, |
|
|
|
right: '5%', |
|
|
|
y: 60 |
|
|
|
bottom: '5%', |
|
|
|
|
|
|
|
top: '15%', |
|
|
|
|
|
|
|
containLabel: true |
|
|
|
}, |
|
|
|
}, |
|
|
|
xAxis : [ |
|
|
|
xAxis : [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
// splitNumber:10, //x轴显示段数 |
|
|
|
// splitNumber:10, //x轴显示段数 |
|
|
|
type : xAxisType, |
|
|
|
type : xAxisType, |
|
|
|
// boundaryGap: ['20%', '20%'], |
|
|
|
// boundaryGap: ['20%', '20%'], |
|
|
|
|
|
|
|
axisLine: { |
|
|
|
|
|
|
|
lineStyle: { |
|
|
|
|
|
|
|
// color: '#cbcaca' |
|
|
|
|
|
|
|
color: '#b3b6b9' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
axisLabel: { |
|
|
|
axisLabel: { |
|
|
|
|
|
|
|
textStyle: { |
|
|
|
|
|
|
|
color: "#606e7a", |
|
|
|
|
|
|
|
}, |
|
|
|
// rotate: 60, |
|
|
|
// rotate: 60, |
|
|
|
formatter: function (value) { |
|
|
|
formatter: function (value) { |
|
|
|
var date = new Date(value); |
|
|
|
var date = new Date(value); |
|
|
@ -136,29 +178,97 @@ export default { |
|
|
|
yAxis : [ |
|
|
|
yAxis : [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
max: function (value) { |
|
|
|
max: function (value) { |
|
|
|
return value.max + 0.05 |
|
|
|
return (value.max + (value.max - value.min) * 0.3).toFixed(2) |
|
|
|
}, |
|
|
|
}, |
|
|
|
min: function (value) { |
|
|
|
min: function (value) { |
|
|
|
if(type == 'line'){ |
|
|
|
if(type == 'line'){ |
|
|
|
return value.min - 0.05 |
|
|
|
return (value.min - (value.max - value.min) * 0.3).toFixed(2) |
|
|
|
} |
|
|
|
} |
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|
}, |
|
|
|
}, |
|
|
|
type : 'value', |
|
|
|
type : 'value', |
|
|
|
axisLabel : { |
|
|
|
axisLabel : { |
|
|
|
|
|
|
|
textStyle: { |
|
|
|
|
|
|
|
color: "#606e7a", |
|
|
|
|
|
|
|
}, |
|
|
|
formatter: function (value,index) { |
|
|
|
formatter: function (value,index) { |
|
|
|
return value.toFixed(fixed); |
|
|
|
return value.toFixed(fixed); |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
axisLine: { |
|
|
|
|
|
|
|
show: true, |
|
|
|
|
|
|
|
lineStyle: { |
|
|
|
|
|
|
|
color: '#b3b6b9' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
name: unit, |
|
|
|
name: unit, |
|
|
|
|
|
|
|
nameTextStyle:{//y轴上方单位的颜色 |
|
|
|
|
|
|
|
color:'#464b50' |
|
|
|
|
|
|
|
}, |
|
|
|
nameLocation:'middle', |
|
|
|
nameLocation:'middle', |
|
|
|
nameGap:50, |
|
|
|
nameGap:50, |
|
|
|
// scale:true,//不从0开始 |
|
|
|
// scale:true,//不从0开始 |
|
|
|
boundaryGap: yAxisBoundaryGap |
|
|
|
boundaryGap: yAxisBoundaryGap |
|
|
|
} |
|
|
|
} |
|
|
|
], |
|
|
|
], |
|
|
|
series : series |
|
|
|
series : [] |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (type == 'bar'){ |
|
|
|
|
|
|
|
for (let i = 0; i < series.length; i++) { |
|
|
|
|
|
|
|
option.series.push( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: series[i]["name"], |
|
|
|
|
|
|
|
type: type, |
|
|
|
|
|
|
|
barMaxWidth: '20', |
|
|
|
|
|
|
|
// symbolSize: 0, |
|
|
|
|
|
|
|
itemStyle: { |
|
|
|
|
|
|
|
normal: { |
|
|
|
|
|
|
|
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ |
|
|
|
|
|
|
|
offset: 0, |
|
|
|
|
|
|
|
color: color[i] |
|
|
|
|
|
|
|
}, { |
|
|
|
|
|
|
|
offset: 1, |
|
|
|
|
|
|
|
color: color2[i] |
|
|
|
|
|
|
|
}]), |
|
|
|
|
|
|
|
barBorderRadius: 11, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: series[i]["data"] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
for (let i = 0; i < series.length; i++) { |
|
|
|
|
|
|
|
if (series[i]["type"] == 'line'){ |
|
|
|
|
|
|
|
option.series.push({ |
|
|
|
|
|
|
|
name: series[i]["name"], |
|
|
|
|
|
|
|
type: 'line', |
|
|
|
|
|
|
|
showSymbol: false, |
|
|
|
|
|
|
|
smooth: true, |
|
|
|
|
|
|
|
lineStyle: { |
|
|
|
|
|
|
|
width: 2, |
|
|
|
|
|
|
|
color: new this.$echarts.graphic.LinearGradient(0, 1, 0, 0, [ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
offset: 0, |
|
|
|
|
|
|
|
color: color[i] |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
offset: 1, |
|
|
|
|
|
|
|
color: color2[i] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
]), |
|
|
|
|
|
|
|
shadowColor: 'rgba(241,240,246,0.84)', |
|
|
|
|
|
|
|
shadowBlur: 5, |
|
|
|
|
|
|
|
shadowOffsetY: 3 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
data: series[i]["data"] |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
option.series.push(series[i]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
return option; |
|
|
|
return option; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|