Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/TargetProcess/tauCharts/llms.txt

Use this file to discover all available pages before exploring further.

The trendline plugin adds a regression line to a scatter plot or line chart. It supports three model types — linear, exponential, and logarithmic — and can optionally display a control panel that lets users switch between models and toggle the trend line visibility at runtime. An optional error band can be shown around the trend to indicate the confidence of the fit.

Usage

var chart = new Taucharts.Chart({
    type: 'scatterplot',
    x: 'experience',
    y: 'salary',
    data: dataset,
    plugins: [
        Taucharts.api.plugins.get('trendline')({
            showPanel: true,
            showTrend: true,
            models: 'linear'
        })
    ]
});

Settings

models
'linear' | 'exponential' | 'logarithmic'
default:"'linear'"
The regression model used to fit the trend line.
  • 'linear' — fits y = mx + b using ordinary least squares.
  • 'exponential' — fits y = A·e^(Bx).
  • 'logarithmic' — fits y = A·ln(x) + B.
type
string
An alias for models accepted for backwards compatibility. Use models for new code.
showTrend
boolean
default:"true"
When true, the trend line is visible on initial render. Set to false to hide the trend line by default and let the user enable it through the panel.
showPanel
boolean
default:"true"
When true, a small control panel is rendered alongside the chart. The panel lets users switch between model types and toggle trend visibility without reloading the chart.
hideError
boolean
default:"false"
When false, an error band (confidence region) is drawn around the trend line to indicate the variance of the fit. Set to true to suppress the error band and show only the regression line.

How trend lines are fitted

The plugin fits the selected regression model to the x and y values from the chart data. Each supported model is calculated as follows:
ModelFormulaNotes
Lineary = mx + bOrdinary least squares via gradient and intercept calculation
Exponentialy = A·e^(Bx)Weighted least squares on ln(y)
Logarithmicy = A·ln(x) + BLeast squares on ln(x)
The fitted curve is drawn as a line element overlaid on the chart. The equation string (e.g. y = 1.23x + 4.56) is computed and can be displayed in the control panel.
The exponential and logarithmic models require positive y and x values respectively. Data points with zero or negative values in the relevant axis are excluded from the regression calculation.

Examples

Linear trend with panel hidden

Taucharts.api.plugins.get('trendline')({
    models: 'linear',
    showPanel: false,
    hideError: true
})

Exponential trend, error band visible

Taucharts.api.plugins.get('trendline')({
    models: 'exponential',
    showPanel: true,
    showTrend: true,
    hideError: false
})

Start with trend hidden, let users enable it

Taucharts.api.plugins.get('trendline')({
    models: 'linear',
    showTrend: false,
    showPanel: true
})

Build docs developers (and LLMs) love