chartjs / chartjs-plugin-datalabels

Chart.js plugin to display labels on data elements
https://chartjs-plugin-datalabels.netlify.app
MIT License
873 stars 473 forks source link

plugin doesn't work with @napi-rs/canvas@0.1.40, chart.js@4.2.1 #378

Open Mikarrori opened 1 year ago

Mikarrori commented 1 year ago

Tried chart.registry(datalabels) and plugins: [datalabels], no errors throwed and nothing happens.

Any hints or tips are appreciated.

Mikarrori commented 1 year ago

it seems that this plugin doesn't like data of which the structure is an object, as i inspected the value args of the formatter option, it was undefined when the data structure is an object. Problem solved by:

formatter: (value, context) => {
                            let keys = Object.keys(context.dataset.data)
                            let key = keys[context.dataIndex]
                            return context.dataset.data[key]
                        }

not a good solution though

florind-ens commented 1 year ago

Ty, I was running through the same scenario as you.

simonbrunel commented 1 year ago

@Mikarrori Can't really help without a way to debug your issue. Since it's an old ticket, I hope you fixed your problem. If not, please provide a codepen that reproduces your use case.