From da4d9e70d2c37f59a365b0fb88ad70e8c1ba79b4 Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期一, 11 十二月 2023 10:25:01 +0800 Subject: [PATCH] 机器开机率优化 --- src/views/cockpitPage/components/MachineStartupRate.vue | 107 ++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 73 insertions(+), 34 deletions(-) diff --git a/src/views/cockpitPage/components/MachineStartupRate.vue b/src/views/cockpitPage/components/MachineStartupRate.vue index 9383322..ffbb382 100644 --- a/src/views/cockpitPage/components/MachineStartupRate.vue +++ b/src/views/cockpitPage/components/MachineStartupRate.vue @@ -5,17 +5,10 @@ <img src="/cockpitPage/machine-top.png" alt="" /> <div class="top-title"> <span>鏈哄櫒寮�鏈虹巼</span> - <span class="top-rate">{{ "60%" }}</span> + <span class="top-rate">{{ startupRate + "%" }}</span> </div> </div> - <div class="machine-chart-bg"> - <img - src="/cockpitPage/machine-chart-bg.png" - alt="" - style="width: 250px; height: 260px" - /> - </div> - <div class="chart" ref="chart"></div> + <div id="main" class="chart" ref="chart"></div> </div> </div> </template> @@ -23,32 +16,63 @@ <script> //寮曞叆echart import * as echarts from "echarts"; +let myChart; export default { components: {}, - props: {}, + props: { + startupRate: { + type: String, + default: "", + }, + }, data() { return {}; }, - mounted() { - let chartData = [ - { value: 20, name: "闂茬疆" }, - { value: 20, name: "缁翠慨" }, - { value: 60, name: "宸ヤ綔" }, - ]; - this.pieChart("chart", chartData); - }, + mounted() {}, watch: {}, methods: { //鍦ㄨ亴 pieChart(chartName, data) { let chartDom = this.$refs[chartName]; - let myChart = echarts.init(chartDom); + + if (myChart != null && myChart != "" && myChart != undefined) { + myChart.dispose(); //閿�姣� + } + myChart = echarts.init(chartDom); + let img = "/cockpitPage/machine-chart-bg.png"; + let height = myChart.getHeight() / 1; + let width = height + 5; let option; if (data) { option = { color: ["#065a6f", "#067687", "#00ffff"], tooltip: { trigger: "item", + textStyle: { + color: "#00FFFF", + }, + borderColor: "#00FFFF", + backgroundColor: "#238d8d6b", + valueFormatter: function (value) { + return value + "%"; + }, + }, + graphic: { + elements: [ + { + type: "image", + // z: 5, + style: { + image: img, + width: width, + height: height, + opacity: 0.55, + }, + left: "center", + top: "center", + position: [10, 10], + }, + ], }, series: [ { @@ -57,10 +81,30 @@ radius: ["58%", "70%"], avoidLabelOverlap: false, label: { - color: "#01f7fd", - fontSize: 14, - formatter: function (params) { - return params.name + params.value + "%"; + normal: { + position: "outer", + padding: [0, -62], + color: "#01f7fd", + fontSize: 12, + borderWidth: 5, + borderRadius: 4, + formatter: function (params) { + let label = + params.name.length > 4 + ? `${params.name.slice(0, 3)}...` + : params.name; + return `{a|${label}} {b|${params.value + "%"}}`; + }, + rich: { + a: { + color: "#00ffff", + fontSize: 14, + }, + b: { + color: "#fccd1d", + fontSize: 14, + }, + }, }, }, emphasis: { @@ -72,8 +116,13 @@ }, labelLine: { show: true, - length: 50, + length: 15, color: "blue", + length2: 80, + }, + labelLayout: { + verticalAlign: "bottom", + dy: -5, }, data: data, }, @@ -121,16 +170,6 @@ color: #fec718; } } - } - .machine-chart-bg { - width: 100%; - height: 100%; - text-align: center; - position: absolute; - left: 0; - right: 0; - margin: auto; - opacity: 0.55; } .chart { margin-top: 8px; -- Gitblit v1.8.0