Merge pull request #9485 from ulleo/dev-v2

feat(图表): 双轴图增加渐变色配置
This commit is contained in:
ulleo 2024-04-30 16:40:09 +08:00 committed by GitHub
commit fdf01f0471
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 24 additions and 5 deletions

View File

@ -19,6 +19,7 @@ export const CHART_MIX_EDITOR_PROPERTY_INNER: EditorPropertyInner = {
'basic-style-selector': [ 'basic-style-selector': [
'colors', 'colors',
'alpha', 'alpha',
'gradient',
'lineWidth', 'lineWidth',
'lineSymbol', 'lineSymbol',
'lineSymbolSize', 'lineSymbolSize',

View File

@ -3,7 +3,14 @@ import {
G2PlotDrawOptions G2PlotDrawOptions
} from '@/views/chart/components/js/panel/types/impl/g2plot' } from '@/views/chart/components/js/panel/types/impl/g2plot'
import { DualAxes, DualAxesOptions } from '@antv/g2plot/esm/plots/dual-axes' import { DualAxes, DualAxesOptions } from '@antv/g2plot/esm/plots/dual-axes'
import { getAnalyse, getLabel, getPadding, getYAxis, getYAxisExt } from '../../common/common_antv' import {
getAnalyse,
getLabel,
getPadding,
getYAxis,
getYAxisExt,
setGradientColor
} from '../../common/common_antv'
import { flow, hexColorToRGBA, parseJson } from '@/views/chart/components/js/util' import { flow, hexColorToRGBA, parseJson } from '@/views/chart/components/js/util'
import { cloneDeep, isEmpty, defaultTo, map, filter } from 'lodash-es' import { cloneDeep, isEmpty, defaultTo, map, filter } from 'lodash-es'
import { valueFormatter } from '@/views/chart/components/js/formatter' import { valueFormatter } from '@/views/chart/components/js/formatter'
@ -63,20 +70,31 @@ export class ColumnLineMix extends G2PlotChartView<DualAxesOptions, DualAxes> {
}) })
// custom color // custom color
const customAttr = parseJson(chart.customAttr) const customAttr = parseJson(chart.customAttr)
const color = customAttr.basicStyle.colors let color = customAttr.basicStyle.colors
color = color.map(ele => {
const tmp = hexColorToRGBA(ele, customAttr.basicStyle.alpha)
if (customAttr.basicStyle.gradient) {
return setGradientColor(tmp, true, 270)
} else {
return tmp
}
})
// options // options
const initOptions: DualAxesOptions = { const initOptions: DualAxesOptions = {
data: [data1, data2], data: [data1, data2],
xField: 'field', xField: 'field',
yField: ['value', 'valueExt'], //这里不能设置成一样的 yField: ['value', 'valueExt'], //这里不能设置成一样的
appendPadding: getPadding(chart), appendPadding: getPadding(chart),
color,
geometryOptions: [ geometryOptions: [
{ {
geometry: data1Type geometry: data1Type,
color: color[0]
}, },
{ {
geometry: data2Type geometry: data2Type,
color: color[1]
} }
], ],
interactions: [ interactions: [