Data gaps and date selected

This question sort of related to my previous post.

That was resolved but now it’s including empty dates which I do not want. This line may be the cause but I think it’s the way plot.ly chooses range, which I hope to understand better. It’s not a big deal but just want to understand. Thanks

if (xi >= ds1 && xi <= ds2)