Many fixes are available on chart.js side.
Like an issue that prevents us from drawing small values:
https://github.com/chartjs/Chart.js/issues/5653
chart.js is a peer dependency to this project. You should be able to update the package in your project.
The problem is that they don't seem to respect semver. Chart.js has breaking changes in minor versions. Updating the peer dependency from let's say 2.3 to 2.7 means some things may be broken. https://github.com/chartjs/Chart.js/releases
@AoDev you can specify a specific changeset from their repo if that would help you:
https://github.com/mozilla-frontend-infra/firefox-health-dashboard/commit/177ab0350918541fa1511e4223d360d852973e78#diff-b9cfc7f2cdf78a7f4b91a753d10865a2
As per this issue, if I understand correctly, I don't think there's anything that can be done on the react-chartjs-2 side.
@armenzg
I think what should be done is to update the chart.js peer dependency to latest. This would need to make sure that the code is changed to accommodate breaking changes.
To force the minimum chart.js version?
What would happen to people that don't want to or can't upgrade their Chart.js?
Is this issue more of a recommendation?
This would effectively create a breaking change in this package. So bump to 3.x.x. and people wouldn't have any problem. They can either stay with the version they have or adapt their code to update major.
This project is a wrapper on top of a library, if there is a breaking change in chart.js, it will usually lead to a breaking change for react-chartjs-2.
There are multiple problems right now:
[email protected]chartjs@^2.3First problem
This means that the developers are actually using different versions to develop than what users might use. I believe the problem is because chartjs does not follow semver and people are not aware of it.
With the peer dependency set as it is, people may face bugs and problems because the current range ^2.3 will allow for any version with a breaking change.
Second problem
On the other hand, since this is a wrapper, it should follow chartjs to take advantage of bug fixes and improvements that are being released, which currently is not possible. (like the one I am facing)
I don't know why they don't follow semver, but it has led to some confusion. So, it's not a recommendation, there is really something to do.
I found this issue: https://github.com/chartjs/Chart.js/issues/4778
Thanks @AoDev for ellaborating!
@jerairrest I believe it is a reasonable request; Do you have any concerns or questions? Or can this be tackled?
I can agree with following semver to keep up with Chart.js's crazy breaking change scheme. We can add a compatibility matrix to the README to ensure what major version people should use.
Thanks, I don't have much time for actual coding but if there is something else I can do, let me know.
I'll copy the list of breaking changes they had since 2.3.
2.7.0
Breaking Changes
#4079 Doughnut, polarArea and radar charts aspect ratio changed to 2 to be consistent with
other charts and are not square anymore by default.
Use the aspectRatio: 1 option to restore the previous behaviour.
2.6.0
Breaking Changes
#3782 The lineArc setting for the radial linear scale has been removed
and replaced by gridLines.circular and pointLabels.display.
#4044 The bar controller internals has been refactored,
therefore custom chart types that extend from the bar controller will need to be updated.
More details can be found in this PR.
2.5.0
Breaking Changes
#3570 Removed unused Chart.helpers.cancelAnimFrame method.
#3669 onHover callback now has 3 parameters.
The 2nd parameter is the event that triggered the hover. This was done for consistency with the onClick callback.
2.4.0
Breaking Changes
#3356 The default aspect ratio is now correctly applied,
meaning that polar, doughnut and radar charts are now rendered with an aspect ratio of 1
(square). The old behavior can be obtained by globally changing the default
aspectRatio for each chart type (e.g. Chart.defaults.doughnut.aspectRatio = 2).
Sometimes, I guess a breaking change on chartjs side, does not affect react-chartjs-2. So this compatibility matrix is a great idea : )
Wow... it's been too long since I looked at this. Anyone still interested on implementing this idea?
Should it start at 3.0 going forward with 2.7? or should there be an effort for the following:
chart.js 2.4.0 = react-chart-js-2 4.0
chart.js 2.5.0 = react chart-js-2 5.0
etc.