Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chart JS grouped sub labels

Looking at the documentation, i'm struggling to find a solution for rendering a chart with the attached data structure.

Could anyone help answering if and how the below is possible?

  • Multiple grouped stacks (re-using datasets in groups)
  • Adding sub labels to each of the bars within a group.

enter image description here

Has anyone been able to achieve this with the library?

Thanks in advance.

like image 795
Samuel Avatar asked Feb 06 '18 12:02

Samuel


1 Answers

I haven't seen that done before. But I can see a possible alternative solution.

You can use the chartjs datalabels plugin, which allows you to put labels on the data itself.

Here is an example: https://chartjs-plugin-datalabels.netlify.com/samples/charts/bar.html with the source code here: https://github.com/chartjs/chartjs-plugin-datalabels/blob/master/samples/charts/bar.html

First you'll have to install the datalabels plugin, and add the datalabels parameter to your data.

like image 179
DavidX Avatar answered Nov 18 '22 01:11

DavidX