Closed timwis closed 6 years ago
I've got it rendering the data properly, but having a hard time setting up the "select date range" interaction. Posted on SO.
Chartjs doesn't have a way to select the date range, apparently. So we'll need to add that functionality ourselves (per the reply on SO above) or switch to another charting library. Britecharts is new and its "brush" chart has it.
Made some progress on selecting a range in a time series chart.
canvas.onpointerdown = function (evt) {
const points = chart.getElementsAtEventForMode(evt, 'nearest', { intersect: false })
const label = chart.data.labels[points[0]._index]
console.log('down', label)
}
canvas.onpointerup = function (evt) {
const points = chart.getElementsAtEventForMode(evt, 'nearest', { intersect: false })
const label = chart.data.labels[points[0]._index]
console.log('up', label)
}
Not sure pointer
events are best practise (haven't encountered them before) relative to mouseup
/mousedown
but hopefully they're a way to handle touch events too.
Only thing missing here, really, is the visual indicator.
EDIT: demo of progress so far
Saved by plottable.js! See v2
branch for progress :D
Using Chart.js