emn178 / chartjs-plugin-labels

Plugin for Chart.js to display percentage, value or label in Pie or Doughnut.
MIT License
614 stars 219 forks source link

Multiple datasets support? #111

Open Tomas-M opened 4 years ago

Tomas-M commented 4 years ago

Is there a support for multiple datasets? For example when I have two doughnut charts, and I want labels for first doughnut to be outside, and then labels for second doughnut to be on border or using different textMargin, ... is it supported now?

Tomas-M commented 4 years ago

If so, can you provide example usage? I can see the plugins: { labels: [{ ... }] } option is an array, but it does not seem to do anything useful.

petitmamouth commented 4 years ago

Hi, Had the same problem. I resolved it with line 207 only (without function)

    case 'label':
      if (this.chart.config.data.labels.length >0 && this.chart.config.data.labels[index] != undefined){
        label = this.chart.config.data.labels[index];
      } else {
        label = dataset.labels[index];
      };
      break;

nested_001

regards

vickieallen commented 4 years ago

@petitmamouth please can you clarify exactly what you did to get the labels to be different per dataset? I can't quite follow what you mean above.