mykola-digtiar / chartjs-plugin-piechart-outlabels

Highly customizable Chart.js plugin that displays labels outside the pie/doughnut chart.
https://piechart-outlabels.netlify.com/sample/
MIT License
51 stars 38 forks source link

This is plugin is not compatible with 3.x chart js verstion #23

Open jagdaleganesh opened 3 years ago

jagdaleganesh commented 3 years ago

This plugin is really awesome but looks like it is working with only 2.x chart js version. Can someone please share how I can make this plugin compatible with chartjs latest version.

Thanks,

jagdaleganesh commented 2 years ago

Any update when this plugin updated to compatible with latest ChartJs version

ChrisRoss5 commented 2 years ago

Same problem here. Definitely not compatible with the latest chartjs version.

jghelen commented 2 years ago

I have the same problem (chart.js@3.5.1)

jagdaleganesh commented 2 years ago

I have tried to update this plugin so that we can use with latest chartjs version 3 and above. I am not sure whether it is fully updated but with my change atleast I can use with latest chartjs version. @jghelen @ChrisRoss5 , hope this will help . chartjs-plugin-outlables.zip

var params = { display: true, //text: [ // '%l (%p.3) \n VALUE: (%v.3)', // '%l (%p) \n VALUE: (%v)', // 'SIMPLE VALUE \n => %v', // 'VALUE WITH PRECISION 4 \n => %v.4', // 'SIMPLE PERCENT \n => %p', // 'PERCENT WITH PRECISION 3 \n => %p.3', // 'JUST LABEL \n => %l', // 'JUST TEXT' //], borderWidth: 2, lineWidth: 2, padding: 3, textAlign: 'center', stretch: 45, font: { resizable: true, minSize: 12, maxSize: 25, family: Chart.defaults.font.family, size: Chart.defaults.font.size, style: Chart.defaults.font.style, lineHeight: Chart.defaults.font.lineHeight, }, color: "black", valuePrecision: 1, percentPrecision: 2 }; var chartOption = { maintainAspectRatio: false, zoomOutPercentage: 20, animation: false, layout: { padding: 50 }, plugins: { outlabels: params, } };

new Chart(ctx, { type: 'doughnut', plugins: [ChartOutLabels], data: { datasets: dataSets, labels: labels }, options: chartOption });

TijlDeclerckWd commented 2 years ago

@jagdaleganesh how do I use this in a project?

jagdaleganesh commented 2 years ago

@TijlDeclerckWd , you can just include js from attached zip and for uses I have already given code snippet.

emit077 commented 2 years ago

Hey, Guys alternatively you can try this. JSFIDDLE

AndreasK79 commented 1 year ago

And for those looking for a working version, check this repo out: https://github.com/energiency/chartjs-plugin-piechart-outlabels