ChartJS Datalabels plugin and negative numbers

๐Ÿ‘:0

After beating my head against the table for a few hours it seems that this may just be the intended behavior of datalabels.

I managed to "solve" it pretty simply like this:

 profit = profit.replaceAll("-","");

The negative can be added back in later using the formatter. In my case, I use a different data object when profit is negative, color it red, and change the "profit" heading to "loss". Solved well enough!

Leave a comment