From cd388c78650efe85fe4dd41cc439208d58ab6c29 Mon Sep 17 00:00:00 2001 From: haoxuan <haoxuan> Date: 星期二, 05 十二月 2023 16:19:55 +0800 Subject: [PATCH] 接口轮训时 设备负荷对比柱状图 动画问题修改 --- src/views/cockpitPage/components/MachineStartupRate.vue | 77 +++++++++++++++++++++++++------------- 1 files changed, 50 insertions(+), 27 deletions(-) diff --git a/src/views/cockpitPage/components/MachineStartupRate.vue b/src/views/cockpitPage/components/MachineStartupRate.vue index 9383322..e9eed89 100644 --- a/src/views/cockpitPage/components/MachineStartupRate.vue +++ b/src/views/cockpitPage/components/MachineStartupRate.vue @@ -5,15 +5,8 @@ <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> @@ -25,17 +18,22 @@ import * as echarts from "echarts"; 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); + // let chartData = [ + // { value: 20, name: "闂茬疆" }, + // { value: 20, name: "缁翠慨" }, + // { value: 60, name: "宸ヤ綔" }, + // ]; + // this.pieChart("chart", chartData); }, watch: {}, methods: { @@ -43,12 +41,31 @@ pieChart(chartName, data) { let chartDom = this.$refs[chartName]; let myChart = echarts.init(chartDom); + let img = "/cockpitPage/machine-chart-bg.png"; let option; if (data) { option = { color: ["#065a6f", "#067687", "#00ffff"], tooltip: { trigger: "item", + }, + graphic: { + elements: [ + { + type: "image", + z: 5, + right: 25, + style: { + image: img, + width: 240, + height: 245, + opacity: 0.55, + }, + left: "center", + top: "center", + position: [5, 5], + }, + ], }, series: [ { @@ -59,8 +76,19 @@ label: { color: "#01f7fd", fontSize: 14, + padding: [0, -60], formatter: function (params) { - return params.name + params.value + "%"; + return `{a|${params.name}} {b|${params.value + "%"}}`; + }, + rich: { + a: { + color: "#00ffff", + fontSize: 14, + }, + b: { + color: "#fccd1d", + fontSize: 14, + }, }, }, emphasis: { @@ -72,8 +100,13 @@ }, labelLine: { show: true, - length: 50, + length: 40, color: "blue", + length2: 70, + }, + labelLayout: { + verticalAlign: "bottom", + dy: -5, }, data: data, }, @@ -121,16 +154,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