question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pie chart label horizontal alignement (v3.0)

See original GitHub issue

got an issue on the pie chart label. Can you please advice or explain me how to align horizontally the labels ? I try several things without success.

readonly PieConfig myPieChartConfig = new PieConfig { AutoFit = true, AngleField = "value", ColorField = "type", Label = new PieLabelConfig { Visible = true, Type = "inner" } };

image

Thanks for the support.

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
superjerry88commented, Feb 21, 2023

Hi @Youldboukhitine,

I manage to recreate this for you, but because post processing is required to calculate the total 100%, some javascript is needed. (It is shown as 82% here because its 70 out of 85) image

Here’s how you can do it:

<Pie Data=data Config="csConfig" JsConfig="@jsConfig" />
public string jsConfig = @"{label: {content: ({ percent }) => `${(percent * 100).toFixed(0)}%`,}}";
PieConfig csConfig = new PieConfig()
    {
        Radius = 0.8,
        AngleField = "value",
        ColorField = "type",
        Label = new PieLabelConfig()
        {
            Visible = true,
            Type = "inner",
            AutoRotate = false,
            Style = new TextStyle()
            {
                TextAlign = TextStyle.TextAlignCenter,
                FontSize = 21,
            },
        },
    };

For JS documentation, you can refer to here: https://charts.ant.design/en/examples/pie/basic#basic

0reactions
Yz274419commented, Aug 15, 2023

Thank you for your reply. I am currently using version 0.3.1. I also tried changing the version to 0.3.0, but I was unable to reproduce the issue. I created a simple project at https://github.com/Yz274419/AntPie/blob/main/Pages/Counter.razor image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Labels alignmnet pie chart / matplotlib 2.1.0+
1. You are setting both horizontal and vertical alignments to 'center', but what you want is to only set the vertical alignment to...
Read more >
Align 3 graph pies
How do I align a pgfplots graph? 3 · Horizontally align inference rules · 1 · Align table side by side with graph...
Read more >
Cannot set text alignment in pie chart · Issue #10941
The code sets the text alignment to left or right based based on where the label is. The error could be solved by...
Read more >
Change the format of data labels in a chart
You can format the labels to show specific labels elements like, the percentages, series name, or category name. Pie chart with data labels...
Read more >
Creating Pie Chart and Adding/Formatting Data Labels (Excel)
Creating Pie Chart and Adding/Formatting Data Labels (Excel). 281K views · 9 years ago ...more. Dan Kasper. 1.4K. Subscribe.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found