Interactive examples showcasing linear trendline functionality for Chart.js
Add the plugin to your HTML page:
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.6.1/dist/chart.umd.js"></script>
<script src="https://cdn.jsdelivr.net/npm/chartjs-plugin-trendline/dist/chartjs-plugin-trendline.min.js"></script>
Basic bar chart with dotted trendline
Bar chart displaying trendline with custom label
Handling datasets with missing data points
Standard line chart with linear trendline
Exponential curve fitting on a logarithmic axis
The same fit on an axis where the curve is visible
Line chart with trendline projection beyond data
Line chart with time-based x-axis
Scatter plot with fitted trendline
Scatter chart with extended trendline projection
xAxisKey and yAxisKey on time-series data
fillColor, and alwaysShowTrendline when a series is hidden
percentage labels and trendoffset on a plain array