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!

1 Like

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

I invite you to read `visible: true` ignored if x, y data arrays are empty · Issue #2861 · plotly/plotly.js · GitHub for more info and a potential workaround.

2 Likes

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