ng2-charts icon indicating copy to clipboard operation
ng2-charts copied to clipboard

ng2-chart add image in legend

Open Totot0 opened this issue 5 years ago • 0 comments

I use legendCallback to customize my legend and in this customization I want to add an image that depends on the legend’s libel. The problem is that it just blinks as if the page reloads every time. When I remove the image it no longer does

` legendCallback: function(chart) { const legendHtml = []; const item = chart.data.datasets[0]; legendHtml.push('

'); for (let i = 0; i < item.data.length; i++) { if(chart.data.labels[i] === 'MonLabel1') {
        legendHtml.push('<img src="./assets/img/img1_icon.png" style="width:50px"/>');

      }}else {

      }
      legendHtml.push('<div style="border-left: 6px solid ' + chart.data.datasets[0].backgroundColor[i] + '; height: 100%;">');
      legendHtml.push('<div style="padding-left:10px;">' + chart.data.labels[i] + '</div>');
      legendHtml.push('<div style="padding-left:10px; weight: "bold">' + item.data[i] + '</div>');
      legendHtml.push('</div>');
    }
    legendHtml.push('</div>');
    return legendHtml.join('');`

Totot0 avatar Jul 10 '19 13:07 Totot0