2 回答
TA贡献1815条经验 获得超10个赞
在 Highcharts 中用于绘制饼图,adultData 和 allData 应采用如下格式:
[
{
name: "USA",
y: 1000
},
{
name: "Italy",
y: 500
}
]
(或者)
[
{
"name": "USA",
"y": 1000
},
{
"name": "Italy",
"y": 500
}
]
请在您的输入数据中仔细检查。我在 GitHub 上写了一篇博客文章和一个工作应用程序,其中包含一个简单的 Highcharts 饼图示例。请查看: http: //softwaredevelopercentral.blogspot.com/2020/03/react-highcharts-and-spring-boot.html
TA贡献1798条经验 获得超7个赞
我遇到了同样的问题,并找到了一个粗略的解决方法。就像你说的,这发生在初始组件渲染上。因此通过更新状态触发重新渲染可以解决问题。
const [shouldRender, doRender] = useState(true)
useEffect(() => {
if (shouldRender) { // this stops the cycle after the first re-render
doRender(!shouldRender)
}
想补充一下,以防有人有更好的解决方案,我正在使用相同的道具渲染多个图表,只有饼图是一个问题。
添加回答
举报