Chartjs-ChartJS โ€“ How to add Text between Pie Chart and Legend

2๐Ÿ‘

โœ…

you can use filter options for customizing your labels

example down below


  legend: {
      display: true,
      labels: {
        usePointStyle: true,
        text: "Hello World",
        fontColor: "black",
        fontSize: 15,
        filter: function(legendItem, data) {
                let labels = data.labels, datasets = data.datasets[0].data;
                for(let i=0;i<labels.length;i++){
                if(labels[i].indexOf(legendItem.text)!=-1){
                let t = legendItem.text;
                legendItem.text = t+' : '+datasets[i] + '%';
                break;
                }
            }
            return legendItem;
            },

      },
      position: "bottom"
    }

Leave a comment