JSPM

chartjs-plugin-regression

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 51
  • Score
    100M100P100Q71909F
  • License ISC

Plugin to draw a regression line

Package Exports

  • chartjs-plugin-regression

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (chartjs-plugin-regression) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

chartjs-plugin-regression

Chart.js plugin to calculate and draw statistical linear, exponential, power, logarithmic, and polynomial regressions using chart datasets data.

The plugin, at the current version, uses the regression npm package as its calculation engine.

Demo

For a better understanding of the capabilities of this plugin, please see this Live Demo.

Download

The compressed version includes the regression package.

Installation

npm install --save chartjs-plugin-regression

Usage

JavaScript

new Chart(ctx, {
  type: type,
  plugins: [
    // This chart will use the plugin
    ChartRegressions
  ],
  data: {
    ...
    datasets: [
      {
        ...
        // Configuration of the plugin per dataset (only will be drawn the datasets with this property) 
        regressions: {
          type: 'linear',
          line: { color: 'red', width: 3},
          ...
        }
      }
    ] 
  },
  options: {
    plugins: {
      regressions: {
        // Global configuration of the plugin, these values will be used unless each dataset defines their own
        type, line, calculation, extendPredictions, copyOverData,
        // Callback function to know when the calculation have been completed for all the datasets.
        onCompleteCalculation: (chart)=> ...
      }
    }
  }
});

License

The project is released under the ISC license.