sgratzl / chartjs-chart-boxplot

Chart.js Box Plots and Violin Plot Charts
https://www.sgratzl.com/chartjs-chart-boxplot/
MIT License
101 stars 23 forks source link

Outliers and statistic values do not correspond to the provided data #62

Closed Vynskir closed 1 year ago

Vynskir commented 1 year ago

Hello,

First thank you very much for this plugin which is a must-have for ChartJS !

I encountered recently a very strange bug in which the outliers values cannot be found in the original data. Their values are slightly altered from the one provided. I use the latest version of ChartJS (v4.2.1) and chartjs-chart-boxplot (v4.1.1), and the issue seems to be present on multiple browsers (at least Chrome & Firefox).

I have made an example Codepen of the issue based on the demo one you provided: https://codepen.io/trobin/pen/RweRZwL

When hovering on the lower outlier, you can see that the displayed value is 57297216 instead of 57297214. Furthermore, hovering on the upper outlier displays 117540928 instead of 117540924. The min/max values are also incorrect when hovering on the boxplot itself, and the median seems also off.

Am I missing something obvious ? I would greatly appreciate your help.

Cheers, Thibault

sgratzl commented 1 year ago

I think the problem is that internally it is using a Float32Array for faster computation which leads to representation errors:

image

need to figure out how to use a Float64 instead