From c36dbb8ba0424ecdd1eb132095056bdb2022d65e Mon Sep 17 00:00:00 2001 From: qianming Date: Fri, 20 Aug 2021 09:54:51 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A0=86=E5=8F=A0=E5=9B=BE=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/bar/widgetBarStackChart.vue | 84 ++++++++----------- 1 file changed, 33 insertions(+), 51 deletions(-) diff --git a/report-ui/src/views/report/bigscreen/designer/widget/bar/widgetBarStackChart.vue b/report-ui/src/views/report/bigscreen/designer/widget/bar/widgetBarStackChart.vue index 3f65536b..2be42d57 100644 --- a/report-ui/src/views/report/bigscreen/designer/widget/bar/widgetBarStackChart.vue +++ b/report-ui/src/views/report/bigscreen/designer/widget/bar/widgetBarStackChart.vue @@ -96,11 +96,9 @@ export default { this.setOptionsTitle(); this.setOptionsX(); this.setOptionsY(); - this.setOptionsTop(); this.setOptionsTooltip(); this.setOptionsMargin(); this.setOptionsLegend(); - this.setOptionsColor(); this.setOptionsData(); }, // 标题修改 @@ -195,25 +193,6 @@ export default { }; this.options.yAxis = yAxis; }, - // 数值设定 or 柱体设置 - setOptionsTop() { - const optionsCollapse = this.optionsSetup; - const series = this.options.series; - for (const key in series) { - if (series[key].type == "bar") { - series[key].label = { - show: optionsCollapse.isShow, - position: "top", - distance: 10, - fontSize: optionsCollapse.fontSize, - color: optionsCollapse.subTextColor, - fontWeight: optionsCollapse.fontWeight - }; - series[key].barWidth = optionsCollapse.maxWidth; - } - } - this.options.series = series; - }, // tooltip 提示语设置,鼠标放置显示 setOptionsTooltip() { const optionsCollapse = this.optionsSetup; @@ -255,30 +234,6 @@ export default { }; legend.itemWidth = optionsCollapse.lengedWidth; }, - // 自定义颜色 - setOptionsColor() { - const optionsCollapse = this.optionsSetup; - const customColor = optionsCollapse.customColor; - if (!customColor) return; - const arrColor = []; - for (let i = 0; i < customColor.length; i++) { - arrColor.push(customColor[i].color); - } - const itemStyle = { - normal: { - color: params => { - return arrColor[params.dataIndex]; - }, - barBorderRadius : optionsCollapse.radius - }, - }; - for (const key in this.options.series) { - if (this.options.series[key].type == "bar") { - this.options.series[key].itemStyle = itemStyle; - } - } - this.options = Object.assign({}, this.options); - }, // 数据解析 setOptionsData() { const optionsSetup = this.optionsSetup; @@ -394,6 +349,12 @@ export default { }); }, renderingFn(optionsSetup, val) { + //颜色 + const customColor = optionsSetup.customColor; + const arrColor = []; + for (let i = 0; i < customColor.length; i++) { + arrColor.push(customColor[i].color); + } // x轴 if (optionsSetup.verticalShow) { this.options.xAxis.data = []; @@ -406,14 +367,35 @@ export default { this.options.xAxis.type = "category"; this.options.yAxis.type = "value"; } - - const series = this.options.series; - for (const i in series) { - if (series[i].type == "bar") { - series[i].name = val.series[i].name; - series[i].data = val.series[i].data; + const series = []; + for (const i in val.series) { + if (val.series[i].type == "bar") { + series.push({ + name: val.series[i].name, + type: "bar", + data: val.series[i].data, + barGap: "0%", + stack: this.getStackStyle(), + barWidth: optionsSetup.maxWidth, + label: { + show: optionsSetup.isShow, + position: "top", + distance: 10, + fontSize: optionsSetup.fontSize, + color: optionsSetup.subTextColor, + fontWeight: optionsSetup.fontWeight + }, + //颜色,圆角属性 + itemStyle: { + normal : { + color: arrColor[i], + barBorderRadius : optionsSetup.radius, + } + } + }) } } + this.options.series = series } } };