cancel
Showing results for
Did you mean:

# Adding A Regression Line To Chart

Community Team Member
Introduction
Regression line helps us to predict values of one variable, when given values of another variable.
Linear regression assists in predicting trends and improving data analysis.

Steps
A regression line can be added to all widgets with both y and x axis.
We can add a simple linear regression calculation to any line / column / scatter chart by use of a simple js code.
The x and y values must be numeric (int).

Step 1:

C:\Program Files\Sisense\PrismWeb\plugins\RegressionLine,  if the "plugins" folder is not there, please create it. If you are using version 7.2 and higher unzip the contents into your C:\Program Files\Sisense\app\plugins\ folder.

Step 2:
Create a widget that has both numeric  X and Y axis (bar chart, line chart, scatter chart etc.).

Step 3:
Open the widget editor, edit script.  Copy the js code below into the script editor.

widget.on('processresult', function(sender, args) {
args.result.series[0].regression = true;
args.result.series[0].regressionSettings = {
type: 'linear',
color:  '#29a2a4',
dashStyle : 'dash',
name : 'regression line'
};
});

If you want multiple regression lines just add the same definition for the next regression line For example:
widget.on('processresult', function(sender, args) {
args.result.series[0].regression = true;
args.result.series[0].regressionSettings = {
type: 'linear',
color:  '#29a2a4',
dashStyle : 'dash',
name : 'regression line'
};

args.result.series[1].regression = true;
args.result.series[1].regressionSettings = {
type: 'linear',
color:  '#29a2a4',
dashStyle : 'dash',
name : 'regression line2'
};

});

Code configuration:
Make sure you change the name  'regression line'  to a meaningful name.
You can edit the script and choose different color or
regression types (see explanation in the readme file in the attached Zip file)
Press SAVE
Close the Script window

Step 4:
Refresh the Widget and click apply
The chart should appear with the regression line
7 - Data Storage

Has anyone gotten this to work in version L2023.x?  I'm not having any success after installing the plugin and using the scripts above.

If not, are then any alternatives to creating regression lines on scatterplot, line, or bar charts (that do not have a date dimension)?

Thanks?

John

John

Community Team Member

Hello @JohnDonovan .

First of all, sorry for the delay. I know this answer has taken a while. These posts from intapiuser were created by an automated migration and are not monitored.

This is a community-made plugin, not created or supported by Sisense. It doesn't look like it has been updated in quite a while.

Have a great day!

Version history
Last update:
‎03-02-2023 09:17 AM
Updated by:
Contributors
Community Toolbox

Developers Group:

Product Feedback Forum: