Animation legend when there is no data for the first frame in the animation

Hello,

I am trying to create an animation using the tutorial (historical chart - data changing as years pass by). I managed to create the animation, but have the following issue:

I have to use a fixed year range. Depending on the dataset, sometimes the data is missing for the first year (for the first frame). In that case, the legend is not visible. In cases where the dataset is such that the first frame is populated with data, the legend is visible and everything works perfectly.

So it appears that displaying the legend depends on whether there is data in the first frame or not.

Any suggestions on how to tweak around this issue?

Thanks!

That’s correct, traces with empty coordinate arrays will not show in the legend.

I invite you to read https://github.com/plotly/plotly.js/issues/2861 for more info and a potential workaround.

Thanks Etienne. I appreciate the link.
I’ll try that.

three reasons why you should buy plotly pro: support open source, get great support, host your plots and dashboards online