Using D3 transition method with data for scatter plot

前端 未结 2 371
清歌不尽
清歌不尽 2020-12-10 12:53

So I\'m new to D3 and have little exp with JavaScript in general. So I have been following some tutorials am currently using source code that creates a basic scatter plot.

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-10 13:20

    First, before addressing the transition issue, you need to refactor things a bit. You're going to want to call an update(newData) function every time your data changes, and have this function do all the necessary updates.

    This tutorial by mbostock describes exactly the "general update pattern" you'll need.

    Parts II and III then go on to explaining how to work transitions into this pattern.

    They're very short. And once you understand them, you'll have just about all the info you need to do this.

提交回复
热议问题