Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[charts] PieChart position #14032

Closed
sshologin opened this issue Jul 30, 2024 · 5 comments
Closed

[charts] PieChart position #14032

sshologin opened this issue Jul 30, 2024 · 5 comments
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!

Comments

@sshologin
Copy link

sshologin commented Jul 30, 2024

Steps to reproduce

Link to live example: (required)

Current behavior

I tried removing cx, cy, setting width, but it seems that it doesn't work at all. Maybe any props to center PieChart?

Expected behavior

No response

Context

Is it possible to make cx and cy props to be calculated automatically, based on the width of the screen? The problem is that without those props the PieChart is not centered in the container

That's what I have now
Screenshot_3

That's how it looks on 1200px
Screenshot_4

Without cx and cy it looks like this
Screenshot_6

Search keywords: piechart

@sshologin sshologin added bug 🐛 Something doesn't work status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 30, 2024
@github-actions github-actions bot added the component: charts This is the name of the generic UI component, not the React module! label Jul 30, 2024
@michelengelen
Copy link
Member

@JCQuintas could you take this one?

@michelengelen michelengelen changed the title [Charts / PieChart] PieChart position [charts] PieChart position Jul 30, 2024
@JCQuintas
Copy link
Member

Hi @sshologin , could you provide a code example using https://codesandbox.io/ or https://stackblitz.com/ ?

Otherwise you could try removing the margin to center the chart.

    <PieChart
      ...
      margin={{ right: 0 }}
    />

We also have an issue already that is similar to this. Where we intend to allow positioning the chart in center/left/right. Which could be helpful in the future: #13787

@sshologin
Copy link
Author

sshologin commented Jul 30, 2024

Hi @sshologin , could you provide a code example using https://codesandbox.io/ or https://stackblitz.com/ ?

Otherwise you could try removing the margin to center the chart.

    <PieChart
      ...
      margin={{ right: 0 }}
    />

We also have an issue already that is similar to this. Where we intend to allow positioning the chart in center/left/right. Which could be helpful in the future: #13787

Seems like it was sort of bug, but I changed nothing and now it works really well, I really don't know what happened
Screenshot_7

Margin right 0 is also good solution for me

                        <Box
                            sx={{
                                display: 'flex',
                                flexDirection: 'row',
                            }}
                        >
                            <PieChart
                                slotProps={{
                                    legend: { hidden: true },
                                }}
                                series={[
                                    {
                                        data: investments.map((investment) => ({
                                            id: investment.id,
                                            value: investment.value,
                                            label: investment.label,
                                            color: investment.color,
                                        })),
                                        paddingAngle: 2,
                                        cornerRadius: 5,
                                        highlightScope: {
                                            faded: 'global',
                                            highlighted: 'item',
                                        },
                                        cx: 130,
                                        cy: 100,
                                        innerRadius: 40,
                                        valueFormatter: (params) => {
                                            const percent =
                                                params.value / totalValue;
                                            return `${(percent * 100).toFixed(
                                                1
                                            )}%`;
                                        },
                                    },
                                ]}
                                width={270}
                                height={200}
                            />
                        </Box>

Also it says that faded and highlighted are deprecated symbol

@JCQuintas
Copy link
Member

Glad it worked for you. You can use fade and highlight instead to get rid of the deprecation warning

@michelengelen michelengelen removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 31, 2024
Copy link

⚠️ This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

@sshologin: How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: charts This is the name of the generic UI component, not the React module!
Projects
None yet
Development

No branches or pull requests

3 participants