From 02bf66f36a39539a326d15689bd22f5f0a9b6025 Mon Sep 17 00:00:00 2001 From: hustcc Date: Tue, 30 Jul 2024 14:17:03 +0800 Subject: [PATCH 1/5] fix: line,area,radar label style with callback --- __tests__/bugs/issue-3804-spec.ts | 41 +++++++++++++++++++++++++++++++ src/adaptor/geometries/line.ts | 2 ++ src/plots/area/adaptor.ts | 4 +-- src/plots/line/adaptor.ts | 4 +-- src/plots/radar/adaptor.ts | 4 +-- 5 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 __tests__/bugs/issue-3804-spec.ts diff --git a/__tests__/bugs/issue-3804-spec.ts b/__tests__/bugs/issue-3804-spec.ts new file mode 100644 index 0000000000..bb4dee400c --- /dev/null +++ b/__tests__/bugs/issue-3804-spec.ts @@ -0,0 +1,41 @@ +import { get } from '@antv/util'; +import { Line } from '../../src'; +import { createDiv } from '../utils/dom'; + +describe('#3804', () => { + it('line label style with callback', () => { + const line = new Line(createDiv(), { + width: 400, + height: 300, + autoFit: false, + data: [ + { year: '1991', value: 3 }, + { year: '1992', value: 4 }, + { year: '1993', value: 3.5 }, + { year: '1994', value: 5 }, + { year: '1995', value: 4.9 }, + { year: '1996', value: 6 }, + { year: '1997', value: 7 }, + { year: '1998', value: 9 }, + { year: '1999', value: 13 }, + ], + xField: 'year', + yField: 'value', + label: { + fields: ['year', 'value'], + callback: (year, value) => { + return { + style: { + text: value, + fill: value > 10 ? '#f24' : '#000', + }, + }; + }, + }, + }); + line.render(); + const geometry = line.chart.geometries[0]; + expect(get(geometry, ['labelOption', 'fields'])).toEqual(['year', 'value']); + line.destroy(); + }); +}); diff --git a/src/adaptor/geometries/line.ts b/src/adaptor/geometries/line.ts index ef8a4a2465..57a6906d99 100644 --- a/src/adaptor/geometries/line.ts +++ b/src/adaptor/geometries/line.ts @@ -31,6 +31,8 @@ export function line(params: Params): Params): Params { if (!label) { areaGeometry.label(false); } else { - const { callback, ...cfg } = label; + const { fields, callback, ...cfg } = label; areaGeometry.label({ - fields: [yField], + fields: fields || [yField], callback, cfg: { layout: [ diff --git a/src/plots/line/adaptor.ts b/src/plots/line/adaptor.ts index 30292942b8..6af93c7da6 100644 --- a/src/plots/line/adaptor.ts +++ b/src/plots/line/adaptor.ts @@ -163,9 +163,9 @@ function label(params: Params): Params { if (!label) { lineGeometry.label(false); } else { - const { callback, ...cfg } = label; + const { fields, callback, ...cfg } = label; lineGeometry.label({ - fields: [yField], + fields: fields || [yField], callback, cfg: { layout: [ diff --git a/src/plots/radar/adaptor.ts b/src/plots/radar/adaptor.ts index 46cb58d61a..5f43d43894 100644 --- a/src/plots/radar/adaptor.ts +++ b/src/plots/radar/adaptor.ts @@ -113,9 +113,9 @@ function label(params: Params): Params { if (!label) { geometry.label(false); } else { - const { callback, ...cfg } = label; + const { fields, callback, ...cfg } = label; geometry.label({ - fields: [yField], + fields: fields || [yField], callback, cfg: transformLabel(cfg), }); From 91cd352dc070c1b5a6ce3764d00d3b5e16923324 Mon Sep 17 00:00:00 2001 From: hustcc Date: Tue, 30 Jul 2024 14:19:37 +0800 Subject: [PATCH 2/5] chore: new version --- CHANGELOG.md | 23 +++++++++++++++++++++++ package.json | 2 +- src/index.ts | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 225a6720c3..43a31bb675 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,26 @@ +#### 2.4.32 (2024-07-30) + +##### Chores + +* update github action ([#3608](https://github.com/antvis/G2plot/pull/3608)) ([90020297](https://github.com/antvis/G2plot/commit/90020297669dbe0d213ebae7abebf3f7d9509ec8)) +* fix customized stock demo typo ([#3564](https://github.com/antvis/G2plot/pull/3564)) ([99b9f638](https://github.com/antvis/G2plot/commit/99b9f63863684dc592f79388c99888c5d24184bd)) +* update version of @antv/component to 0.8.34 for dist build ([#3545](https://github.com/antvis/G2plot/pull/3545)) ([ec015ea5](https://github.com/antvis/G2plot/commit/ec015ea55490621de20cc2e8cdae872272f3789d)) + +##### Documentation Changes + +* update readme ([#3757](https://github.com/antvis/G2plot/pull/3757)) ([3725803e](https://github.com/antvis/G2plot/commit/3725803e982e7b4eb6595742462afbc23172ea76)) +* fix link ([#3514](https://github.com/antvis/G2plot/pull/3514)) ([0f570eb0](https://github.com/antvis/G2plot/commit/0f570eb085612910651cd9cd57b3c95cea97a1db)) +* Fix a few typos ([#3525](https://github.com/antvis/G2plot/pull/3525)) ([ce615a2a](https://github.com/antvis/G2plot/commit/ce615a2a17fae845fd6badf044491447a713cb90)) + +##### Bug Fixes + +* line,area,radar label style with callback ([02bf66f3](https://github.com/antvis/G2plot/commit/02bf66f36a39539a326d15689bd22f5f0a9b6025)) + +##### Other Changes + +* the default value of isPercent option should be false ([#3725](https://github.com/antvis/G2plot/pull/3725)) ([bdc1342e](https://github.com/antvis/G2plot/commit/bdc1342e3cc8a71d8cb1284acec9299b64648774)) +* **demo:** heatmap-base parameter error ([#3679](https://github.com/antvis/G2plot/pull/3679)) ([bd6af004](https://github.com/antvis/G2plot/commit/bd6af0044efe869b503c2d388adac8326d1e6f31)) + #### 2.4.31 (2023-05-10) ##### Chores diff --git a/package.json b/package.json index 78fc90f876..5179370980 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g2plot", - "version": "2.4.31", + "version": "2.4.32", "description": "An interactive and responsive charting library", "keywords": [ "chart", diff --git a/src/index.ts b/src/index.ts index 96b860f90f..797b88d9f9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -export const version = '2.4.31'; +export const version = '2.4.32'; // G2 自定义能力透出 import * as G2 from '@antv/g2'; From 49a9d86d7975812dd7022912ba320e80edba2a3f Mon Sep 17 00:00:00 2001 From: hustcc Date: Tue, 30 Jul 2024 14:22:45 +0800 Subject: [PATCH 3/5] chore: remove console.log --- src/adaptor/geometries/line.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/adaptor/geometries/line.ts b/src/adaptor/geometries/line.ts index 57a6906d99..ef8a4a2465 100644 --- a/src/adaptor/geometries/line.ts +++ b/src/adaptor/geometries/line.ts @@ -31,8 +31,6 @@ export function line(params: Params): Params Date: Tue, 30 Jul 2024 14:56:57 +0800 Subject: [PATCH 4/5] chore: update node version of ci --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4f859ab1e2..3c9e83a972 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -13,7 +13,7 @@ jobs: - name: Setup Node.js environment uses: actions/setup-node@v2.1.5 with: - node-version: '14' + node-version: '18' - name: Run CI run: | From d7ad1e90fc505b9820e5a99202cf3bcb9cadf5cd Mon Sep 17 00:00:00 2001 From: hustcc Date: Tue, 30 Jul 2024 14:58:58 +0800 Subject: [PATCH 5/5] chore; update ci workflow --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c9e83a972..76a4874d79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: - name: Run CI run: | - npm install + npm install --legacy-peer-deps npm run lint npm run build npm run coverage