From 187cd51b2f1bfb8eaa72c967e52f58a5391edb21 Mon Sep 17 00:00:00 2001 From: jiangyy Date: Fri, 17 Dec 2021 16:04:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=98=E7=BA=BF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../visual/communityGovern/cpt/issue-info.vue | 5 +++- src/views/modules/visual/cpts/line-chart.vue | 24 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/views/modules/visual/communityGovern/cpt/issue-info.vue b/src/views/modules/visual/communityGovern/cpt/issue-info.vue index 0cc0f2fb..381a871c 100644 --- a/src/views/modules/visual/communityGovern/cpt/issue-info.vue +++ b/src/views/modules/visual/communityGovern/cpt/issue-info.vue @@ -80,7 +80,8 @@ - + @@ -215,6 +216,8 @@ export default { ); }); this.issueChartData = chartData; + this.$refs.lineChart.setList(this.issueChartData) + } else { this.$message.error(msg); } diff --git a/src/views/modules/visual/cpts/line-chart.vue b/src/views/modules/visual/cpts/line-chart.vue index 84d14f2b..8cb617e7 100644 --- a/src/views/modules/visual/cpts/line-chart.vue +++ b/src/views/modules/visual/cpts/line-chart.vue @@ -1,6 +1,8 @@ @@ -26,7 +28,7 @@ const addTextShape = () => { const group = canvas.addGroup(); const shapes = {}; - function addFn(list) { + function addFn (list) { const listLength = list.length; list.forEach(function (obj, index) { // 避免显示太多,乱七八糟 @@ -130,7 +132,7 @@ const iniChart = function (config, srcData) { items: [ { name: "支持", - marker(x, y, r, ctx) { + marker (x, y, r, ctx) { ctx.lineWidth = 10; ctx.strokeStyle = supColor; ctx.moveTo(x - r - 15, y); @@ -141,7 +143,7 @@ const iniChart = function (config, srcData) { }, { name: "反对", - marker(x, y, r, ctx) { + marker (x, y, r, ctx) { ctx.lineWidth = 10; ctx.strokeStyle = oppColor; ctx.moveTo(x - r - 15, y); @@ -198,24 +200,32 @@ export default { default: 260, }, }, - data() { + data () { return { iniLoading: false, }; }, watch: { - list(data) { + list (data) { chart.changeData(data); srcData = data; addTextShape(); }, }, - async created() { + async created () { await nextTick(200); iniChart(this.config, this.list); await nextTick(200); this.iniLoading = true; }, + + methods: { + setList (data) { + chart.changeData(data); + srcData = data; + addTextShape(); + }, + } };