ScottPlot / ScottPlot

Interactive plotting library for .NET
https://ScottPlot.net
MIT License
5.24k stars 855 forks source link

X/Y Axis.SetBoundary should respect lockScales: true #2913

Closed bukkideme closed 11 months ago

bukkideme commented 1 year ago

Example: we have a heatmap with lockScales: true. the formsplot control is docked inside a container panel, which we resize freely with the application window.

Issue now: if we want to set XY Axis.SetBoundary, so the Heatmap plot display does not have "white", empty parts inside the XY axis, then this will break the lockScale = true behaviour. As much as i understand, we could create an automatic padding size calulator, so the lockScale true could be kept respected even if setting axis.SetBoundary ?

image

swharden commented 11 months ago

Hi @bukkideme, thanks for pointing this out!

This seems like some pretty niche custom axis behavior. You could poke through the code that evaluates whether boundaries are set and after it modifies the axis you could have it do whatever logic the scale locker uses.

Alternatively, since you've got so much custom axis stuff going on, it may be simpler to use events to invoke a custom method every time the plot's axes change. I think it's the AxesChanged event. In your custom handler you can apply the boundary limiting you seek then force a square scale lock.

Both strategies would probably work, but the second one seems a little simpler and doesn't require messing with the ScottPlot 4 source code.

I'll close this issue for now, but feel free to re-open it if you make progress on this front! I'll be focusing pretty hard for the next few weeks on #2984👍