chartjs/chartjs-plugin-datalabels

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

Mikarrori opened this issue · 3 comments

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

Any hints or tips are appreciated.

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

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

@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.