diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts index 5b5c376214..43f49f815f 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/line/area.ts @@ -177,8 +177,12 @@ export class Area extends G2PlotChartView { let areaStyle if (customAttr.basicStyle.gradient) { const colorMap = new Map() + const yAxis = parseJson(chart.customStyle).yAxis + const axisValue = yAxis.axisValue + const start = + !axisValue?.auto && axisValue.min && axisValue.max ? axisValue.min / axisValue.max : 0 areaStyle = item => { - let ele + let ele: string const key = `${item.field}-${item.category}` if (colorMap.has(key)) { ele = colorMap.get(key) @@ -188,9 +192,12 @@ export class Area extends G2PlotChartView { } if (ele) { return { - fill: setGradientColor(hexColorToRGBA(ele, alpha), true, 270) + fill: setGradientColor(hexColorToRGBA(ele, alpha), true, 270, start) } } + return { + fill: 'rgba(255,255,255,0)' + } } } return { diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 510086322b..ebed648536 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -799,11 +799,20 @@ export function getLineDash(type) { * @param rawColor 原始 RGBA 颜色 * @param show * @param angle 渐变角度 + * @param start 起始值 */ -export function setGradientColor(rawColor: string, show = false, angle = 0) { +export function setGradientColor(rawColor: string, show = false, angle = 0, start = 0) { const item = rawColor.split(',') item.splice(3, 1, '0.3)') - return show ? `l(${angle}) 0:${item.join(',')} 1:${rawColor}` : rawColor + let color: string + if (start == 0) { + color = `l(${angle}) 0:${item.join(',')} 1:${rawColor}` + } else if (start > 0) { + color = `l(${angle}) 0:rgba(255,255,255,0) ${start}:${item.join(',')} 1:${rawColor}` + } else { + color = `l(${angle}) 0:rgba(255,255,255,0) 0.1:${item.join(',')} 1:${rawColor}` + } + return show ? color : rawColor } export function transAxisPosition(position: string): string {