-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Disabling zoom in/out animation #109
Comments
Another idea can be to have a beforeZoom event when you use toolbar buttons, which allow the user to return new axis range(s), so you can constraint the xaxis max value for example. |
I'm sorry - but it would be difficult for me to visualize the issue without reproducing it. If you want to disable runtime animations (update after the initial render), you can set |
I've tried to create a codepen. Anthony. |
the code pen : https://codepen.io/atoy40/pen/RYexmo |
I saw your example, and I think I understood what you're trying to do. So, you're calling I suggest you call the events: {
zoomed: function (chart, {
xaxis
}) {
getServerData(xaxis.min, xaxis.max, function (temp) {
chart.updateOptions({
series: [{
data: temp
}],
xaxis: {
min: xaxis.min,
max: xaxis.max
}
}, true, false, false)
})
}
} Read more about the Also, I updated the codepen example, and it works great now. I hope this gives some idea. |
I agree it's far better with updateOptions as it preserve the range. |
Ok, then I think - a |
Docs: https://apexcharts.com/docs/options/chart/events/#beforeZoom Will be available in 1.5.5 |
But the problem with this form of beforeZoom function (returning a bool) is you disable the zoom. But in my temperature example, I don't want to disable the zoom, i want to have the zoom extend the range in the past, for example from [now-30day, now] to [now-60days, now] (instead of [now-45days, now+15days]). So imho, the beforeZoom event must allow to alter the proposed ranges. |
I thought you want to avoid zoomout by checking the “next” range. Ok, no problem. I will remove the boolean condition. So, you want to set a custom range in “beforeZoom” before zoom happens. Correct me if I am wrong |
It looks good, but may be there is a simple way to handle the problem. xaxis: {
min: now - 30*millisecondsperday // default to last month
max: now
extendedMin: now - 365*millisecondsperday // one year max
extendedMax: now // never show futur
} where you can define both, or only one (the extendedMax in my temperature example) Anthony. |
Changed the I have updated the docs on this page with an example So now, you will be able to control the "next" zoom range before the actual zoom happens. If you never want the user to zoom out into "future", you can set the "xaxis.max" as demonstrated in the example. |
Hello,
When you use zoom in/out button from the toolbar, it animate the graph accordingly by defining a new xaxis range. But when you load data dynamically into the zoom event handler, it's sometimes weird. For example, when you have a time data serie which only have value "before now", it's strange to have a centered zoom out (so empty graph before and after the inatial range), then another redraw when you get/update serie into the handler.
One simple solution can be to have an option to disable the zoom animation, and only call the zoom event handler. So the user can reload new datas, and if he wants, ignore the new xaxis proposed range and define the zoom "size" as he desires (because the graph will be automatically "xscaled" according to the new data set).
I hope it's understandable :)
Anthony.
The text was updated successfully, but these errors were encountered: