Skip to content

Add Trend Line

Linda Mejia edited this page Sep 13, 2020 · 7 revisions

To create a trend line we have used a linear regression javascript library.

  1. Add the following to scripts.html file inside the _includes folder:

<script src="https://cdn.jsdelivr.net/npm/regression@2.0.1/dist/regression.min.js"></script>

  1. Add the following code to this file (open-sdg-site-starter/_includes/assets/js/indicatorView.js), which can also be found here:

linear regression function

  1. Then, call the linear regression function by adding linearRegression(chartInfo); inside of this.createPlot function & this.updatePlot function.