Skip to content

Commit

Permalink
Merge pull request #82 from Makanz/bugfix/scale-type-time
Browse files Browse the repository at this point in the history
Bugfix/scale type time
  • Loading branch information
Makanz authored Sep 13, 2023
2 parents 20437e5 + de7e564 commit b72fb07
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 71 deletions.
2 changes: 1 addition & 1 deletion dist/chartjs-plugin-trendline.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/chartjs-plugin-trendline.min.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* chartjs-plugin-trendline.js
* Version: 2.0.3
* Version: 2.0.4
*
* Copyright 2023 Marcus Alsterfjord
* Released under the MIT license
Expand Down
128 changes: 64 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartjs-plugin-trendline",
"version": "2.0.3",
"version": "2.0.4",
"description": "Trendline for Chart.js",
"main": "src/chartjs-plugin-trendline.js",
"scripts": {
Expand All @@ -17,7 +17,7 @@
},
"homepage": "https://github.com/Makanz/chartjs-plugin-trendline#readme",
"devDependencies": {
"webpack": "^5.83.1",
"webpack-cli": "^5.1.1"
"webpack": "^5.88.2",
"webpack-cli": "^5.1.4"
}
}
8 changes: 6 additions & 2 deletions src/chartjs-plugin-trendline.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!
* chartjs-plugin-trendline.js
* Version: 2.0.3
* Version: 2.0.4
*
* Copyright 2023 Marcus Alsterfjord
* Released under the MIT license
Expand Down Expand Up @@ -69,7 +69,11 @@ function addFitter(datasetMeta, ctx, dataset, xScale, yScale) {

if (['time', 'timeseries'].includes(xScale.options.type)) {
var x = data.x != null ? data.x : data.t;
fitter.add(new Date(x).getTime(), data.y);
if (x !== undefined) {
fitter.add(new Date(x).getTime(), data.y);
} else {
fitter.add(index, data);
}
} else if (xy) {
if (!isNaN(data.x) && !isNaN(data.y)) {
fitter.add(data.x, data.y);
Expand Down

0 comments on commit b72fb07

Please sign in to comment.