Setting initial active slider step to something else than 0 does not update the chart
We have a grouped bar chart where each group consists of two or three bars. If a bar is above a certain threshold, we color it different than the others. There may be up to 1000 bar groups, but we only display 32 at once. For this purpose, we use a slider to allow the user to pan the chart horizontally. So far, so good.
We have the requirement to automatically jump to the first bar group that is beyond the mentioned threshold. For this purpose, we calculate in which bar group the first bar resides, then detect the corresponding range and set the active property to its index. This move the slider to the correct position, but does not update the view. In fact, the view still remains at the first slider position.
As MCVE, one can use the Basic Slider example from the docs (https://plot.ly/javascript/sliders/#basic-slider). The slider is set to red by default, but the line color is blue. One has to select a different slider position first and then select red afterwards to actually get a red line instead of a blue one.

@molehillrocker Thanks for pointing this out. Your assessment is correct though. We talked about a feature that would apply the initial slider position by updating the plot right after it's initially plotted, but we ultimately decided against it as having a few too many corner cases. Slider steps have the ability to call any plotly API function, which means the only way to apply that step is to actually issue the command, which, in the case of animation for one, wouldn't actually be desirable on initialization. There might also be a flash of un-slider'd content if there's a tick between the initial plot and the issuing of the command. I think we would need to write custom wrappers for some of the API function to tell it what to do on initialization. restyle might just restyle, but animate might need to override timing or make other tweaks. If it's possible to nail down all the corner cases and make it behave predictably though, I'd strongly support better handling of the initial slider position.
At the moment though, I'd recommend this approach for starting on frame 5 of 10:
- Set up an array of 10 frames
- Deep-clone frame 5 and pass it as the data/layout, along with the 10 frames, to
Plotly.newPlot
@rreusser can we merge this ticket with https://github.com/plotly/plotly.js/issues/1225 ?
Yes, definitely. Forgot there was a ticket for this. Thanks! Merging with #1225.
Thanks for the quick response. I'll try the workaround with the frames and monitor #1225 in the meantime. :smile_cat:
Has there been any update on this issue about a starting frame other than 0?
I still have this issue, even with 0'th frame. I set my title in slider and unless I move the slider, I don't get a title.