gcalmettes/reveal.js-d3

Moving backward when loading external data gives error due to data not read in yet

Opened this issue · 2 comments

I have a visual with several steps for which I need to load several (larger) files. When I move forward in my visual this is fine, because I can call my "initial state" function from within the code (the data reading function) itself, and it will take some seconds before I would press "next" to go to the next fragment. During this time my data will have loaded.

However, when I move backwards from the next slide, and thus the final transition triggers immediately, then my data has not yet fully loaded, before reveal.js-d3 triggers that function, and thus the final animation function gives an error, and the slide just shows the initial state.

Not a major problem, since going back is "extra" anyway, but I was wondering how you've perhaps solved this in the past? I noticed that the examples from the demo that rely on "pure" d3 all have their data hardcoded in the files, or if a file is loaded, then no transition is triggered, right? Would it perhaps be possible to add an extra slide that does show this? A big-ish dataset being loaded through some form of d3.csv() / d3.json(), adding a few transitions, having a slide after that one, and then seeing how it would work when going backward?

Great idea.
I will look into this, but on the top of my head what you could do is add a conditional statement to load the data if there is no data in the function triggered by your last transition. I will add that in the demo,

O yeah, that sounds like it would work! Looking forward to the addition to the demo so I can learn from it :)