|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div class="chart" :id="id"></div>
|
|
|
+ <div class="chart" id="equipment"></div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
@@ -45,8 +45,8 @@ export default {
|
|
|
"#005bd9",
|
|
|
"#019f2e",
|
|
|
"#db6200",
|
|
|
- "#a10f0f",
|
|
|
- "#850894",
|
|
|
+ "#d24645",
|
|
|
+ "#f00bd8",
|
|
|
"#9fa0a2",
|
|
|
],
|
|
|
},
|
|
@@ -56,126 +56,293 @@ export default {
|
|
|
id: "",
|
|
|
chart: null,
|
|
|
newlist: null,
|
|
|
+ chooseItem: {},
|
|
|
+ seriesData: [],
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
- list: {
|
|
|
- handler(newValue, oldValue) {
|
|
|
- this.newlist = newValue;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.newlist = this.list;
|
|
|
- this.initChart();
|
|
|
- });
|
|
|
- },
|
|
|
- deep: true,
|
|
|
+ lossPower() {
|
|
|
+ this.seriesData = [
|
|
|
+ {
|
|
|
+ value: this.lossPower.XNSS ? this.lossPower?.XNSS?.toFixed(2) : 0,
|
|
|
+ name: "性能损失",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: this.lossPower.WHSS ? this.lossPower?.WHSS?.toFixed(2) : 0,
|
|
|
+ name: "维护损失",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: this.lossPower.GZSS ? this.lossPower?.GZSS?.toFixed(2) : 0,
|
|
|
+ name: "故障损失",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: this.lossPower.XDSS ? this.lossPower?.XDSS?.toFixed(2) : 0,
|
|
|
+ name: "限电损失",
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: this.lossPower.SLSS ? this.lossPower?.SLSS?.toFixed(2) : 0,
|
|
|
+ name: "受累损失",
|
|
|
+ },
|
|
|
+ ];
|
|
|
},
|
|
|
},
|
|
|
- computed: {},
|
|
|
+
|
|
|
methods: {
|
|
|
resize() {},
|
|
|
initChart() {
|
|
|
- const chart = echarts.init(this.$el);
|
|
|
+ const chart = echarts.init(document.getElementById("equipment"));
|
|
|
+ let max =
|
|
|
+ Math.max.apply(
|
|
|
+ Math,
|
|
|
+ this.seriesData.map(function (o) {
|
|
|
+ return o.value;
|
|
|
+ })
|
|
|
+ ) || 0;
|
|
|
+ let index = this.seriesData.findIndex((item) => item.value == max);
|
|
|
+ let total =
|
|
|
+ this.seriesData.reduce((a, b) => {
|
|
|
+ return a + b.value * 1;
|
|
|
+ }, 0) || 0;
|
|
|
+ let title = this.seriesData.find((item) => item.value == max)?.name || "";
|
|
|
+
|
|
|
let option = {
|
|
|
color: this.color,
|
|
|
- radar: [
|
|
|
- {
|
|
|
- indicator: [{ text: "" }],
|
|
|
- center: ["47%", "50%"],
|
|
|
- radius: [0, 79],
|
|
|
- startAngle: 60,
|
|
|
- splitNumber: 5,
|
|
|
- shape: "circle",
|
|
|
- name: {
|
|
|
- formatter: "",
|
|
|
- textStyle: {
|
|
|
- color: "#0000FF",
|
|
|
+
|
|
|
+ // radar: [
|
|
|
+ // {
|
|
|
+ // indicator: [{ text: "" }],
|
|
|
+ // center: ["47%", "50%"],
|
|
|
+ // radius: [0, 79],
|
|
|
+ // startAngle: 60,
|
|
|
+ // splitNumber: 5,
|
|
|
+ // shape: "circle",
|
|
|
+ // name: {
|
|
|
+ // formatter: "",
|
|
|
+ // textStyle: {
|
|
|
+ // color: "#0000FF",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // splitArea: {
|
|
|
+ // areaStyle: {
|
|
|
+ // color: "rgba(0, 0, 0, 0)",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // axisLine: {
|
|
|
+ // lineStyle: {
|
|
|
+ // color: "rgba(0, 0, 0, 0)",
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // splitLine: {
|
|
|
+ // lineStyle: {
|
|
|
+ // color: "#0a389c",
|
|
|
+ // shadowColor: "#0a389c",
|
|
|
+ // shadowBlur: 10,
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ // tooltip: {
|
|
|
+ // trigger: "item",
|
|
|
+ // },
|
|
|
+ // series: [
|
|
|
+ // {
|
|
|
+ // name: "",
|
|
|
+ // type: "pie",
|
|
|
+ // radius: [0, 80],
|
|
|
+ // center: ["47%", "50%"],
|
|
|
+ // roseType: "area",
|
|
|
+ // label: {
|
|
|
+ // formatter: "{d}%",
|
|
|
+ // padding: [-20, -25, 10, 5],
|
|
|
+ // },
|
|
|
+ // itemStyle: {
|
|
|
+ // normal: {
|
|
|
+ // // 阴影的大小
|
|
|
+ // shadowBlur: 20,
|
|
|
+ // // 阴影水平方向上的偏移
|
|
|
+ // shadowOffsetX: 0,
|
|
|
+ // // 阴影垂直方向上的偏移
|
|
|
+ // shadowOffsetY: 0,
|
|
|
+ // // 阴影颜色
|
|
|
+ // shadowColor: "rgba(0,70,199, 0.8)",
|
|
|
+ // },
|
|
|
+ // borderRadius: 2,
|
|
|
+ // },
|
|
|
+ // data: [
|
|
|
+ // {
|
|
|
+ // value: this.lossPower.XNSS
|
|
|
+ // ? this.lossPower?.XNSS?.toFixed(2)
|
|
|
+ // : 0,
|
|
|
+ // name: "性能损失",
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: this.lossPower.WHSS
|
|
|
+ // ? this.lossPower?.WHSS?.toFixed(2)
|
|
|
+ // : 0,
|
|
|
+ // name: "维护损失",
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: this.lossPower.GZSS
|
|
|
+ // ? this.lossPower?.GZSS?.toFixed(2)
|
|
|
+ // : 0,
|
|
|
+ // name: "故障损失",
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: this.lossPower.XDSS
|
|
|
+ // ? this.lossPower?.XDSS?.toFixed(2)
|
|
|
+ // : 0,
|
|
|
+ // name: "限电损失",
|
|
|
+ // },
|
|
|
+ // {
|
|
|
+ // value: this.lossPower.SLSS
|
|
|
+ // ? this.lossPower?.SLSS?.toFixed(2)
|
|
|
+ // : 0,
|
|
|
+ // name: "受累损失",
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ // },
|
|
|
+ // ],
|
|
|
+ legend: {
|
|
|
+ top: 40,
|
|
|
+ right: 30,
|
|
|
+ orient: "vertical", //改变排列方式
|
|
|
+ itemGap: 15, // 设置legend的间距
|
|
|
+ itemWidth: 10, // 设置宽度
|
|
|
+ itemHeight: 10, // 设置高度
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 15,
|
|
|
+ color: "#fff",
|
|
|
+ },
|
|
|
+ itemStyle: {
|
|
|
+ borderColor: "transparent",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ title: {
|
|
|
+ text: `{val|${
|
|
|
+ max && total ? Number((max / total) * 100).toFixed(2) : 0
|
|
|
+ }%}\n{name|${title || ""}}`,
|
|
|
+ top: "43%",
|
|
|
+ left: "34%",
|
|
|
+ textAlign: "center",
|
|
|
+ textStyle: {
|
|
|
+ rich: {
|
|
|
+ name: {
|
|
|
+ fontSize: 15,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[index],
|
|
|
},
|
|
|
- },
|
|
|
- splitArea: {
|
|
|
- areaStyle: {
|
|
|
- color: "rgba(0, 0, 0, 0)",
|
|
|
+ val: {
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[index],
|
|
|
},
|
|
|
},
|
|
|
- axisLine: {
|
|
|
- lineStyle: {
|
|
|
- color: "rgba(0, 0, 0, 0)",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ radius: ["60%", "65%"],
|
|
|
+ center: ["35%", "50%"],
|
|
|
+ type: "pie",
|
|
|
+ avoidLabelOverlap: false,
|
|
|
+ hoverAnimation: false,
|
|
|
+ label: {
|
|
|
+ position: "center",
|
|
|
+ normal: {
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: "bold",
|
|
|
+ show: true,
|
|
|
+ padding: [-25, -40, 5, 1],
|
|
|
+ formatter: (params) => {
|
|
|
+ return `${params.name}${params.percent}%`;
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
- splitLine: {
|
|
|
+
|
|
|
+ labelLine: {
|
|
|
lineStyle: {
|
|
|
- color: "#0a389c",
|
|
|
- shadowColor: "#0a389c",
|
|
|
- shadowBlur: 10,
|
|
|
+ width: 1,
|
|
|
},
|
|
|
},
|
|
|
+ itemStyle: {
|
|
|
+ borderColor: "#000",
|
|
|
+ },
|
|
|
+ data: this.seriesData,
|
|
|
},
|
|
|
- ],
|
|
|
- tooltip: {
|
|
|
- trigger: "item",
|
|
|
- },
|
|
|
- series: [
|
|
|
{
|
|
|
name: "",
|
|
|
type: "pie",
|
|
|
- radius: [0, 80],
|
|
|
- center: ["47%", "50%"],
|
|
|
- roseType: "area",
|
|
|
+ radius: ["30%", "60%"],
|
|
|
+ center: ["35%", "50%"],
|
|
|
+ avoidLabelOverlap: false,
|
|
|
+ hoverAnimation: false,
|
|
|
+ itemStyle: {
|
|
|
+ opacity: 0.8,
|
|
|
+ color: "#35383f",
|
|
|
+ borderColor: "#000",
|
|
|
+ },
|
|
|
label: {
|
|
|
- formatter: "{d}%",
|
|
|
- padding: [-20, -25, 10, 5],
|
|
|
+ show: false,
|
|
|
},
|
|
|
- itemStyle: {
|
|
|
- normal: {
|
|
|
- // 阴影的大小
|
|
|
- shadowBlur: 20,
|
|
|
- // 阴影水平方向上的偏移
|
|
|
- shadowOffsetX: 0,
|
|
|
- // 阴影垂直方向上的偏移
|
|
|
- shadowOffsetY: 0,
|
|
|
- // 阴影颜色
|
|
|
- shadowColor: "rgba(0,70,199, 0.8)",
|
|
|
- },
|
|
|
- borderRadius: 2,
|
|
|
+ labelLine: {
|
|
|
+ show: false,
|
|
|
},
|
|
|
- data: [
|
|
|
- {
|
|
|
- value: this.lossPower.XNSS
|
|
|
- ? this.lossPower?.XNSS?.toFixed(2)
|
|
|
- : 0,
|
|
|
- name: "性能损失",
|
|
|
- },
|
|
|
- {
|
|
|
- value: this.lossPower.WHSS
|
|
|
- ? this.lossPower?.WHSS?.toFixed(2)
|
|
|
- : 0,
|
|
|
- name: "维护损失",
|
|
|
- },
|
|
|
- {
|
|
|
- value: this.lossPower.GZSS
|
|
|
- ? this.lossPower?.GZSS?.toFixed(2)
|
|
|
- : 0,
|
|
|
- name: "故障损失",
|
|
|
- },
|
|
|
- {
|
|
|
- value: this.lossPower.XDSS
|
|
|
- ? this.lossPower?.XDSS?.toFixed(2)
|
|
|
- : 0,
|
|
|
- name: "限电损失",
|
|
|
- },
|
|
|
- {
|
|
|
- value: this.lossPower.SLSS
|
|
|
- ? this.lossPower?.SLSS?.toFixed(2)
|
|
|
- : 0,
|
|
|
- name: "受累损失",
|
|
|
- },
|
|
|
- ],
|
|
|
+ data: this.seriesData,
|
|
|
},
|
|
|
],
|
|
|
};
|
|
|
|
|
|
chart.clear();
|
|
|
- chart.setOption(option);
|
|
|
|
|
|
+ chart.setOption(option);
|
|
|
+ chart.on("mouseover", (event) => {
|
|
|
+ let name = event.name;
|
|
|
+ let value = event.percent;
|
|
|
+ option.title.text = "{val|" + value + "%}\n{name|" + name + "}";
|
|
|
+ option.animation = false;
|
|
|
+ option.title.textStyle = {
|
|
|
+ rich: {
|
|
|
+ name: {
|
|
|
+ fontSize: 15,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[event.dataIndex],
|
|
|
+ },
|
|
|
+ val: {
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[event.dataIndex],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ chart.setOption(option);
|
|
|
+ });
|
|
|
+ chart.on("mouseout", (event) => {
|
|
|
+ option.animation = false;
|
|
|
+ option.title = {
|
|
|
+ text: `{val|${
|
|
|
+ max && total ? Number((max / total) * 100).toFixed(2) : 0
|
|
|
+ }%}\n{name|${title || ""}}`,
|
|
|
+ top: "43%",
|
|
|
+ left: "34%",
|
|
|
+ textAlign: "center",
|
|
|
+ textStyle: {
|
|
|
+ rich: {
|
|
|
+ name: {
|
|
|
+ fontSize: 15,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[index],
|
|
|
+ // padding: [10, 10],
|
|
|
+ },
|
|
|
+ val: {
|
|
|
+ fontSize: 14,
|
|
|
+ fontWeight: "bold",
|
|
|
+ color: this.color[index],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ chart.setOption(option);
|
|
|
+ });
|
|
|
this.resize = function () {
|
|
|
chart.resize();
|
|
|
};
|
|
@@ -184,15 +351,13 @@ export default {
|
|
|
},
|
|
|
},
|
|
|
created() {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.id = "pie-chart-" + util.newGUID();
|
|
|
- });
|
|
|
- this.newlist = this.list;
|
|
|
+ this.$nextTick(() => {});
|
|
|
},
|
|
|
mounted() {
|
|
|
this.$nextTick(() => {
|
|
|
- this.$el.style.width = this.width;
|
|
|
- this.$el.style.height = this.height;
|
|
|
+ let el = this.$el.parentElement;
|
|
|
+ el.style.width = this.width;
|
|
|
+ el.style.height = this.height;
|
|
|
this.initChart();
|
|
|
});
|
|
|
},
|