Skip to content

Regression

Type classSince 4.2.2

A module which automatically calculates data for for trend lines using various regression algorithms.

By pushing an instance of Regression into plugin list of any XYSeries, it automatically recalculates and overrides its data to show regression trend line, inestead of the source values.

Example:

let regseries = chart.series.push(new am4charts.LineSeries());
regseries.dataFields.valueY = "value";
regseries.dataFields.dateX = "date";

let reg = regseries.plugins.push(new am4plugins_regression.Regression());
reg.method = "polynomial";
var regseries = chart.series.push(new am4charts.LineSeries());
regseries.dataFields.valueY = "value";
regseries.dataFields.dateX = "date";

var reg = regseries.plugins.push(new am4plugins_regression.Regression());
reg.method = "polynomial";
{
  // ...
  "series": [{
    // ...
  }, {
    "type": "LineSeries",
    "dataFields": {
      "valueY": "value",
      "dateX": "date"
    },
    "plugins": [{
      "type": "Regression",
      "method": "polynomial"
    }]
  }]
}

Sources

This information about Regression is provided for reference only and is not available through exported packages and thus should not be imported or used on its own.

Inheritance

Regression extends Plugin.

Regression is not extended by any other symbol.

Properties

events

Type EventDispatcher <AMEvent <this, IRegressionEvents>>Default new EventDispatcher()Since 4.3.14

An EventDispatcher instance.

method

Type "linear" | "polynomial"Default linear

Method to calculate regression.

Supported values: "linear" (default), "polynomial".

options

Type object

Regression output options.

Below are default values.

{
  order: 2,
  precision: 2,
}

More info: https://github.com/Tom-Alexander/regression-js#configuration-options About options

reorder

Type booleanDefault falseSince 4.2.3

Orders data points after calculation. This can make sense in scatter plot scenarios where data points can come in non-linear fashion.

result

Type Optional <any>Since 4.3.14

An object containing results of the calculation.

simplify

Type booleanDefault falseSince 4.2.3

Simplify regression line data? If set to true it will use only two result data points: first and last.

NOTE: this does make sense with "linear" method only.

target

Type Optional <XYSeries>

A series object that will be used for the trend line.

Methods

constructor()

Returns Regression

Constructor

init()

Returns void

2 inherited items
dispose()

Returns voidInherited from Plugin

Disposes this object and related stuff.

isDisposed()

Returns booleanInherited from Plugin

Returns if this element is already disposed.

Events

processed

Param { type: "processed", target: Regression }

Invoked when regression finishes calculating data.