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

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()

An EventDispatcher instance.

@since 4.3.14

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,
}

Click here About options

reorder
#

Type boolean

Default false

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

@since 4.2.3

result
#

Type Optional < any >

An object containing results of the calculation.

@since 4.3.14

simplify
#

Type boolean

Default false

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.

@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.