Skip to content

Commit

Permalink
Bump to version 0.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-alsterfjord-visma committed Nov 21, 2019
1 parent 6f5bf3e commit dd1b941
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Marcus Alsterfjord
Copyright (c) 2019 Marcus Alsterfjord

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
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.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chartjs-plugin-trendline",
"version": "0.1.2",
"version": "0.1.3",
"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": {
"del": "^3.0.0",
"del": "^5.1.0",
"gulp": "^4.0.2",
"gulp-bump": "^3.1.3",
"gulp-rename": "^1.4.0",
Expand Down
22 changes: 11 additions & 11 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: 0.1.2
* Version: 0.1.3
*
* Copyright 2017 Marcus Alsterfjord
* Released under the MIT license
Expand Down Expand Up @@ -59,22 +59,22 @@ function addFitter(datasetMeta, ctx, dataset, xScale, yScale) {
var y2 = yScale.getPixelForValue(fitter.f(fitter.maxx));
if ( !xy ) { x1 = startPos; x2 = endPos; }

const drawBottom = datasetMeta.controller.chart.chartArea.bottom;
const chartWidth = datasetMeta.controller.chart.width;
var drawBottom = datasetMeta.controller.chart.chartArea.bottom;
var chartWidth = datasetMeta.controller.chart.width;

if(y1 > drawBottom) { // Left side is below zero
const diff = y1 - drawBottom;
const lineHeight = y1 - y2;
const overlapPercentage = diff / lineHeight;
const addition = chartWidth * overlapPercentage;
var diff = y1 - drawBottom;
var lineHeight = y1 - y2;
var overlapPercentage = diff / lineHeight;
var addition = chartWidth * overlapPercentage;

y1 = drawBottom;
x1 = (x1 + addition);
} else if(y2 > drawBottom) { // right side is below zero
const diff = y2 - drawBottom;
const lineHeight = y2 - y1;
const overlapPercentage = diff / lineHeight;
const subtraction = chartWidth - (chartWidth * overlapPercentage);
var diff = y2 - drawBottom;
var lineHeight = y2 - y1;
var overlapPercentage = diff / lineHeight;
var subtraction = chartWidth - (chartWidth * overlapPercentage);

y2 = drawBottom;
x2 = chartWidth - (x2 - subtraction);
Expand Down

0 comments on commit dd1b941

Please sign in to comment.