Skip to content

Pie Chart: add support for slice labels outside the pie #2275

@cpa-level-it

Description

@cpa-level-it

Feature Suggestion

Alter the piechart API to allow the user to distribute the labels along the radius of the piechart. So the user could specify if the label should be close to the center or near the border.

Feature description:
Sometimes when you make piecharts with labels, the labels can overlaps if slice are too small.

image

One way to avoid this problem would be to distribute the labels along the radius, so they would not be overlapping. This could ideally be computed automatically but a first step would be to just allow the users to define where on the radius a label should be. This could be defined in percent, 0% would mean the label is on the center, 100% on the perimeter.

This also could be used when the ShowValues or ShowPercentages are true.

Code example:

var values = new int[] {10, 20, 30};
var labels = new string[] {"10", "20", "30"};
var labelsPosition = new float[] {0.33f, 0.66f, 0.99f};

var plt = new ScottPlot.Plot((int)(size.Width * scale), (int)(size.Height * scale));
var pie = plt.AddPie(values);
pie.SliceLabels = labels;
pie.SliceLabelsPositions = labelsRadiusPosition;

Is it something that could be possible ?

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