Skip to content

Add support for customizing the value of DonutSummary #577

@lishichengyan

Description

@lishichengyan

Provide a general summary of the feature here

For Donut charts, the summary in the center always displays the total value of all slices by default, for example -

 const donutData = [
    { id: '1', value: 3 },
    { id: '2', value: 7 },
  ];
 colors = ['static-green-800', 'gray-200'];
 <Chart
   data={donutData}
   colorScheme="light"
   colors={colors}
   height={110}
   width={110}
   >
    <Donut color="id" metric="value">
      <DonutSummary label={'Good'} />
    </Donut>
  </Chart>

renders

Image

Is there a way to customize it so that only the value of the green slice (i.e. the slice with id=1) is shown instead?

🤔 Expected Behavior?

Can customize the value of DonutSummary, maybe provide a prop -

<DonutSummary label={someLabel} value={someValue}/>

💁 Possible Solution

No response

🔦 Context

Working on a project where we need to display a measurement score out of 10. We'd like to visualize it using a donut chart, with the score (not the sum) shown in the center.

💻 Examples

Here's a mock -
Image

🧢 Your Company/Team

No response

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