Skip to content

Automatic render after a plottable is added? #525

@swharden

Description

@swharden

Problem

After plotting in user controls you have to call Render() to force a redraw.
This is not intuitive to new users and is easy to forget.

double[] dataX = new double[] {1, 2, 3, 4, 5};
double[] dataY = new double[] {1, 4, 9, 16, 25};
formsPlot1.plt.PlotScatter(dataX, dataY);
formsPlot1.Render(); // <-- you must do this

Solution?

Add a delegate to the Plot module:

public delegate void PlottablesUpdated();
public PlottablesUpdated PlottablesUpdatedHandler;

Invoke the delegate whenever the list of plottables is modified:

PlottablesUpdatedHandler?.Invoke();

User control constructors would wire it together like this:

plt.PlottablesUpdatedHandler = () => Render();

Thoughts

  • There may be a slight performance hit since adding 5 scatter plots will cause 5 renders
  • Automatic rendering can be disabled with formsPlot1.plt.PlottablesUpdatedHandler = null

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions