From b5744bad3987abf42375311ef5d627fe2380a352 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 13 Dec 2023 15:07:16 +0800 Subject: [PATCH 1/2] fix(mark): change liquid text name --- __tests__/plots/static/index.ts | 1 + __tests__/plots/static/liquid-content.ts | 18 ++++++++++++++++++ __tests__/plots/static/liquid-pin.ts | 2 +- .../general/Liquid/demo/liquid-content.ts | 18 ++++++++++++++++++ .../examples/general/Liquid/demo/liquid-pin.ts | 2 +- site/examples/general/Liquid/demo/meta.json | 8 ++++++++ src/mark/liquid.ts | 4 ++-- 7 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 __tests__/plots/static/liquid-content.ts create mode 100644 site/examples/general/Liquid/demo/liquid-content.ts diff --git a/__tests__/plots/static/index.ts b/__tests__/plots/static/index.ts index f2fac717e3..894d8dd625 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..ece8c7ace1 100644 --- a/src/mark/liquid.ts +++ b/src/mark/liquid.ts @@ -64,7 +64,7 @@ export const Liquid: CC = (options) => { const newData = [{ percent, type: 'liquid' }]; - const textStyle = subObject(style, 'text'); + const contentStyle = subObject(style, 'content'); const outline = subObject(style, 'outline'); const wave = subObject(style, 'wave'); const background = subObject(style, 'background'); @@ -91,7 +91,7 @@ export const Liquid: CC = (options) => { deepMix({}, DEFAULT_TEXT_OPTIONS, { style: { text: `${prettyNumber(percent * 100)} %`, - ...textStyle, + ...contentStyle, }, animate, }), From 1e1b98098bd638ee8aca5826309e36defa3b9490 Mon Sep 17 00:00:00 2001 From: wb-xcf804241 Date: Wed, 13 Dec 2023 15:56:04 +0800 Subject: [PATCH 2/2] fix(mark): change liquid text name --- src/mark/liquid.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mark/liquid.ts b/src/mark/liquid.ts index ece8c7ace1..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 contentStyle = subObject(style, 'content'); + const contentStyle = { + ...subObject(style, 'text'), + ...subObject(style, 'content'), + }; + const outline = subObject(style, 'outline'); const wave = subObject(style, 'wave'); const background = subObject(style, 'background');