FormsPlot: Fix exception when right mouse clicking on a plot with Crosshair.#1794
FormsPlot: Fix exception when right mouse clicking on a plot with Crosshair.#1794swharden merged 6 commits intoScottPlot:mainfrom MareMare:1791-getlegenditems-maybe-null
Conversation
|
An alternative solution would be return a default legend object in |
|
@StendProg, Thank you for your reply.
So you mean, for example, the following? public LegendItem[] GetLegendItems() => Array.Empty<LegendItem>();I thought about that too, but I did the same with the Shall I change to the solution you suggested? |
|
I mean something like this: public class Crosshair
{
...
public LegendItem[] GetLegendItems() => new LegendItem[]{ new LegendItem(this){label = null}};
...
}We only have 1 Plottable which is out of concept and returns |
|
Sorry for the delay. public interface IPlottable
{
...
/// <summary>
/// Returns items to show in the legend. Most plottables return a single item. in this array will appear in the legend.
/// Plottables which never appear in the legend can return null.
/// </summary>
LegendItem[] GetLegendItems();
...
}As stated in the documentation comments for the Therefore, I would like to return null for the said method ( |
|
Thank you @MareMare and @StendProg!
I will implement this now to bring
I am happy the filter was updated to protect against In ScottPlot 5 I'll use the |
|
Quick update, wow, lots of plottables were returning null! 4bcf592 Returning null was even recommended in the XML documentation of |
Purpose:
I tried solve #1791.
Fixed a
NullReferenceExceptionexception raised by right mouse click on a WinForms Plot with Crosshair.