carbon-design-system / carbon-charts

:bar_chart: :chart_with_upwards_trend:⠀Robust dataviz framework implemented using D3 & typescript
https://charts.carbondesignsystem.com
Apache License 2.0
904 stars 184 forks source link

Donut / Pie chart: Hide labels? Hide labels based on % of the pie/donut filled? #917

Open tony opened 3 years ago

tony commented 3 years ago

Code sandbox:

I am submitting a...

charts version: 0.41.14

Issue description

Steps to produce the issue

Current behavior

image image

Attempting to hide:

      pie: {
        labels: {
          formatter: () => void 0
        }
      },

PieChart with pie.legends zero'd out: https://codesandbox.io/s/carbon-components-hide-labels-pie-void-7yxzs?file=/src/index.js

image

DonutChart With .pie.legends set to void: https://codesandbox.io/s/carbon-components-hide-labels-donut-void-j2tc6

image

Expected behavior

Would hope for some way to hide labels outright

image

Or a way to hide conditionally based on % of the graph/circle filled

Screenshot or recording

tony commented 3 years ago

Edited above:

I think this needs design advice since this is how to handle the layout of data when there's not enough room for it.

natashadecoste commented 3 years ago

@jeanservaas I can add a configuration to enable/disable the labels (and then not draw any callouts either). Is there more design explorations that need to be done for conditional rendering of callouts? There are some problems with what to do with slices that are too small for labels to not collide

jeanservaas commented 3 years ago

@natashadecoste Sorry, I know this issue has been kicking around for a while.

I would definitely add a config to enable/disable the labels in the meantime.

Beyond that, I think we need to label smaller slices either outside of the chart or in a tooltip with a table... and then just disable those labels. But I'm not too familiar with conventions around this... so yes, it would take a little research and some quick design explorations I think to address properly.

I also consulted @shixiedesign and @mjabbink to see what they say.

kavyanekkalapu commented 3 years ago

@natashadecoste @jeanservaas Hi, I am one of the ui dev using these charts, I am not sure who is fixing this issue but it is exactly what we are seeing in our project with pie and donut charts, Is there a way to hide labels for smaller percentages (<4%) and display percentages in tooltip? Right now tooltips are not displaying %. Something like first chart in below screenshot (Second one is carbon chart with same values), thank you.

Example:

Screen Shot 2021-01-26 at 8 03 49 PM
shawnmgoulet commented 2 years ago

@natashadecoste this issue has been around for some time now, but wanted to check in on the suggested approach. We have the same issue as has been discussed.

image