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

Donut chart issues with empty segments #357

Open
kylekarpack opened this issue Jun 18, 2024 · 3 comments
Open

Donut chart issues with empty segments #357

kylekarpack opened this issue Jun 18, 2024 · 3 comments
Labels
bug Something isn't working good first issue Good for newcomers open for contribution Issue is available for contribution rsc:Donut

Comments

@kylekarpack
Copy link
Member

Provide a general summary of the issue here

When rendering segment labels on a donut chart, there are several issues if all segments have a value of 0.

🤔 Expected Behavior?

  1. No NaNs displayed
  2. No overlapping labels (or potentially no labels shown at all)
  3. Potentially some sort of fallback behavior

😯 Current Behavior

Several rendering problems with the chart:

image

💁 Possible Solution

Falling back to a "No data found" label would be fine:
image

Alternatively, an empty donut chart would work nicely:
image

🔦 Context

No response

🖥️ Steps to Reproduce

Visit the CodeSandbox here

Ensure that all data points have a value of 0, and show percentage and value labels on a donut chart:

import {
  Chart,
  ChartPopover,
  ChartTooltip,
  Legend,
} from "@adobe/react-spectrum-charts";
import {
  Donut,
  DonutSummary,
  SegmentLabel,
} from "@adobe/react-spectrum-charts/rc";
import { defaultTheme, Provider } from "@adobe/react-spectrum";

export default function App() {
  return (
    <Provider theme={defaultTheme} height="100%">
      <div className="App">
        <Chart
          colorScheme="dark"
          data={[
            {
              browser: "Chrome",
              count: 0,
            },
            {
              browser: "Firefox",
              count: 0,
            },
          ]}
          height={350}
          width={400}
        >
          <Donut color="browser" holeRatio={0.8} metric="count">
            <ChartTooltip />
            <ChartPopover width="auto" />
            <DonutSummary label="Visitors" />
            <SegmentLabel percent value />
          </Donut>
          <Legend highlight isToggleable position="right" title="Browsers" />
        </Chart>
      </div>
    </Provider>
  );
}

Version

1.11.1

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS

🧢 Your Company/Team

AJO B2B

🕷 Tracking Issue

No response

@kylekarpack kylekarpack added the bug Something isn't working label Jun 18, 2024
@marshallpete
Copy link
Member

The proposed solution is to use a light gray (gray-200 or similar) ring as the donut and to display the value in the center as 0. Also we will drop all direct labels.

@marshallpete marshallpete added good first issue Good for newcomers open for contribution Issue is available for contribution rsc:Donut labels Jul 30, 2024
@Sid-80
Copy link

Sid-80 commented Aug 27, 2024

@marshallpete @kylekarpack I am willing to work on this issue!

@marshallpete
Copy link
Member

@Sid-80 sounds good. Please review the Contribution Guidelines and the Developer Docs before you get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers open for contribution Issue is available for contribution rsc:Donut
Projects
None yet
Development

No branches or pull requests

3 participants