egui icon indicating copy to clipboard operation
egui copied to clipboard

Custom zoom configuration

Open SwayStar123 opened this issue 3 years ago • 3 comments

Is your feature request related to a problem? Please describe.

Currently, the ctrl + scroll zooms in on both x and y axis at the same time, when trying to see granular candlestick data this is not ideal.

Describe the solution you'd like

It would be nice if I could add my own custom zoom logic, like regular scroll to zoom on the x axis, ctrl scroll to zoom on the y axis, etc.

Describe alternatives you've considered

Ive tried setting the bar width at a higher number, so that zooming would be unnecessary but its impossible to find a zoom level that works for every need

Additional context

image Pretty much impossible to make any good use out of this chart with the current y axis zoom, only option is to zoom in on both axes and only view a small segment of the chart.

SwayStar123 avatar Jan 26 '22 09:01 SwayStar123

its not as important as a seperate x & y zoom but it would be nice if I could add a maximum and a minimum zoom level aswell as a log scale

SwayStar123 avatar Jan 26 '22 10:01 SwayStar123

Yep, I'd benefit hugely from being able to make check boxes for lock x zoom and/or lock y zoom so that I could zoom in one axis only. It'd also be nice to be able to specify ranges of x- and y-data to plot.

calbaker avatar Sep 02 '22 14:09 calbaker

This would be of great help to me too! Any ideas anyone?

g-tejas avatar Jan 08 '23 02:01 g-tejas

For my use case, I'd simply like to change zoom so it happens on regular scrolling, rather than ctrl + scrolling. A convenience method to zoom by a certain amount per each direction (around some centre point) would help me immensely, and would allow everyone to hook up whatever zooming behaviour they need. Sort of like the translate_bounds but for scale. Granted, they'd still need process the scroll deltas and mouse position themselves, but it would still be a lot friendlier than messing with set_plot_bounds. A possible API could be pub fn scale_bounds(&mut self, scale: Vec2, centre: Pos2) where the components of the scale vector represent the amounts to scale x and y by. Or alternatively two separate functions scale_x/y_bounds(&mut self, scale: f64, centre: f64).

IFcoltransG avatar Jan 23 '23 10:01 IFcoltransG

I opened a PR to address this issue. Any feedback would be appreciated. I included an example of how to customize the plot manipulation, but I am struggling with using Ctrl for scrolling instead of zooming. When Ctrl is down, the mouse Scroll event is automatically replaced by a Zoom event, so I don't know how to distinguish it from other Zoom events. If anyone knows of a way to get the mouse scroll delta regardless of modifier keys, that would be appreciated as well.

YgorSouza avatar Feb 11 '23 14:02 YgorSouza