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 @@ + + + + + + + + + + + + + + + + {{ $t('chart.background') }} + + + + + + + + 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 @@ - + - + @@ -121,6 +121,10 @@ export default { .shape-item{ padding: 6px; border: none; + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; } .form-item-slider>>>.el-form-item__label{ font-size: 12px; diff --git a/frontend/src/views/chart/components/component-style/TitleSelector.vue b/frontend/src/views/chart/components/component-style/TitleSelector.vue index 8af38c639e..b86412b4d3 100644 --- a/frontend/src/views/chart/components/component-style/TitleSelector.vue +++ b/frontend/src/views/chart/components/component-style/TitleSelector.vue @@ -1,6 +1,6 @@ - + - + @@ -100,6 +100,10 @@ export default { .shape-item{ padding: 6px; border: none; + width: 100%; + display: flex; + justify-content: space-between; + align-items: center; } .form-item-slider>>>.el-form-item__label{ font-size: 12px; diff --git a/frontend/src/views/chart/components/component-style/XAxisSelector.vue b/frontend/src/views/chart/components/component-style/XAxisSelector.vue index 2b8f156cde..84dfacbe0f 100644 --- a/frontend/src/views/chart/components/component-style/XAxisSelector.vue +++ b/frontend/src/views/chart/components/component-style/XAxisSelector.vue @@ -1,6 +1,6 @@ - + >>.el-form-item__label{ font-size: 12px; diff --git a/frontend/src/views/chart/components/component-style/YAxisSelector.vue b/frontend/src/views/chart/components/component-style/YAxisSelector.vue index 48177d9953..c4f254b301 100644 --- a/frontend/src/views/chart/components/component-style/YAxisSelector.vue +++ b/frontend/src/views/chart/components/component-style/YAxisSelector.vue @@ -1,6 +1,6 @@ - + >>.el-form-item__label{ font-size: 12px; diff --git a/frontend/src/views/chart/components/shape-attr/ColorSelector.vue b/frontend/src/views/chart/components/shape-attr/ColorSelector.vue index 30e566d61c..02fd2fa465 100644 --- a/frontend/src/views/chart/components/shape-attr/ColorSelector.vue +++ b/frontend/src/views/chart/components/shape-attr/ColorSelector.vue @@ -1,6 +1,6 @@ - + >>.el-form-item__label{ font-size: 12px; diff --git a/frontend/src/views/chart/components/shape-attr/LabelSelector.vue b/frontend/src/views/chart/components/shape-attr/LabelSelector.vue index c68e81274b..41612bbbd0 100644 --- a/frontend/src/views/chart/components/shape-attr/LabelSelector.vue +++ b/frontend/src/views/chart/components/shape-attr/LabelSelector.vue @@ -1,6 +1,6 @@ - + - + @@ -29,7 +29,7 @@ - + @@ -92,10 +92,14 @@ export default {