0👍
As you have mentioned, console log of the x-axis-0 does not have the min and max index. I was working in a project that requires almost identical solution to yours hence had to find a way around.
I added the moment.min.js and added time type to x-axis because drag zoom doesn’t seem to work without it:
type: 'time',
time: { parser: 'HH:mm:ss', displayFormats: { second: "HH:mm:ss" } },
I got the first and last value from chart.scales["x-axis-0"].ticks after zoom and got the desired min and max index from chart.data.labels and the rest was easy.
var data = chart.data.labels;
var l = chart.scales["x-axis-0"].ticks;
l = l.length -1;
var min = data.indexOf(chart.scales["x-axis-0"].ticks[0]);
var max = data.indexOf(chart.scales["x-axis-0"].ticks[l]);
document.getElementById("vv").innerText = JSON.stringify(chart.data.datasets[0].data.slice(min, max +1));
Here is the jsfiddle:
https://jsfiddle.net/ModeNashid/84zuqwLa/3/
Note that I did not check the versions of any of the resources that you have included in your jsfiddle so there might be some warnings.
Source:stackexchange.com