# How to graph linear regression

**URL:** <https://forum.inductiveautomation.com/t/how-to-graph-linear-regression/2767>\
**Category:** Ignition\
**Created:** [March 16, 2011, 12:00pm UTC](https://forum.inductiveautomation.com/t/how-to-graph-linear-regression/2767 "2011-03-16T12:00:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnguyen](https://avatars.discourse-cdn.com/v4/letter/g/41988e/32.png) [@gnguyen](https://forum.inductiveautomation.com/u/gnguyen)\
**Post date:** [March 16, 2011, 12:00pm UTC](https://forum.inductiveautomation.com/t/how-to-graph-linear-regression/2767/1 "2011-03-16T12:00:21Z")

</div>

Hello,

I need to chart energy values and forecast trend by calculating a linear regression. And put it in a report.  
Is there a way to do it in the report module ? if not, I can calculate it and store it in SQL; but how to show up in a scatter plot and plot a line for the regression ?

Anyone has yet use the sdk to use a java chart library ?

Many thanks.

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [March 16, 2011, 5:05pm UTC](https://forum.inductiveautomation.com/t/how-to-graph-linear-regression/2767/2 "2011-03-16T17:05:12Z")

</div>

All of your data for the report is going into a dataset, so you could use python to take the raw data and mangle it into your final dataset. Just use a SQL query on one dataset and on a propertyChange event write a python script to copy it, do your linear regression calculation, and add the projected data. Store it in a final dataset on the report and use that in your charts. I haven’t used the sdk to do this, but it’s pretty easy to do so the hardest part should be your calculation.
