Fix: Correct trendline rendering, projection, and data accuracy #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This commit addresses several issues with the chartjs-plugin-trendline:
Trendline Boundaries and Projection:
adjustLineForOverflowfunction.Consistent Slope/Intercept:
LineFitter.Data Point Accuracy for Fitting:
trendoffset:trendoffsetcorrectly skips points from the beginning of the dataset.trendoffsetnow correctly excludes points from the end of the dataset.{x, y}pairs): points are now skipped if either the x or y coordinate is invalid (null, undefined, NaN), preventing the use ofindexas a fallback coordinate which could skew the trendline.Code Clarity and Examples:
src/components/trendline.jsto explain the new logic for boundary calculations, clipping, and data selection.example/lineChartProjection.htmlwith multiple datasets and an "Observations Guide" to clearly demonstrate the corrected behaviors and new features liketrendoffsetand null data point handling.These changes collectively improve the accuracy, visual correctness, and predictability of the trendlines generated by the plugin.