Black Lives Matter. Please consider donating to Black Girls Code today.

Data gaps and date selected

Hi everyone,

I don’t understand range selection. I believe it should be empty but it’s not. Is this a feature or a bug? It returns date ‘2017-01-02’ and may be ‘2017-01-06’ if close enough. I think it’s correct but not for my case. Thanks.

        myPlot.on('plotly_relayout', function () {
            var xRange = myPlot.layout.xaxis.range;
            var ptsInside = [];

            var N = trace1.x.length;
            var count = 0;
            for (var i = 0; i < N; i++) {
                var xi = trace1.x[i];
                d1 = (new Date(xRange[0]));
                d2 = (new Date(xRange[1]));
                var ds1 = d1.getUTCFullYear() + "-" + pad(d1.getUTCMonth() + 1) + "-" + pad(d1.getUTCDate());
                var ds2 = d2.getUTCFullYear() + "-" + pad(d2.getUTCMonth() + 1) + "-" + pad(d2.getUTCDate());
                if (xi >= ds1 && xi <= ds2) {
                    console.log('pushed: ' + xi);
                    count++;
                    ptsInside.push(i);
                }
            }
        });

Hmm. I don’t understand your question. What are you looking to do?

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)