-
Notifications
You must be signed in to change notification settings - Fork 327
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor & export pan and zoom functions #464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One minor point. The only other part I had comments about was removing some of the checks around the enabled
option, but I'm guessing that is because they were redundant
Thanks! Will try it out ASAP 👍 |
@KoalaBear84 I think you can use the scale options directly for "zoom to somewhere" kind of functionality. yourchart.options.scales.x.min = new Date('2021-04-19');
yourchart.options.scales.x.max = new Date('2021-04-20');
yourchart.update(); |
Hmm, didn't knew about that. It does work, as in that it also zooms to this period. But it also 'locks' the graph, so you cannot zoom out, and the "Reset zoom" button I use doesn't show anymore, probably because it isn't a real zoom command anymore. Hmm, I guess I know now I see my check, it is based on the values we change on the sample you supplied. Somehow there looks to be a change to the onZoomComplete function. In 1.0.0-beta.1 I have to use this (with curly brackets): onZoomComplete: function ({ chart }) {
showHideZoomButton(chart);
}
function showHideZoomButton(chart) {
document.querySelector('.resetZoomButton').style.display = (chart.scales.x.options.min != 0 || chart.scales.x.options.max != 0 || chart.scales.y.options.min != 0 || chart.scales.y.options.max != 0) ? 'block' : 'none';
} In 1.0.0-beta.2 I have to use this (without curly brackets): onZoomComplete: function (chart) {
showHideZoomButton(chart);
} Is there any logic to this, or am I doing something wrong? |
doPan
anddoZoom
interface.pan
andzoom
functions to chart instance.