diff --git a/__tests__/plots/static/index.ts b/__tests__/plots/static/index.ts index 2c2a520d59..e60774b7f4 100644 --- a/__tests__/plots/static/index.ts +++ b/__tests__/plots/static/index.ts @@ -293,6 +293,7 @@ export { liquidPin } from './liquid-pin'; export { liquidRect } from './liquid-rect'; export { liquidCircle } from './liquid-circle'; export { liquidDiamond } from './liquid-diamond'; +export { liquidContent } from './liquid-content'; export { liquidTriangle } from './liquid-triangle'; export { liquidCustomShape } from './liquid-custom-shape'; export { alphabetIntervalAxisOptions } from './alphabet-interval-axis-options'; diff --git a/__tests__/plots/static/liquid-content.ts b/__tests__/plots/static/liquid-content.ts new file mode 100644 index 0000000000..9ae74f7b79 --- /dev/null +++ b/__tests__/plots/static/liquid-content.ts @@ -0,0 +1,18 @@ +import { G2Spec } from '../../../src'; + +export function liquidContent(): G2Spec { + return { + type: 'liquid', + data: 0.581, + style: { + contentFill: '#000', + contentText: 'center text', + contentStroke: '#fff', + contentLineWidth: 2, + outlineBorder: 4, + outlineDistance: 8, + waveLength: 128, + }, + }; +} +liquidContent.skip = true; diff --git a/__tests__/plots/static/liquid-pin.ts b/__tests__/plots/static/liquid-pin.ts index fd44cb4d9e..1c83fa5ef4 100644 --- a/__tests__/plots/static/liquid-pin.ts +++ b/__tests__/plots/static/liquid-pin.ts @@ -6,7 +6,7 @@ export function liquidPin(): G2Spec { data: 0.7, style: { shape: 'pin', - textFill: '#fff', + contentFill: '#fff', outlineBorder: 4, outlineDistance: 8, waveLength: 128, diff --git a/site/examples/general/Liquid/demo/liquid-content.ts b/site/examples/general/Liquid/demo/liquid-content.ts new file mode 100644 index 0000000000..e7f9051395 --- /dev/null +++ b/site/examples/general/Liquid/demo/liquid-content.ts @@ -0,0 +1,18 @@ +import { Chart } from '@antv/g2'; + +const chart = new Chart({ + container: 'container', + autoFit: true, +}); + +chart.liquid().data(0.581).style({ + contentFill: '#000', + contentText: 'center text', + contentStroke: '#fff', + contentLineWidth: 2, + outlineBorder: 4, + outlineDistance: 8, + waveLength: 128, +}); + +chart.render(); diff --git a/site/examples/general/Liquid/demo/liquid-pin.ts b/site/examples/general/Liquid/demo/liquid-pin.ts index 3907ff5674..b9b3e4b9cb 100644 --- a/site/examples/general/Liquid/demo/liquid-pin.ts +++ b/site/examples/general/Liquid/demo/liquid-pin.ts @@ -7,7 +7,7 @@ const chart = new Chart({ chart.liquid().data(0.581).style({ shape: 'pin', // Build-in shapes: rect, circle, pin, diamond, triangle. - textFill: '#fff', + contentFill: '#fff', outlineBorder: 4, outlineDistance: 8, waveLength: 128, diff --git a/site/examples/general/Liquid/demo/meta.json b/site/examples/general/Liquid/demo/meta.json index 4032ef3f85..f73b3fe2fd 100644 --- a/site/examples/general/Liquid/demo/meta.json +++ b/site/examples/general/Liquid/demo/meta.json @@ -12,6 +12,14 @@ }, "screenshot": "https://mdn.alipayobjects.com/huamei_za7we3/afts/img/A*cHArRaizyBsAAAAAAAAAAAAADo2bAQ/original" }, + { + "filename": "liquid-content.ts", + "title": { + "zh": "水波图 文本内容", + "en": "Content Text Liquid Chart" + }, + "screenshot": "https://mdn.alipayobjects.com/huamei_qa8qxu/afts/img/A*5ZT3R4yo_3kAAAAAAAAAAAAADmJ7AQ/original" + }, { "filename": "liquid-pin.ts", "title": { diff --git a/src/mark/liquid.ts b/src/mark/liquid.ts index 38ccc2eac2..6ae2cbc7b8 100644 --- a/src/mark/liquid.ts +++ b/src/mark/liquid.ts @@ -64,7 +64,11 @@ export const Liquid: CC = (options) => { const newData = [{ percent, type: 'liquid' }]; - const textStyle = subObject(style, 'text'); + const contentStyle = { + ...subObject(style, 'text'), + ...subObject(style, 'content'), + }; + const outline = subObject(style, 'outline'); const wave = subObject(style, 'wave'); const background = subObject(style, 'background'); @@ -91,7 +95,7 @@ export const Liquid: CC = (options) => { deepMix({}, DEFAULT_TEXT_OPTIONS, { style: { text: `${prettyNumber(percent * 100)} %`, - ...textStyle, + ...contentStyle, }, animate, }),