question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Display stack label for Stacked groups

See original GitHub issue

Feature Proposal

When I use stacked groups, I want the possibility to display stack label if correct option is selected.

Suggestions of options:

this.chart = new Chart('canvas', {
      type: 'bar',
      data: {
        labels: this.barChartLabels,
        datasets: this.datasets;
      },
      options: {
        scales: {
          xAxes: [{
            display: true,
            stacked: barStacked,
            displayStackLabel: true
          }],
          yAxes: [{
            display: true,
            stacked: barStacked
          }],
        }
      }
    });

Feature Use Case

I have found a stack-overflow with exactly the same feature wanted : https://stackoverflow.com/questions/48643408/chart-js-grouped-sub-labels

chart

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:13
  • Comments:9

github_iconTop GitHub Comments

1reaction
kpetrowcommented, Jan 20, 2022

This is actually resolved using datalabels plugin, and labels. Use labels as regular maybe adjusting vertical height to make room for datalabels. Also adjust datalabels vertical height and offset then use formatter

 chartSettings.options.plugins.datalabels.formatter = function (value, context) {
    let ds = context.chart.data.datasets
    // check if it's the first ds
    if (ds[context.datasetIndex - 1]) {
      // check if the ds is in the same stack as the ds before
      if (ds[context.datasetIndex - 1].stack == ds[context.datasetIndex].stack) {
        return ''
      } else {
        return ds[context.datasetIndex].stack;
      }
    } else {
      return ds[context.datasetIndex].stack;
    }
0reactions
firetunescommented, Jan 20, 2022

+1 Would like this

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Complete Guide to Stacked Bar Charts | Tutorial by Chartio
Stacked bar charts extend the standard bar chart by dividing each bar into multiple subcategories. Learn how to best use this chart type...
Read more >
Stacked Groups | FlexChart | ComponentOne - GrapeCity
Stacked groups allow you to compare items across categories in a group. In addition, you can visualize relative difference between items in each...
Read more >
Display label of stacked graphs on the bar rather - ServiceNow
My client is asking to setup a stacked bar chart and to display the labels for the different stacks. The issue is that...
Read more >
How to add total labels to stacked column chart in Excel?
Create a stacked column chart with total labels in Excel · 1. Supposing you have prepared your source data as below screenshot shown....
Read more >
Stacked Bar Chart with Segment Labels - Graphically Speaking
Stacked Bar Chart with Segment Labels · Summarize the data by category and group variable using the MEANS procedure. · Use a data...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found