We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在官方案例‘带辅助框标注的基础柱状图’中,动态添加数据时,第二次添加时报错
将下面的代码粘贴至官方案例的“带辅助框标注的基础柱状图"中
第二次点击时,正确渲染出柱状图
import { Column } from '@ant-design/plots'; import React,{useState} from 'react'; import ReactDOM from 'react-dom'; const data = [ { month: '1', value: 178 }, { month: '2', value: 126 }, { month: '3', value: 78 }, { month: '4', value: 623 }, { month: '5', value: 319 }, { month: '6', value: 422 }, { month: '7', value: -4 }, { month: '8', value: -217 }, { month: '9', value: -358 }, { month: '10', value: 1513 }, { month: '11', value: 1388 }, { month: '12', value: 597 }, ]; let i=12 const DemoColumn = () => { const config1 = { data, xField: 'month', yField: 'value', scale: { y: { domainMax: 2000, domainMin: -1000, }, }, axis: { x: { labelFormatter: (val) => `${val} 月`, }, }, annotations: [ { type: 'rangeX', data: [{ month: ['7', '9'] }], xField: 'month', }, ], }; const [config,setconfig]=useState(config1) const click = ()=>{ i=i+1 console.log(`i=${i}`) setconfig({...config,data:[...config.data,{month:`${i}`,value:12}]}) } return <> <button onClick={click}>添加一条数据</button> <Column {...config} /> </>; }; ReactDOM.render(<DemoColumn />, document.getElementById('container'));
报错信息
The text was updated successfully, but these errors were encountered:
先改为 setState(data) 跳过一下,后续修复
Sorry, something went wrong.
No branches or pull requests
🐛 bug 描述 [详细地描述 bug,让大家都能理解]
在官方案例‘带辅助框标注的基础柱状图’中,动态添加数据时,第二次添加时报错
📷 复现步骤 [清晰描述复现步骤,让别人也能看到问题]
将下面的代码粘贴至官方案例的“带辅助框标注的基础柱状图"中
🏞 期望结果 [描述你原本期望看到的结果]
第二次点击时,正确渲染出柱状图
💻 复现代码 [提供可复现的代码,仓库,或线上示例]
© 版本信息
🚑 其他信息 [如截图等其他信息可以贴在这里]
报错信息
The text was updated successfully, but these errors were encountered: