AmCharts 4 "animateData is not a function" 还是 'How to reanimate chart new data'?

AmCharts 4 "animateData is not a function" or 'How to reanimate chart new data'?

我通过将它包含在页脚中来使用 AmCharts4。

<script src="https://www.amcharts.com/lib/4/core.js"></script>
<script src="https://www.amcharts.com/lib/4/charts.js"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js"></script>
<script>am4core.useTheme(am4themes_animated);</script>


我可以绘制图表并在加载时进行动画处理,但很想在接收新数据时进行动画处理。
chart.animateAgain()chart.animateData() 都抛出我 TypeError: chart.animateAgain is not a function.


为了创建图表,我做了 chart = am4core.create("chartdiv", am4charts.RadarChart);

我刚刚分配了新数据 chart.data = newData

animateDataanimateAgain是版本3中的方法。版本4完全不同API。

要在版本 4 中重新绘制图表并再次触发动画,您可以调用 invalidateData,这在需要 manually update the chart. You can also call deepInvalidate if you really want to trigger a full redraw, but it's very performance heavy and the documentation warns to only do this if absolutely necessary 的情况下也很有用。