chartjs / awesome

A curated list of awesome Chart.js resources and libraries
MIT License
2.11k stars 128 forks source link

add labels plugin #78

Open noraj opened 6 months ago

noraj commented 6 months ago

Awesome Contribution Checklist:

Please Describe Your Addition

An (now old) plugin I used to add labels on my pie charts.

noraj commented 4 months ago

Chart.js version 2 is old and if the plugin does not support newer versions it's likely it won't be maintained and its use for new users is verry limited.

They are then better off using the data labels plugin that is already listed

I disagree. I use this plugin for https://noraj.github.io/XSS-classification-model/ and that's the only label plugin that works well with arc labels.

I have been stuck with Chart.js 2.9.1 because this is the only plugin working for this use case.

https://github.com/noraj/XSS-classification-model/blob/46e072b6dce5270a8e0f2508cec4479dcc6bb45e/docs/index.html#L10C3-L11

I have spent hours trying to upgrade to Chat.js 4, but the issue is not Chat.js but the replacement plugin chartjs-plugin-datalabels doesn't behave properly for arcs. So rather than ChartJS 4 and ugly labels I preferred to stick to ChartJS 2 and emn178/chartjs-plugin-labels waiting for a better plugin working with newer versions of ChartJS.

https://github.com/noraj/XSS-classification-model/blob/0125eb01aead52c26a68ff6d3f56bf7868f01cd1/docs/index.html#L10-L11

So I think this plugin is worth being listed since it supports unique feature not working for other labels plugins.

stockiNail commented 4 months ago

Hi guys, let me jump in this thread, if I may.

In principal, I agree with @LeeLenaleee . Doesn't make much sense to publish now a plugin which is clearly unmaintained and not complaint with last 2 major versions of Chart.js.

@noraj I know what you meant. In fact, in my library where I'm wrapping Chart.js, the lib is providing both datalabels and labels plugins.

But my lib is based currently on Chart.js 4.4.x and the labels plugin is not working with that. And then I have decided, several years ago, when the lib wrapped Chart.js 3, to change the plugin adapting it to new Chart.js version.

I didn't create a fork to new repo because I don't have time to maintain it for JS guys, currently the adapted plugin is working with CHart.js 4.4.x.

Here you can take/see the code. The code has been a bit updated to better integrate the J2CL/GWT lib (mainly for events) but you can change it as you want.: https://github.com/pepstock-org/Charba/blob/master/src/org/pepstock/charba/client/resources/js/chartjs-plugin-labels.js

Feel free to create a repo and maintain it if you want.

And here the doc (even if it is for java developers) but you can see the options: https://pepstock-org.github.io/Charba-Wiki/docs/extensions/Labels#options

I hope it can help you.