Comments (1)
Ok, so I've found the problematic section of code. This is in components/Legend/index.tsx:
// 事件didmount后绑定一次即可
useEffect(() => {
// 连续图例
view.on('legend:valuechanged',(ev: {
/** [ start, end ] */
originValue: [ number | any, number | any ],
/** [ start, end ] */
value: [ number | any, number | any ],
}) => {
if (_isFunction(props.onChange)) {
props.onChange(ev, view)
}
});
// 分类图例
view.on('legend-item:click', (ev: IEvent) => {
if (_isFunction(props.onChange)) {
const { target } = ev;
const delegateObject = target.get('delegateObject');
const { item } = delegateObject; // 图例选项
ev.item = item; // 快捷获取
props.onChange(ev, view);
}
});
}, []);
The empty dependency array for this useEffect means it will only run on the first render. When props.onChange changes, the chart event is not updated.
There is a fix. When you load the chart, you can get the g2Instance (a prop on Chart) and call .on yourself (the g2Instance is the 'view' referenced above) to re-register the legend click events when they change.
I'm leaving this issue open since this does not follow the expected behavior. If you run into this issue, the fix above should work.
from bizcharts.
Related Issues (20)
- Tooltip报错
- legend
- react18 严格模式下, 切换 图表类型 不渲染 HOT 1
- 带有label的条形图(BizCharts@4)数据紊乱,刷新会随机出现以下2种情况,label对应的会乱
- onAnnotationClick在Annotation.Html下不生效 HOT 1
- The above error occurred in the <Chart3> component: HOT 1
- English documentation
- [Feature Request]气泡散点图支持双缩略轴
- 设置了父级元素的宽高,并且把autoFit设置为true,再设置图表的宽高还是有效 HOT 1
- DonutChart的onRingClick事件该如何触发
- react 兼容版本能提升至 17.+ 吗?做个多版本兼容行吗?
- 时间类型的x轴,刻度显示的值错误
- Interval组件动态修改adjust属性视图不更新
- v4版本的Legend如何实现基于html的自定义
- Issue with Chart Visualization in React/Next.js Project Using StrictMode HOT 1
- @antv/g2 已经发布了新的大版本v5,请问是否有支持的计划?
- uglify-js:2.8.29 ,ansi-regex:2.1.1, inflight:1.0.6 ,扫描到这三个组件存在高危漏洞,请问近期有修复计划吗?
- 基础饼图的label怎么改成蜘蛛Label形式
- Scale配置中,linear类型下属性minTickInterval 设置不生效
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bizcharts.