From 470f8cddae2d9b998394600b41b666f18a5af396 Mon Sep 17 00:00:00 2001 From: junjie Date: Wed, 24 Mar 2021 13:32:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=A7=86=E5=9B=BE):=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E8=AE=BE=E7=BD=AE=EF=BC=8C=E6=A0=B7=E5=BC=8F?= =?UTF-8?q?=E7=AD=89=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/lang/zh.js | 4 +- frontend/src/views/chart/chart/chart.js | 4 + .../src/views/chart/chart/common/common.js | 5 ++ .../views/chart/components/ChartComponent.vue | 2 +- .../BackgroundColorSelector.vue | 90 +++++++++++++++++++ .../component-style/LegendSelector.vue | 8 +- .../component-style/TitleSelector.vue | 8 +- .../component-style/XAxisSelector.vue | 6 +- .../component-style/YAxisSelector.vue | 6 +- .../components/shape-attr/ColorSelector.vue | 6 +- .../components/shape-attr/LabelSelector.vue | 18 ++-- .../components/shape-attr/SizeSelector.vue | 6 +- .../components/shape-attr/TooltipSelector.vue | 8 +- frontend/src/views/chart/group/Group.vue | 12 ++- frontend/src/views/chart/view/ChartEdit.vue | 21 ++++- 15 files changed, 178 insertions(+), 26 deletions(-) create mode 100644 frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue diff --git a/frontend/src/lang/zh.js b/frontend/src/lang/zh.js index 235154e72a..c5b4bfb8ed 100644 --- a/frontend/src/lang/zh.js +++ b/frontend/src/lang/zh.js @@ -679,7 +679,9 @@ export default { desc: '降序', sort: '排序', filter: '过滤', - none: '无' + none: '无', + background: '背景', + alpha: '透明度' }, dataset: { datalist: '数据集', diff --git a/frontend/src/views/chart/chart/chart.js b/frontend/src/views/chart/chart/chart.js index 1d5df1b4ee..6c77b1264c 100644 --- a/frontend/src/views/chart/chart/chart.js +++ b/frontend/src/views/chart/chart/chart.js @@ -71,6 +71,10 @@ export const DEFAULT_YAXIS_STYLE = { formatter: '{value}' } } +export const DEFAULT_BACKGROUND_COLOR = { + color: '#ffffff', + alpha: 0 +} // chart config export const BASE_BAR = { title: { diff --git a/frontend/src/views/chart/chart/common/common.js b/frontend/src/views/chart/chart/common/common.js index 6d19b2eba2..b47e0b9fe5 100644 --- a/frontend/src/views/chart/chart/common/common.js +++ b/frontend/src/views/chart/chart/common/common.js @@ -1,3 +1,5 @@ +import { hexColorToRGBA } from '@/views/chart/chart/util' + export function componentStyle(chart_option, chart) { if (chart.customStyle) { const customStyle = JSON.parse(chart.customStyle) @@ -31,5 +33,8 @@ export function componentStyle(chart_option, chart) { chart_option.yAxis.name = customStyle.yAxis.name chart_option.yAxis.axisLabel = customStyle.yAxis.axisLabel } + if (customStyle.background) { + chart_option.backgroundColor = hexColorToRGBA(customStyle.background.color, customStyle.background.alpha) + } } } diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 8d7f150221..88230a6c14 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -53,7 +53,7 @@ export default { chart_option = stackBarOption(JSON.parse(JSON.stringify(BASE_BAR)), chart) } else if (chart.type === 'bar-horizontal') { chart_option = horizontalBarOption(JSON.parse(JSON.stringify(HORIZONTAL_BAR)), chart) - } else if (chart.type === 'bar-horizontal-stack') { + } else if (chart.type === 'bar-stack-horizontal') { chart_option = horizontalStackBarOption(JSON.parse(JSON.stringify(HORIZONTAL_BAR)), chart) } else if (chart.type === 'line') { chart_option = baseLineOption(JSON.parse(JSON.stringify(BASE_LINE)), chart) diff --git a/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue new file mode 100644 index 0000000000..7ec8fc943a --- /dev/null +++ b/frontend/src/views/chart/components/component-style/BackgroundColorSelector.vue @@ -0,0 +1,90 @@ + + + + + diff --git a/frontend/src/views/chart/components/component-style/LegendSelector.vue b/frontend/src/views/chart/components/component-style/LegendSelector.vue index b84cfd20bb..45c7233ec9 100644 --- a/frontend/src/views/chart/components/component-style/LegendSelector.vue +++ b/frontend/src/views/chart/components/component-style/LegendSelector.vue @@ -1,6 +1,6 @@