-
Notifications
You must be signed in to change notification settings - Fork 981
Description
This issue was emailed to me from Jeff Haley
The legend is duplicated after adding a pie chart: I looked at the PlottableList and noticed that the software had actually added 2 pie charts instead of just one. They were both referencing the same object. I have pasted the code containing the error below. Only the function called with the PieSlice list needs to add the pie chart to the plottable list as it is always called by the function with the double valued array below it. This may affect some of the other overridden functions. I hope this helps. In my project I have used RemoveAt on the PlottableList to remove the extra pie chart object. I think this is an excellent library, very fast and extremely useful. I hope I have helped in some small way.
The error is in this portion of the code:
ScottPlot/src/ScottPlot5/ScottPlot5/PlottableAdder.cs
Lines 430 to 454 in 8c2ffc9
| public Pie Pie(IList<PieSlice> slices) | |
| { | |
| Pie pie = new(slices); | |
| Plot.PlottableList.Add(pie); | |
| return pie; | |
| } | |
| public Pie Pie(IEnumerable<double> values) | |
| { | |
| List<PieSlice> slices = new(); | |
| foreach (double value in values) | |
| { | |
| PieSlice slice = new() | |
| { | |
| Value = value, | |
| FillColor = Palette.GetColor(slices.Count), | |
| }; | |
| slices.Add(slice); | |
| } | |
| var pie = Pie(slices); | |
| Plot.PlottableList.Add(pie); | |
| return pie; | |
| } |