Linear regression

Calculate a linear trend from original XY samples.

Import
@neural-charts/angular
Data
regression

Live demo

Container width

The chart fits its available space automatically. Choose a width to simulate a different container.

Animation
240ms
Samples and calculated trendThe linear fit is calculated from original XY pairs.0010102020303040400055101015152020XXY

Samples and calculated trend

The linear fit is calculated from original XY pairs.

Original data
SeriesidxyVisible
Original samplessample-004Yes
Original samplessample-119.7Yes
Original samplessample-226.4Yes
Original samplessample-335.4Yes
Original samplessample-4412.8Yes
Original samplessample-5515.7Yes
Original samplessample-6611.4Yes
Original samplessample-7713.4Yes
Original samplessample-8821Yes
Original samplessample-9920.9Yes
Original samplessample-101017.2Yes
Original samplessample-111122.1Yes
Original samplessample-121228.4Yes
Original samplessample-131325.7Yes
Original samplessample-141423.9Yes
Original samplessample-151530.9Yes
Original samplessample-161634.7Yes
Original samplessample-171730.6Yes

Tap a data point or explore it with the pointer or keyboard.

Configurator

Adjust the presentation and interaction of this example.

Chart elements and interaction
Chart toolbar
  1. CSV
  2. PNG
  3. SVG

Interactive examples

Open a chart to explore its data, try its options and copy its code.

When to use it

Compare samples with an ordinary least-squares fit y = slope × x + intercept. A linear relationship is a modelling assumption, not a forecast or causal conclusion. No extrapolation is drawn.

Chart API · Linear regression

Expand a property to learn when to use it, see its public type, and find examples where applicable.

Data

The property data.type for this family is regression.

Appearance

Customize presentation while keeping series and point identities stable.

Axes and grid

Data types and domains determine the scale. Use options.axes to change its presentation.

Legend

Tooltip

Customize the tooltip with code →

Interaction and state

Identify the selection and hidden series by ID.

Animation

Complete options and events reference

Explore the data

Select an observation with the pointer or enter the chart with Tab. Arrow keys navigate the data; Home and End move to the endpoints. Enter or Space selects, and Escape closes the detail.

The data table retains original values, including missing values and hidden series. A repeated label does not merge separate categories. Manual screen reader review remains pending.

Accessibility guide

Example data

Copy the current input object with its original identifiers and values.