/**
* 顶部header
*/
Vue.component("oil-consumption-chart", {
template: `
`,
props: {
height:{
type:Number
},
data:{
type:Object
}
},
data() {
return {
option:{}
}
},
mounted(){
this.init()
},
methods: {
init(){
this.getChartData()
},
//分类及工时情况
getChartData(){
var chChartBar = echarts.init(this.$refs.chart);
this.echartBar(chChartBar,this.data)
},
echartBar(chChart,data){
let newPromise = new Promise((resolve) => {
resolve()
})
//然后异步执行echarts的初始化函数
newPromise.then(() => {
this.option = {
tooltip: {
trigger: "axis",
formatter: function (params) {
return (params[0].seriesName+"
"
+params[0].name +":"+ params[0].data + "L/h")
},
},
grid: {
top:'5%',
left: "2%",
right: "2%",
bottom: "0%",
containLabel: true,
},
xAxis: {
type: "category",
boundaryGap: false,
data: data.xAxis,
axisLine: {
//坐标轴轴线相关设置。数学上的x轴
show: true,
lineStyle: {
color: "#25597e",
type: "dashed",
},
},
axisTick: {
show: false
},
axisLabel: {
//坐标轴刻度标签的相关设置
textStyle: {
color: "#c5d9fc",
margin: 20,
fontSize:12
},
},
},
yAxis: {
type: "value",
axisLine: {
//坐标轴轴线相关设置。数学上的x轴
show: false,
lineStyle: {
color: "#c5d9fc",
type: "dashed",
},
},
axisTick: {
show: false
},
axisLabel: {
show: true,
//坐标轴刻度标签的相关设置
textStyle: {
color: "#c5d9fc",
margin: 20,
fontSize:12
},
},
splitLine: {
show: true,
lineStyle: {
color: "#25597e",
type: "dashed",
},
},
},
series: [
{
name: data.seriesName,
type: "line",
symbol: "circle", // 默认是空心圆(中间是白色的),改成实心圆
showAllSymbol: true,
symbolSize: 8,
lineStyle: {
normal: {
color: "#7c80f4", // 线条颜色
},
borderColor: "rgba(0,0,0,.4)",
},
itemStyle: {
color: "rgba(14,30,73,1)",
borderColor: "#646ace",
borderWidth: 2,
},
label: {
normal: {
show: true,
position: "top",
formatter: [" {a|{c}}"].join(","),
rich: {
a: {
color: "#fff",
align: "center",
},
},
},
},
tooltip: {
show: true,
},
areaStyle: {
//区域填充样式
normal: {
//线性渐变,前4个参数分别是x0,y0,x2,y2(范围0~1);相当于图形包围盒中的百分比。如果最后一个参数是‘true’,则该四个值是绝对像素位置。
color: new echarts.graphic.LinearGradient(
0,
0,
0,
1,
[
{
offset: 0,
color: "rgba(124, 128, 244,.6)",
},
{
offset: 1,
color: "rgba(124, 128, 244, 0)",
},
],
false
),
shadowColor: "rgba(53,142,215, 0.9)", //阴影颜色
shadowBlur: 20, //shadowBlur设图形阴影的模糊大小。配合shadowColor,shadowOffsetX/Y, 设置图形的阴影效果。
},
},
data: data.data,
},
],
};
chChart.setOption(this.option);
window.onresize = chChart.resize;
})
},
},
watch:{
data() {
this.init()
}
}
})