-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
Question: I Would like to know how can I create a doughnut chart in Scott Plot 5, I know that I can make a pie chart and on V4.1 there used to be a .DonutSize property, which is no longer available.
ScottPlot Version: 5
Code Sample:
public void Create_ScottPlot_Doughnut(string path)
{
double[] values = { 44.2, 51.9, .09, 1.1, .8, 1.1 };
string[] labels = { "External", "Sold", "Personel", "Others", "Depreciation", "Tax" };
var palette = new ScottPlot.Palettes.Category20();
// Define the slices for the doughnut chart
var slices = new List<PieSlice>();
for (var i = 0; i < values.Length; i++)
{
var slice = new PieSlice
{
Value = values[i],
Label = values[i].ToString("N2"),
LabelStyle = new Label { IsVisible = true },
FillColor = palette.Colors[i],
};
slices.Add(slice);
}
// Add the doughnut chart to the plot
Plot myPlot = new();
var pie = myPlot.Add.Pie(slices);
//pie.ExplodeFraction = 0.05; // Set the donut size to create a hollow center
pie.ShowSliceLabels = true;
pie.SliceLabelDistance = 1.3;
pie.LineStyle.Width = 0;
myPlot.HideGrid();
myPlot.Layout.Frameless();
myPlot.Legend.IsVisible = true;
myPlot.Legend.Location = Alignment.LowerCenter;
myPlot.SavePng(path, 1000, 650);
Console.ReadKey();
}This is something like what I would like to do:

Is it also possible to make the labels never be on top of one another?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels