Regression

Type class

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"
    }]
  }]
}

@since 4.2.2

Sources

Regression can be used (imported) via one of the following packages.

// Regression is available in all of the following modules.
// You only need to import one of them.


Inheritance

Regression extends Plugin.

Regression is not extended by any other symbol.

Properties

events
#

Type EventDispatcher < AMEvent < this, IRegressionEvents > >

Default new EventDispatcher()

An EventDispatcher instance.

@since 4.3.14

method
#

Type "linear" | "polynomial"

Method to calculate regression.

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

@default linear

options
#

Type object

Regression output options.

Below are default values.

{
  order: 2,
  precision: 2,
}

@see This link About options

reorder
#

Type boolean

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

@default false
@since 4.2.3

result
#

Type Optional < any >

An object containing results of the calculation.

@since 4.3.14

simplify
#

Type boolean

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.

@default false
@since 4.2.3

target
#

Type Optional < XYSeries >

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

Methods

constructor()

#

Returns Regression

Constructor

dispose()

#

Returns void

Inherited from Plugin

Disposes this object and related stuff.

init()

#

Returns void

isDisposed()

#

Returns boolean

Inherited from Plugin

Returns if this element is already disposed.

There are 2 inherited items currently hidden from this list.

Events

#processed

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

Invoked when regression finishes calculating data.

Adapters

Regression does not have any adapters.