How to create a pie chart with %

Hi there,
I’m a beginner here, you will find below the details.
Thank you for your help.


  • What Grafana version and what operating system are you using?
    v8.0.3 on Chrome

  • What are you trying to achieve?
    A pie chart representation

  • How are you trying to achieve it?
    From a Postgresl table.

The table view look like this :

Date | Modality | sum_modality
2021-09-02 | AC | 4
2021-09-02 | AB | 3
2021-09-02 | CA | 3
2021-09-01 | CA | 2
2021-09-01 | BG | 6
2021-08-31 | BG | 3
2021-08-31 | AC | 3

  • What happened?
    Didn’t achieve to well set up the pie chart to display the distribution with a filter per date.

  • What did you expect to happen?
    I would like to display the distribution in pourcent. For exemple if I choose to filter only on this date ‘2021_09-02’, the pie chart is suppose to show 25% AC, 33,3%, AB 33,3% CA.

And if I choose to filter on several date, rates should be automaticly update.

  • Can you copy/paste the configuration(s) that you are having problems with?
select 
  $__timeGroup(date, 1d),
  modality,
  sum(count_modality) as sum_modality
from 
  schema.table
GROUP BY 
  date,
  modality,
  count_modality
  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    no

  • Did you follow any online instructions? If so, what is the URL?
    Didn’t find relevant instructions

Welcome to the Grafana forums.

Can you show us what your data looks like in Table view (switch the toggle at the top of the screen). For example, my pie chart in Table view looks like this:

and the pie chart looks like this, where you can see the amounts in percent. The chart changes as I change the date range (e.g. last 90 days, last year, etc.):

1 Like

I succeed in resolving my problem finally thank you :slight_smile:

SELECT
  $__timeGroupAlias(date,$__interval),
  sum(count_modality) AS "count_modality",
  modality AS "modality"
FROM <table> 
WHERE
  $__timeFilter(date)
GROUP BY 1, modality
ORDER BY 1

This topic was automatically closed after 365 days. New replies are no longer allowed.