Skip to content

Commit

Permalink
fix: line,area,radar label style with callback (#3805)
Browse files Browse the repository at this point in the history
* fix: line,area,radar label style with callback

* chore: new version

* chore: remove console.log

* chore: update node version of ci

* chore; update ci workflow
  • Loading branch information
hustcc authored Jul 30, 2024
1 parent bdc1342 commit 97223f0
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
- name: Setup Node.js environment
uses: actions/setup-node@v2.1.5
with:
node-version: '14'
node-version: '18'

- name: Run CI
run: |
npm install
npm install --legacy-peer-deps
npm run lint
npm run build
npm run coverage
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
41 changes: 41 additions & 0 deletions __tests__/bugs/issue-3804-spec.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g2plot",
"version": "2.4.31",
"version": "2.4.32",
"description": "An interactive and responsive charting library",
"keywords": [
"chart",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const version = '2.4.31';
export const version = '2.4.32';

// G2 自定义能力透出
import * as G2 from '@antv/g2';
Expand Down
4 changes: 2 additions & 2 deletions src/plots/area/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ function label(params: Params<AreaOptions>): Params<AreaOptions> {
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: [
Expand Down
4 changes: 2 additions & 2 deletions src/plots/line/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ function label(params: Params<LineOptions>): Params<LineOptions> {
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: [
Expand Down
4 changes: 2 additions & 2 deletions src/plots/radar/adaptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ function label(params: Params<RadarOptions>): Params<RadarOptions> {
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),
});
Expand Down

0 comments on commit 97223f0

Please sign in to comment.