2.1.0 • Published 4 months ago

chartjs-plugin-trendline v2.1.0

Weekly downloads
1,788
License
MIT
Repository
github
Last release
4 months ago

chartjs-plugin-trendline

This plugin draws an linear trendline in your Chart. It has been tested with Chart.js version 4.4.0.

Installation

Load directly in the browser

Load Chart.js first, then the plugin which will automatically register itself with Chart.js

<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-trendline"></script>

As a Chart.JS plugin

Install & import the plugin via npm:

npm i chart.js chartjs-plugin-trendline

import ChartJS from 'chart.js';
import chartTrendline from 'chartjs-plugin-trendline';

ChartJS.plugins.register(chartTrendline);

Configuration

To configure the trendline plugin you simply add a new config options to your dataset in your chart config.

{
	trendlineLinear: {
		colorMin: "red",
		colorMax: "green",
		lineStyle: "dotted|solid",
		width: 2,
		xAxisKey: "time" (optional),
		yAxisKey: "usage" (optional),
		projection: true|false (optional)
	}
}

Supported chart types

  • bar
  • line

Contributing

Pull requests and issues are always welcome. For bugs and feature requests, please create an issue.

License

chartjs-plugin-trendline.js is available under the MIT license.

2.1.0

4 months ago

2.0.5

8 months ago

2.0.4

8 months ago

2.0.3

12 months ago

2.0.2

1 year ago

2.0.1

1 year ago

1.0.3

2 years ago

2.0.0

2 years ago

1.0.2

2 years ago

1.0.0

3 years ago

0.2.2

3 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.1.3

4 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.4

5 years ago

0.0.3

6 years ago

0.0.1

6 years ago