Chartjs-How to add chart js legends in ember?

0👍

I’d the same issue with you, every item has a name, value and code. The name is larger than 20 characters.

I’ve provided codes as labels and names as tooltip. So my data:

data:{
  labels: items.map((item)=>{return Ember.get(item, labelName);}),
  datasets: [{
    borderColor: BORDER_COLORS,
    backgroundColor: BACKGROUND_COLORS,
    data: items.mapBy(propertyName)
  }]
}

And my tooltip options:

tooltips: {
  callbacks:{
    title: (tooltipItems)=>{
      let index = tooltipItem[0].index;
      return Ember.get(this.get('items')[index], tooltipName);
    }
  }
}

This solved my problem. I’ve tried legends but long names in legend fields are not seemed good to me.

Leave a comment