-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Labels
Description
Create something like this
public static class ScottPlotExtensions
{
/// <summary>
/// Update another plot control's axis limits when this one's change
/// </summary>
public static void ShareAxisLimits(this IPlotControl source, IPlotControl target, bool x = true, bool y = true)
{
if (source == target)
throw new ArgumentException("Cannot link a plot control to itself");
source.Plot.RenderManager.AxisLimitsChanged += (s, e) =>
{
AxisLimits sourceLimits = source.Plot.Axes.GetLimits();
if (x) target.Plot.Axes.SetLimitsX(sourceLimits.Left, sourceLimits.Right);
if (y) target.Plot.Axes.SetLimitsY(sourceLimits.Bottom, sourceLimits.Top);
target.Plot.RenderManager.DisableAxisLimitsChangedEventOnNextRender = true;
target.Refresh();
};
}
}which makes it easy to link plot controls together like this:
formsPlot1.ShareAxisLimits(formsPlot2, x: true, y: false);
formsPlot2.ShareAxisLimits(formsPlot1, x: true, y: false);Then update the docs to show how to use it
Reactions are currently unavailable