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

react-chartjs-2 v3.0.5 not recognizing the "cutout" property inside the config options for Doughnut chart #741

Closed
georgewfsantos opened this issue Sep 28, 2021 · 4 comments
Assignees

Comments

@georgewfsantos
Copy link

georgewfsantos commented Sep 28, 2021

Hello,
We are having an issue in our React application where cutout is not recognized as part of the config options for the Doughnut chart. The problem happened after the lib was upgraded to version 3.0.5 and we're using chart.js v3.5.1. We've tried a lot of things but the problem seems to be type related, since after adding " as any " to the config object inside the options prop, the problem disappears. I'm also attaching some screenshots below showing the error and that it disappears after typying the object as "any".Thank you in advance.
The code is as follows:

<Doughnut
              data={{
                labels: recognitionsByEvent.breakdown.map(
                  breakdown => breakdown.name,
                ),
                datasets: [
                  {
                    data: recognitionsByEvent.breakdown.map(
                      breakdown => breakdown.total,
                    ),
                    backgroundColor: getRandomColor(),
                  },
                ],
              }}
              height={200}
              options={{
                maintainAspectRatio: false,
                responsive: true,
                cutout: '75%',
                plugins: {
                  legend: { display: false },
                },
              }}
            /> 

Screenshot_20210928_105727
Screenshot_20210928_110729

@georgewfsantos georgewfsantos changed the title Hello, react-chartjs-2 v3.0.5 not recognizing the "cutout" property inside the config options for Doughnut chart Sep 28, 2021
@esslamben
Copy link

Can confirm TS is giving us the same errors for the cutout property.

Screenshot 2021-10-04 at 10 21 44

@honzahruby
Copy link

The Doughnut component doesn't correctly recognize its respective type of options. As a workaround, you can give it a hint and cast your options object to ChartOptions<'doughnut'>

@dangreen dangreen self-assigned this Oct 15, 2021
dangreen added a commit that referenced this issue Oct 18, 2021
dangreen added a commit that referenced this issue Oct 18, 2021
@dangreen
Copy link
Collaborator

@georgewfsantos Hi. Can you try react-chartjs-2@v3.1.1? Is this issue still there?

@georgewfsantos
Copy link
Author

@dangreen Hi. We need to take some time to test with that version. As soon as we do that, I'll let you know. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants