From f5976f38c33048020de1b116ffa004b0d889a14d Mon Sep 17 00:00:00 2001 From: yangfeng <wanwan926_4@163.com> Date: 星期二, 05 十二月 2023 17:38:45 +0800 Subject: [PATCH] 车间正品率、工单进度统计、其他样式处理 --- src/views/cockpitPage/components/PerSonnelProductivity.vue | 100 +++++++++++++++++++++++++++++--------------------- 1 files changed, 58 insertions(+), 42 deletions(-) diff --git a/src/views/cockpitPage/components/PerSonnelProductivity.vue b/src/views/cockpitPage/components/PerSonnelProductivity.vue index b0dbd06..904cdf8 100644 --- a/src/views/cockpitPage/components/PerSonnelProductivity.vue +++ b/src/views/cockpitPage/components/PerSonnelProductivity.vue @@ -16,35 +16,49 @@ import ChartTitle from "@/views/cockpitPage/components/ChartTitle.vue"; //寮曞叆echart import * as echarts from "echarts"; +let myChart; export default { components: { ChartTitle, }, - props: {}, + props: { + chartData: { + type: Object, + require: true, + default: () => { + return { + datax: [], + datay: [], + }; + }, + }, + }, data() { return { - chartData: { - datax: ["浜哄憳1", "浜哄憳2", "浜哄憳3", "浜哄憳4", "浜哄憳5", "浜哄憳6"], - datay: [120, 200, 150, 380, 470, 150, 230], - }, + startValue: 0, + endValue: 5, + chartTimer: null, }; }, - mounted() { - this.pieChart("chart", this.chartData); - let chartData2 = [ - { value: 10, name: "涓�绫�" }, - { value: 20, name: "浜岀被" }, - { value: 60, name: "涓夌被" }, - { value: 10, name: "鍥涚被" }, - ]; - this.getChartRight("chart2", chartData2); + watch: { + "chartData.datay"(val) { + this.startValue = 0; + this.endValue = 5; + this.pieChart("chart", this.chartData); + }, }, - watch: {}, + mounted() {}, methods: { //鍦ㄨ亴 pieChart(chartName, data) { + let that = this; + clearInterval(this.chartTimer); let chartDom = this.$refs[chartName]; - let myChart = echarts.init(chartDom); + // let myChart = echarts.init(chartDom); + if (myChart != null && myChart != "" && myChart != undefined) { + myChart.dispose(); //閿�姣� + } + myChart = echarts.init(chartDom); let option; let lineColor = "#35ddc74d"; if (data) { @@ -59,30 +73,16 @@ grid: { right: "80px", bottom: "60px", - left: "60px", + left: "70px", top: "30px", }, dataZoom: [ { type: "inside", - // show: true, //鏄剧ず婊氬姩鏉� - start: 0, - end: 100, yAxisIndex: 0, - minSpan: 20, - maxSpan: 100, - // handleSize: 8 - }, - { - // type: 'slider', //涓や釜涓�涓槸slider锛屼竴涓槸inside锛宻lider鏄鍔犳粴鍔ㄦ潯浠ュ強榧犳爣鎷栧姩婊氬姩鏉″姛鑳斤紝inside鍒欐槸榧犳爣婊氳疆婊氬姩婊氬姩鏉°�� - type: "inside", - // show: true, - // realtime : true, - yAxisIndex: 0, - minSpan: 20, - maxSpan: 100, - start: 0, - end: 100, + show: false, + startValue: this.startValue, // 浠庡ご寮�濮� + endValue: this.endValue, // 涓�娆℃�у睍绀哄嚑涓� }, ], legend: { @@ -108,6 +108,7 @@ // rotate:45, margin: 10, show: true, + fontSize:12, textStyle: { color: function (params, index) { let colorList = ["#dcb018", "#00FFFF"]; @@ -118,13 +119,19 @@ } }, }, + formatter: function (value) { + if (value.length > 5) { + return `${value.slice(0, 4)}...`; + } + return value; + }, }, data: data.datax ? data.datax : [], }, ], xAxis: [ { - type: "", + type: "value", name: "鍗曚綅锛氫欢", // min: data.yAxis[0].min?data.yAxis.min:0, minInterval: 1, //鍧愭爣杞存槸鏁存暟 @@ -151,7 +158,6 @@ axisTick: { show: false, }, - axisLabel: { textStyle: { color: "#00FFFF", @@ -187,8 +193,21 @@ }, ], }; + this.chartTimer = setInterval(function () { + if (option.dataZoom[0].endValue == data.datay.length) { + option.dataZoom[0].startValue = 0; + option.dataZoom[0].endValue = 5; + } else { + option.dataZoom[0].endValue = option.dataZoom[0].endValue + 1; + option.dataZoom[0].startValue = option.dataZoom[0].startValue + 1; + } + myChart.setOption(option); + }, 4000); option && myChart.setOption(option); + window.addEventListener("resize", function () { + myChart.resize(); + }); } else { option = {}; myChart.setOption(option, true); @@ -212,8 +231,8 @@ z: 3, style: { image: img, - width: 238, - height: 238, + width: 240, + height: 240, }, left: "center", top: "center", @@ -225,10 +244,7 @@ { name: "Access From", type: "pie", - // center: ['80%', '46%'], radius: ["52%", "62%"], - // minAngle: 20, - // startAngle: 60, avoidLabelOverlap: false, label: { @@ -265,7 +281,7 @@ labelLine: { show: true, length: 4, - length2: 70, + length2: 80, lineStyle: { color: "#dcb018", }, -- Gitblit v1.8.0