-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(label): correct label selector parameter handling and test case
- Loading branch information
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { issue6396 } from './issue-6396'; | ||
export { issue6399 } from './issue-6399'; | ||
export { issueChart2719 } from './issue-chart-2719'; | ||
export { issue6020 } from './issue-6020'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Chart } from '../../../src'; | ||
|
||
export function issue6020(context) { | ||
const { container, canvas } = context; | ||
|
||
const chart = new Chart({ | ||
container: container, | ||
autoFit: true, | ||
insetRight: 10, | ||
canvas, | ||
}); | ||
|
||
let i = 0; | ||
|
||
chart | ||
.line() | ||
.data({ | ||
type: 'fetch', | ||
value: 'https://assets.antv.antgroup.com/g2/indices.json', | ||
}) | ||
.transform({ type: 'normalizeY', basis: 'first', groupBy: 'color' }) | ||
.encode('x', (d) => new Date(d.Date)) | ||
.encode('y', 'Close') | ||
.encode('color', 'Symbol') | ||
.scale('y', { type: 'log' }) | ||
.axis('y', { title: '↑ Change in price (%)' }) | ||
.label({ | ||
text: 'Symbol', | ||
selector: (data) => { | ||
if (data.length) { | ||
// 对于每个系列的数据,只保留索引等于 2 的标签 | ||
return data.filter((d, index) => index === 2); | ||
} | ||
return data; | ||
}, | ||
fontSize: 10, | ||
}) | ||
.tooltip({ channel: 'y', valueFormatter: '.1f' }); | ||
|
||
chart.render().then(() => { | ||
console.log(i); | ||
i = 0; | ||
}); | ||
|
||
return { chart }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters