I have following example data for a line chart:
[
{
x: 'Mon Sep 29 2018 14:26:53 GMT+0100',
y: 100
},
{
x: 'Mon Oct 15 2018 10:40:31 GMT+0100',
y: 400
}
]
My goal is to set a certain time frame as default and change it's range and zoom dynamically. If there is no data to show, it's fine.
I'm using the chartjs-plugin-zoom which allows me to pan freely on the x axis which is very good. Unfotunately the zoom is set on user events via this plugin.
Basically I want to have buttons to switch between time scalings and then pan on the x axis.
My question is, do I need to set the "limits" in ChartJS itself and let the plugin only pan? If yes, how to do this "freely" not considering the data (ChartJS tries to fit all data in the view, correct me if I'm wrong)
I tried the zoom options on the plugin, but they do not seem to affect anything:
zoom: {
enabled: true,
drag: false,
mode: '',
rangeMin: {
x: moment().format(),
y: null
},
rangeMax: {
x: moment().add(7, 'day').format(),
y: null
}
}
Thank you!