|
@@ -1,390 +1,427 @@
|
|
|
<template>
|
|
|
- <div class="chart" :id="id"></div>
|
|
|
+ <div class="chart" :id="id"></div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import util from "@/helper/util.js";
|
|
|
- import partten from "@/helper/partten.js";
|
|
|
- import * as echarts from "echarts";
|
|
|
+import util from "@/helper/util.js";
|
|
|
+import partten from "@/helper/partten.js";
|
|
|
+import * as echarts from "echarts";
|
|
|
|
|
|
- export default {
|
|
|
- name: "multiple-bar-charts",
|
|
|
- componentName: "multiple-bar-chart",
|
|
|
- props: {
|
|
|
- width: {
|
|
|
- type: String,
|
|
|
- default: "100%",
|
|
|
+export default {
|
|
|
+ name: "multiple-bar-charts",
|
|
|
+ componentName: "multiple-bar-chart",
|
|
|
+ props: {
|
|
|
+ width: {
|
|
|
+ type: String,
|
|
|
+ default: "100%",
|
|
|
+ },
|
|
|
+ height: {
|
|
|
+ type: String,
|
|
|
+ default: "13.889vh",
|
|
|
+ },
|
|
|
+ // 传入数据
|
|
|
+ list: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [
|
|
|
+ {
|
|
|
+ title: "日发电量",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ value: [
|
|
|
+ {
|
|
|
+ text: "1日",
|
|
|
+ value: 1,
|
|
|
},
|
|
|
- height: {
|
|
|
- type: String,
|
|
|
- default: "13.889vh",
|
|
|
- },
|
|
|
- // 传入数据
|
|
|
- list: {
|
|
|
- type: Array,
|
|
|
- default: () => [{
|
|
|
- title: "日发电量",
|
|
|
- yAxisIndex: 0,
|
|
|
- value: [{
|
|
|
- text: "1日",
|
|
|
- value: 1,
|
|
|
- }, ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "上网电量",
|
|
|
- yAxisIndex: 0,
|
|
|
- value: [{
|
|
|
- text: "1日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "2日",
|
|
|
- value: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "3日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "4日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "5日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "6日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "7日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "购网电量",
|
|
|
- yAxisIndex: 0,
|
|
|
- value: [{
|
|
|
- text: "1日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "2日",
|
|
|
- value: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "3日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "4日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "5日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "6日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "7日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- {
|
|
|
- title: "风速",
|
|
|
- yAxisIndex: 1,
|
|
|
- value: [{
|
|
|
- text: "1日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "2日",
|
|
|
- value: 2,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "3日",
|
|
|
- value: 1,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "4日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "5日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "6日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- {
|
|
|
- text: "7日",
|
|
|
- value: 3,
|
|
|
- },
|
|
|
- ],
|
|
|
- },
|
|
|
- ],
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: "上网电量",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ value: [
|
|
|
+ {
|
|
|
+ text: "1日",
|
|
|
+ value: 1,
|
|
|
},
|
|
|
- // 单位
|
|
|
- units: {
|
|
|
- type: Array,
|
|
|
- default: () => ["(万KWh)", "(风速)"],
|
|
|
+ {
|
|
|
+ text: "2日",
|
|
|
+ value: 2,
|
|
|
},
|
|
|
- // 显示 legend
|
|
|
- showLegend: {
|
|
|
- type: Boolean,
|
|
|
- default: true,
|
|
|
+ {
|
|
|
+ text: "3日",
|
|
|
+ value: 1,
|
|
|
},
|
|
|
- // 颜色#
|
|
|
- color: {
|
|
|
- type: Array,
|
|
|
- default: () => [
|
|
|
- "#2999a0", "#67b9ff", "#ff6271",
|
|
|
- "#05bb4c",
|
|
|
- "#4b55ae",
|
|
|
- "#fa8c16",
|
|
|
- "#f8de5b",
|
|
|
- "#1a93cf",
|
|
|
- "#c531c7",
|
|
|
- "#bd3338",
|
|
|
- ],
|
|
|
+ {
|
|
|
+ text: "4日",
|
|
|
+ value: 3,
|
|
|
},
|
|
|
- showAnimation: {
|
|
|
- type: Boolean,
|
|
|
- default: true,
|
|
|
+ {
|
|
|
+ text: "5日",
|
|
|
+ value: 3,
|
|
|
},
|
|
|
- // 柱子最大宽度
|
|
|
- barMaxWidth: {
|
|
|
- type: Number || String,
|
|
|
- default: 0,
|
|
|
+ {
|
|
|
+ text: "6日",
|
|
|
+ value: 3,
|
|
|
},
|
|
|
- // 柱子间距
|
|
|
- barGap: {
|
|
|
- type: Number || String,
|
|
|
- default: 0,
|
|
|
+ {
|
|
|
+ text: "7日",
|
|
|
+ value: 3,
|
|
|
},
|
|
|
+ ],
|
|
|
},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- id: "",
|
|
|
- chart: null,
|
|
|
- firstAnimation: true,
|
|
|
- };
|
|
|
+ {
|
|
|
+ title: "购网电量",
|
|
|
+ yAxisIndex: 0,
|
|
|
+ value: [
|
|
|
+ {
|
|
|
+ text: "1日",
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "2日",
|
|
|
+ value: 2,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "3日",
|
|
|
+ value: 1,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "4日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "5日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "6日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "7日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- computed: {
|
|
|
- legend() {
|
|
|
- return this.list.map((t) => {
|
|
|
- return t.title;
|
|
|
- });
|
|
|
+ {
|
|
|
+ title: "风速",
|
|
|
+ yAxisIndex: 1,
|
|
|
+ value: [
|
|
|
+ {
|
|
|
+ text: "1日",
|
|
|
+ value: 1,
|
|
|
},
|
|
|
- xdata() {
|
|
|
- let result = [];
|
|
|
- if (this.list && this.list.length > 0 && this.list[0].value.length > 0) {
|
|
|
- result = this.list[0].value.map((t) => {
|
|
|
- return t.text;
|
|
|
- });
|
|
|
- }
|
|
|
- return result;
|
|
|
+ {
|
|
|
+ text: "2日",
|
|
|
+ value: 2,
|
|
|
},
|
|
|
- ydata() {
|
|
|
- let result = [];
|
|
|
- this.units.forEach((value, index) => {
|
|
|
- let data = null;
|
|
|
- if (index == 0) {
|
|
|
- data = {
|
|
|
- type: "value",
|
|
|
- name: value,
|
|
|
- nameTextStyle: {
|
|
|
- color: "#a6c1dd"
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- formatter: "{value} ",
|
|
|
- fontSize: 12,
|
|
|
- textStyle: {
|
|
|
- color: this.$store.state.themeName === "dark" ?
|
|
|
- "#a6c1dd" : "#000",
|
|
|
- },
|
|
|
- },
|
|
|
- //分格线
|
|
|
- splitLine: {
|
|
|
- lineStyle: {
|
|
|
- color: this.$store.state.themeName === "dark" ? "#404d69" : "#000",
|
|
|
- type: "dashed",
|
|
|
- },
|
|
|
- },
|
|
|
- };
|
|
|
- } else {
|
|
|
- data = {
|
|
|
- type: "value",
|
|
|
- name: value,
|
|
|
- nameTextStyle: {
|
|
|
- color: "#a6c1dd"
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- formatter: "{value}",
|
|
|
- fontSize: 12,
|
|
|
- textStyle: {
|
|
|
- color: this.$store.state.themeName === "dark" ?
|
|
|
- "#a6c1dd" : "#000",
|
|
|
- },
|
|
|
- },
|
|
|
- //分格线
|
|
|
- splitLine: {
|
|
|
- show: false,
|
|
|
- },
|
|
|
- };
|
|
|
- }
|
|
|
-
|
|
|
- result.push(data);
|
|
|
- });
|
|
|
-
|
|
|
- return result;
|
|
|
+ {
|
|
|
+ text: "3日",
|
|
|
+ value: 1,
|
|
|
},
|
|
|
- series() {
|
|
|
- let result = [];
|
|
|
- if (this.list && this.list.length > 0) {
|
|
|
- this.list.forEach((value, index) => {
|
|
|
- let seriesItem = {
|
|
|
- name: value.title,
|
|
|
- type: "bar",
|
|
|
- barWidth: "8%",
|
|
|
- animation: this.firstAnimation && this.showAnimation,
|
|
|
- yAxisIndex: value.yAxisIndex,
|
|
|
- data: value.value.map((t) => {
|
|
|
- return t.value;
|
|
|
- }),
|
|
|
- };
|
|
|
- if (this.barMaxWidth) {
|
|
|
- seriesItem.barMaxWidth = this.barMaxWidth;
|
|
|
- } else {
|
|
|
- seriesItem.barWidth = "8%";
|
|
|
- }
|
|
|
-
|
|
|
- if (this.barGap) {
|
|
|
- seriesItem.barGap = this.barGap;
|
|
|
- }
|
|
|
- result.push(seriesItem);
|
|
|
- });
|
|
|
- }
|
|
|
- return result;
|
|
|
+ {
|
|
|
+ text: "4日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "5日",
|
|
|
+ value: 3,
|
|
|
},
|
|
|
+ {
|
|
|
+ text: "6日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: "7日",
|
|
|
+ value: 3,
|
|
|
+ },
|
|
|
+ ],
|
|
|
},
|
|
|
- methods: {
|
|
|
- resize() {
|
|
|
- this.initChart();
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ // 单位
|
|
|
+ units: {
|
|
|
+ type: Array,
|
|
|
+ default: () => ["(万KWh)", "(风速)"],
|
|
|
+ },
|
|
|
+ // 显示 legend
|
|
|
+ showLegend: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true,
|
|
|
+ },
|
|
|
+ // 颜色#
|
|
|
+ color: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [
|
|
|
+ "#2999a0",
|
|
|
+ "#67b9ff",
|
|
|
+ "#ff6271",
|
|
|
+ "#05bb4c",
|
|
|
+ "#4b55ae",
|
|
|
+ "#fa8c16",
|
|
|
+ "#f8de5b",
|
|
|
+ "#1a93cf",
|
|
|
+ "#c531c7",
|
|
|
+ "#bd3338",
|
|
|
+ ],
|
|
|
+ },
|
|
|
+ showAnimation: {
|
|
|
+ type: Boolean,
|
|
|
+ default: true,
|
|
|
+ },
|
|
|
+ // 柱子最大宽度
|
|
|
+ barMaxWidth: {
|
|
|
+ type: Number || String,
|
|
|
+ default: 0,
|
|
|
+ },
|
|
|
+ // 柱子间距
|
|
|
+ barGap: {
|
|
|
+ type: Number || String,
|
|
|
+ default: 0,
|
|
|
+ },
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ id: "",
|
|
|
+ chart: null,
|
|
|
+ firstAnimation: true,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ legend() {
|
|
|
+ return this.list.map((t) => {
|
|
|
+ return t.title;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ xdata() {
|
|
|
+ let result = [];
|
|
|
+ if (this.list && this.list.length > 0 && this.list[0].value.length > 0) {
|
|
|
+ result = this.list[0].value.map((t) => {
|
|
|
+ return t.text;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ ydata() {
|
|
|
+ let result = [];
|
|
|
+ this.units.forEach((value, index) => {
|
|
|
+ let data = null;
|
|
|
+ if (index == 0) {
|
|
|
+ data = {
|
|
|
+ type: "value",
|
|
|
+ name: value,
|
|
|
+ nameTextStyle: {
|
|
|
+ color: "#a6c1dd",
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: "{value} ",
|
|
|
+ fontSize: 12,
|
|
|
+ textStyle: {
|
|
|
+ color:
|
|
|
+ this.$store.state.themeName === "dark" ? "#a6c1dd" : "#000",
|
|
|
+ },
|
|
|
},
|
|
|
- initChart() {
|
|
|
- let chart = echarts.init(this.$el);
|
|
|
+ //分格线
|
|
|
+ splitLine: {
|
|
|
+ lineStyle: {
|
|
|
+ color:
|
|
|
+ this.$store.state.themeName === "dark" ? "#404d69" : "#000",
|
|
|
+ type: "dashed",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ };
|
|
|
+ } else {
|
|
|
+ data = {
|
|
|
+ type: "value",
|
|
|
+ name: value,
|
|
|
+ nameTextStyle: {
|
|
|
+ color: "#a6c1dd",
|
|
|
+ },
|
|
|
+ axisLabel: {
|
|
|
+ formatter: "{value}",
|
|
|
+ fontSize: 12,
|
|
|
+ textStyle: {
|
|
|
+ color:
|
|
|
+ this.$store.state.themeName === "dark" ? "#a6c1dd" : "#000",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ //分格线
|
|
|
+ splitLine: {
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
- let option = {
|
|
|
- color: this.color,
|
|
|
- tooltip: {
|
|
|
- trigger: "axis",
|
|
|
- backgroundColor: this.$store.state.themeName === "dark" ?
|
|
|
- "rgba(0,0,0,0.4)" : "rgba(255,255,255,0.5)",
|
|
|
- borderColor: this.$store.state.themeName === "dark" ?
|
|
|
- partten.getColor("gray") : "#000",
|
|
|
- textStyle: {
|
|
|
- color: this.$store.state.themeName === "dark" ? "#fff" : "#000",
|
|
|
- fontSize: 12,
|
|
|
- },
|
|
|
- },
|
|
|
- legend: {
|
|
|
- show: this.showLegend,
|
|
|
- data: this.legend,
|
|
|
- right: 56,
|
|
|
- icon: "ract",
|
|
|
- itemWidth: 8,
|
|
|
- itemHeight: 8,
|
|
|
- inactiveColor: this.$store.state.themeName === "dark" ?
|
|
|
- partten.getColor("gray") : "#000",
|
|
|
- textStyle: {
|
|
|
- fontSize: 12,
|
|
|
- color: this.$store.state.themeName === "dark" ?
|
|
|
- partten.getColor("grayl") : "#000",
|
|
|
- },
|
|
|
- },
|
|
|
- grid: {
|
|
|
- top: 32,
|
|
|
- left: 25,
|
|
|
- right: 30,
|
|
|
- bottom: 0,
|
|
|
- containLabel: true,
|
|
|
- },
|
|
|
- xAxis: [{
|
|
|
- type: "category",
|
|
|
- data: this.xdata,
|
|
|
- nameLocation: "center",
|
|
|
- axisPointer: {
|
|
|
- type: "shadow",
|
|
|
- },
|
|
|
- axisLabel: {
|
|
|
- interval: 0,
|
|
|
- fontSize: 12,
|
|
|
- textStyle: {
|
|
|
- color: this.$store.state.themeName === "dark" ?
|
|
|
- "#a6c1dd" : "#000",
|
|
|
- },
|
|
|
- },
|
|
|
- }, ],
|
|
|
- yAxis: this.ydata,
|
|
|
- series: this.series,
|
|
|
- };
|
|
|
+ result.push(data);
|
|
|
+ });
|
|
|
|
|
|
- chart.clear();
|
|
|
- chart.setOption(option);
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ series() {
|
|
|
+ let result = [];
|
|
|
+ if (this.list && this.list.length > 0) {
|
|
|
+ this.list.forEach((value, index) => {
|
|
|
+ let seriesItem = {
|
|
|
+ name: value.title,
|
|
|
+ type: "bar",
|
|
|
+ barWidth: "8%",
|
|
|
+ animation: this.firstAnimation && this.showAnimation,
|
|
|
+ yAxisIndex: value.yAxisIndex,
|
|
|
+ data: value.value.map((t) => {
|
|
|
+ return t.value;
|
|
|
+ }),
|
|
|
+ };
|
|
|
+ if (this.barMaxWidth) {
|
|
|
+ seriesItem.barMaxWidth = this.barMaxWidth;
|
|
|
+ } else {
|
|
|
+ seriesItem.barWidth = "8%";
|
|
|
+ }
|
|
|
|
|
|
- this.resize = function () {
|
|
|
- chart.resize();
|
|
|
- };
|
|
|
+ if (this.barGap) {
|
|
|
+ seriesItem.barGap = this.barGap;
|
|
|
+ }
|
|
|
+ result.push(seriesItem);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ resize() {
|
|
|
+ this.initChart();
|
|
|
+ },
|
|
|
+ initChart() {
|
|
|
+ let chart = echarts.init(this.$el);
|
|
|
|
|
|
- window.addEventListener("resize", this.resize);
|
|
|
- },
|
|
|
- },
|
|
|
- created() {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.id = "pie-chart-" + util.newGUID();
|
|
|
- });
|
|
|
- },
|
|
|
- mounted() {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$el.style.width = this.width;
|
|
|
- this.$el.style.height = this.height;
|
|
|
- this.initChart();
|
|
|
- this.firstAnimation = false;
|
|
|
- });
|
|
|
+ let option = {
|
|
|
+ color: this.color,
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ backgroundColor:
|
|
|
+ this.$store.state.themeName === "dark"
|
|
|
+ ? "rgba(0,0,0,0.4)"
|
|
|
+ : "rgba(255,255,255,0.5)",
|
|
|
+ borderColor:
|
|
|
+ this.$store.state.themeName === "dark"
|
|
|
+ ? partten.getColor("gray")
|
|
|
+ : "#000",
|
|
|
+ textStyle: {
|
|
|
+ color: this.$store.state.themeName === "dark" ? "#fff" : "#000",
|
|
|
+ fontSize: 12,
|
|
|
+ },
|
|
|
+ formatter: function (params) {
|
|
|
+ var htmlStr = `<div style='margin-bottom:5px'>${params[0].axisValue}</div>`;
|
|
|
+ for (var i = 0; i < params.length; i++) {
|
|
|
+ htmlStr += `<div style='margin-bottom:2px'>`;
|
|
|
+ var param = params[i];
|
|
|
+ var seriesName = param.seriesName; //图例名称
|
|
|
+ var value = param.value; //y轴值
|
|
|
+ var mark = param.marker; //点
|
|
|
+ var unit = `<span style='font-size:12px'>${"万kWh"}</span>`;
|
|
|
+
|
|
|
+ htmlStr += mark; //一个点
|
|
|
+ htmlStr += `${seriesName} : ${
|
|
|
+ value != null ? value + unit : "--"
|
|
|
+ }`; //圆点后面显示的文本
|
|
|
+ htmlStr += "</div>";
|
|
|
+ }
|
|
|
+ return htmlStr;
|
|
|
+ },
|
|
|
},
|
|
|
- updated() {
|
|
|
- this.$nextTick(() => {
|
|
|
- this.initChart();
|
|
|
- });
|
|
|
+ legend: {
|
|
|
+ show: this.showLegend,
|
|
|
+ data: this.legend,
|
|
|
+ right: 56,
|
|
|
+ icon: "ract",
|
|
|
+ itemWidth: 8,
|
|
|
+ itemHeight: 8,
|
|
|
+ inactiveColor:
|
|
|
+ this.$store.state.themeName === "dark"
|
|
|
+ ? partten.getColor("gray")
|
|
|
+ : "#000",
|
|
|
+ textStyle: {
|
|
|
+ fontSize: 12,
|
|
|
+ color:
|
|
|
+ this.$store.state.themeName === "dark"
|
|
|
+ ? partten.getColor("grayl")
|
|
|
+ : "#000",
|
|
|
+ },
|
|
|
},
|
|
|
- unmounted() {
|
|
|
- window.removeEventListener("resize", this.resize);
|
|
|
+ grid: {
|
|
|
+ top: 32,
|
|
|
+ left: 25,
|
|
|
+ right: 30,
|
|
|
+ bottom: 0,
|
|
|
+ containLabel: true,
|
|
|
},
|
|
|
-
|
|
|
- watch: {
|
|
|
- "$store.state.themeName"() {
|
|
|
- let myChart = echarts.init(document.getElementById(this.id));
|
|
|
- myChart.dispose();
|
|
|
- setTimeout(() => {
|
|
|
- this.initChart();
|
|
|
- }, 300);
|
|
|
+ xAxis: [
|
|
|
+ {
|
|
|
+ type: "category",
|
|
|
+ data: this.xdata,
|
|
|
+ nameLocation: "center",
|
|
|
+ axisPointer: {
|
|
|
+ type: "shadow",
|
|
|
},
|
|
|
- },
|
|
|
- };
|
|
|
+ axisLabel: {
|
|
|
+ interval: 0,
|
|
|
+ fontSize: 12,
|
|
|
+ textStyle: {
|
|
|
+ color:
|
|
|
+ this.$store.state.themeName === "dark" ? "#a6c1dd" : "#000",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ yAxis: this.ydata,
|
|
|
+ series: this.series,
|
|
|
+ };
|
|
|
+
|
|
|
+ chart.clear();
|
|
|
+ chart.setOption(option);
|
|
|
+
|
|
|
+ this.resize = function () {
|
|
|
+ chart.resize();
|
|
|
+ };
|
|
|
+
|
|
|
+ window.addEventListener("resize", this.resize);
|
|
|
+ },
|
|
|
+ },
|
|
|
+ created() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.id = "pie-chart-" + util.newGUID();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.$el.style.width = this.width;
|
|
|
+ this.$el.style.height = this.height;
|
|
|
+ this.initChart();
|
|
|
+ this.firstAnimation = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ updated() {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.initChart();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ unmounted() {
|
|
|
+ window.removeEventListener("resize", this.resize);
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ "$store.state.themeName"() {
|
|
|
+ let myChart = echarts.init(document.getElementById(this.id));
|
|
|
+ myChart.dispose();
|
|
|
+ setTimeout(() => {
|
|
|
+ this.initChart();
|
|
|
+ }, 300);
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
<style lang="less">
|
|
|
- .chart {
|
|
|
- width: 100%;
|
|
|
- height: 100%;
|
|
|
- display: inline-block;
|
|
|
- }
|
|
|
+.chart {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ display: inline-block;
|
|
|
+}
|
|
|
</style>
|