antvis/G2

The issue has been closed
geom.style 的 callback 只触发一次 #3379
myou posted onGitHub
- I have searched the issues of this repository and believe that this is not a duplicate.
Reproduction link
https://g2.antv.vision/en/examples/line/basic#curved
Steps to reproduce
把 example code 的
chart
.line()
.position('month*temperature')
.color('city')
.shape('smooth');
改成
chart
.line()
.position('month*temperature')
.style('city', (city) => {
console.log('city', city);
return {
stroke: city === 'London' ? 'red' : 'blue'
};
})
.shape('smooth');
会发现整个线都是蓝色,而且 city 只打印了一次。data 第一个元素 style 是用 .style callback 决定的,之后每一个元素都是用了第一个元素的 style
Environment | Info |
---|---|
g2 | 4.1.14 |
System | - |
Browser | - |
按照 https://g2.antv.vision/en/docs/api/general/style 这里文档,style 应该是每一个数据数组元素都重新判断一次
<!-- generated by antv-issue-helper. DO NOT REMOVE -->