diff --git a/frontend/src/views/chart/chart/util.js b/frontend/src/views/chart/chart/util.js index 64b297e8cf..912cb1005c 100644 --- a/frontend/src/views/chart/chart/util.js +++ b/frontend/src/views/chart/chart/util.js @@ -669,6 +669,85 @@ export const TYPE_CONFIGS = [ ] } }, + { + render: 'antv', + category: 'chart.chart_type_compare', + value: 'bar-group', + title: 'chart.chart_bar_group', + icon: 'bar-group', + properties: [ + 'color-selector', + 'size-selector-ant-v', + 'label-selector-ant-v', + 'tooltip-selector-ant-v', + 'x-axis-selector-ant-v', + 'y-axis-selector-ant-v', + 'title-selector-ant-v', + 'legend-selector-ant-v' + ], + propertyInner: { + 'color-selector': [ + 'value', + 'colorPanel', + 'customColor', + 'alpha' + ], + 'size-selector-ant-v': [ + 'barDefault', + 'barGap' + ], + 'label-selector-ant-v': [ + 'show', + 'fontSize', + 'color', + 'position-v' + ], + 'tooltip-selector-ant-v': [ + 'show', + 'textStyle' + ], + 'x-axis-selector-ant-v': [ + 'show', + 'position', + 'name', + 'nameTextStyle', + 'splitLine', + 'axisForm', + 'axisLabel' + ], + 'y-axis-selector-ant-v': [ + 'show', + 'position', + 'name', + 'nameTextStyle', + 'axisValue', + 'splitLine', + 'axisForm', + 'axisLabel' + ], + 'title-selector-ant-v': [ + 'show', + 'title', + 'fontSize', + 'color', + 'hPosition', + 'isItalic', + 'isBolder', + 'remarkShow', + 'fontFamily', + 'letterSpace', + 'fontShadow' + ], + 'legend-selector-ant-v': [ + 'show', + 'icon', + 'orient', + 'textStyle', + 'hPosition', + 'vPosition' + ] + } + }, { render: 'antv', category: 'chart.chart_type_compare', @@ -2628,7 +2707,7 @@ export function getColors(chart, colors, reset) { }) } } - } else if (chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar')) { + } else if ((chart.type.includes('bar') || chart.type.includes('line') || chart.type.includes('scatter') || chart.type.includes('radar') || chart.type.includes('area')) && !chart.type.includes('group')) { if (Object.prototype.toString.call(chart.yaxis) === '[object Array]') { series = JSON.parse(JSON.stringify(chart.yaxis)) } else { @@ -2644,6 +2723,22 @@ export function getColors(chart, colors, reset) { }) } } + } else if (chart.type === 'bar-group') { + // 拿到data中的category,并去重,然后构建seriesColor + const data = chart.data.datas + const s = [] + data.forEach((cur) => { + if (s.indexOf(cur.category) < 0) { + s.push(cur.category) + } + }) + for (let i = 0; i < s.length; i++) { + seriesColors.push({ + name: s[i], + color: colors[i % colors.length], + isCustom: false + }) + } } else { if (chart.data) { const data = chart.data.datas