{"id":13701997,"url":"https://github.com/pomgui/chartjs-plugin-regression","last_synced_at":"2026-04-04T09:34:49.822Z","repository":{"id":42257620,"uuid":"274739029","full_name":"pomgui/chartjs-plugin-regression","owner":"pomgui","description":"Chart.js plugin to calculate and draw statistical linear, exponential, power, logarithmic, and polynomial regressions.","archived":false,"fork":false,"pushed_at":"2023-01-06T10:38:28.000Z","size":98,"stargazers_count":20,"open_issues_count":9,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T03:07:40.995Z","etag":null,"topics":["chart","regressions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pomgui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-24T18:17:05.000Z","updated_at":"2025-03-25T23:14:36.000Z","dependencies_parsed_at":"2023-02-05T22:00:26.809Z","dependency_job_id":null,"html_url":"https://github.com/pomgui/chartjs-plugin-regression","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/pomgui/chartjs-plugin-regression","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomgui%2Fchartjs-plugin-regression","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomgui%2Fchartjs-plugin-regression/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomgui%2Fchartjs-plugin-regression/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomgui%2Fchartjs-plugin-regression/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pomgui","download_url":"https://codeload.github.com/pomgui/chartjs-plugin-regression/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pomgui%2Fchartjs-plugin-regression/sbom","scorecard":{"id":740669,"data":{"date":"2025-08-11","repo":{"name":"github.com/pomgui/chartjs-plugin-regression","commit":"1cf097a2020537755ee086fb23ef4a7c87a15a90"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/20 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"11 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-76p3-8jx3-jpfq","Warn: Project is vulnerable to: GHSA-3rfm-jhwj-7488","Warn: Project is vulnerable to: GHSA-hhq3-ff78-jv3g","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4","Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-22T17:20:15.670Z","repository_id":42257620,"created_at":"2025-08-22T17:20:15.670Z","updated_at":"2025-08-22T17:20:15.670Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31394916,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-04T09:13:02.600Z","status":"ssl_error","status_checked_at":"2026-04-04T09:13:01.683Z","response_time":60,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["chart","regressions"],"created_at":"2024-08-02T21:00:29.264Z","updated_at":"2026-04-04T09:34:49.787Z","avatar_url":"https://github.com/pomgui.png","language":"TypeScript","readme":"[![NPM version](https://img.shields.io/npm/v/chartjs-plugin-regression.svg)](https://npmjs.org/package/chartjs-plugin-regression) \n[![License](http://img.shields.io/badge/license-ISC-blue.svg)](https://github.com/pomgui/chartjs-plugin-regression/blob/master/LICENSE)\n[![NPM downloads](https://img.shields.io/npm/dm/chartjs-plugin-regression.svg)](https://npmjs.org/package/chartjs-plugin-regression)\n\n# chartjs-plugin-regression\nChart.js plugin to calculate and draw statistical linear, exponential, power, \nlogarithmic, and polynomial regressions using chart datasets data.\n\nThe plugin, at the current version, uses the [regression](https://www.npmjs.com/package/regression)\nnpm package as its calculation engine.\n\n### Important\n- Only `bar`, `line`, and `scatter` chart types are supported.\n- The plugin works just fine with chart.js@2.5.0, however that version may have some problems handling certain color configuration (not related with the plugin). No problems have been found with chart.js@^2.6.0.\n- The plugin does not work with chart.js@3.x\n\n## Demo\nFor a better understanding of the capabilities of this plugin, please see this \n[Live Demo](https://pomgui.github.io/chartjs-plugin-regression/demo/).\n\n## Download\nThe [compressed](https://pomgui.github.io/chartjs-plugin-regression/dist/chartjs-plugin-regression-0.2.1.js)\nversion includes the regression package.\n\n## Installation\n\n    npm install --save chartjs-plugin-regression\n\n## Usage\n\nFor a single chart, it needs to be listed in plugins section. \n\n### Example:\n\n```javascript\nnew Chart(ctx, {\n  type: 'bar',\n  plugins: [\n    // This chart will use the plugin\n    ChartRegressions\n  ],\n  data: {\n    ...\n    datasets: [\n      {\n        ...\n        // Configuration of the plugin per dataset (only will be drawn the datasets with this property) \n        regressions: {\n          type: 'linear',\n          line: { color: 'red', width: 3},\n          ...\n        }\n      }\n    ]\n    ...\n  }\n});\n```\n\nAlso, it's possible to register the plugin for all the charts:\n\n```javascript\nChart.plugins.register(ChartRegressions);\n```\n\n## Configuration\n\nThe plugin has three levels of configuration:\n\n- global (for all the datasets in a chart)\n- Per dataset\n- Per section\n\nThere are common properties that the three levels share, and the priority of them are: section, dataset, and global.\n\n### Common properties\n\nCommon to the three levels of configuration.\n\n| Property | Description |\n|---|---|\n| type | Type of regression to be calculated. It can be 'copy', 'linear', 'exponential', 'power', 'polynomial', 'polynomial3', 'polynomial4', or 'logarithmic'. It also can be an array with a combination of these types, in which case the regression type with the best [_R²_](https://en.wikipedia.org/wiki/Coefficient_of_determination) will be drawn. |\n| line | Line configuration for drawing the regression. It has the following properties: `{width, color, dash}` |\n| calculation | Precision and polynomial order of the values returned by the regression calculations |\n| extendPredictions | Previous sections predictions for the current section will be drawed as dashed lines |\n| copy | Only if type=='copy'. Behavior of sections that copy other section's calculation |\n\nSome considerations:\n\n- `type`: polynomial3 and polynomial4 are pseudo-types added for convenience, they allow combinationss where the plugin will draw the regression with bigger R². Example:\n\n```javascript\n{\n  type: ['polynomial', 'polynomial3', 'polynomial4'],\n  calculation: {order 2}\n}\n```\n\n- `calculation` has the following properties:\n\n| Property | Description |\n|---|---|\n| `precision` | Determines how many decimals will have the results (default: 2). |\n| `order` | Only for `polynomial` regression type, i.e. `polynomial3` and `polynomial4` are not affected by this property. Example: _ax² + bx + c_ has order 2.  |\n\n- `copy` has the following properties:\n\n| Property | Description |\n|---|---|\n| `overwriteData` | Possible values: 'none', 'all', 'empty', or 'last'. Default: 'none'. It determines how the dataset's data will be overwritten in this section (empty: Only zero, undefined, or null data will be overwriten). **Obs.** the plugin is only prepared to overwrite numerical data arrays, e.g. `[1,2,3,...]`, scatter charts use xy data arrays, e.g. `[{x:1,y:1}, {x:2,y:2},...]`, with them the behavior is undetermined. In these cases it's better use `overwriteData: 'none'`. |\n| `minValue` | Minimum value that the predicted value can be written into the data. |\n| `maxValue` | Maximum value that the predicted value can be written into the data. |\n\n### Global\n\nThe global configuration affects all the regressions calculated for all the datasets in the chart. It contains all the common properties and the following properties:\n\n| Property | Description |\n|---|---|\n| onCompleteCalculation | Callback called when the regressions for all the datasets in a chart have been calculated |\n\nExample:\n\n```javascript\noptions: {\n  plugins: {\n    regressions: {\n      type: ['linear', 'polynomial'],\n      line: { color: 'blue', width: 3 },\n      onCompleteCalculation: function callback(chart){ ... }\n    }\n  }\n}\n```\n\n### Per Dataset\n\nIt's possible to configure the regressions per dataset. The configuration will contain all the common properties and the following properties:\n\n| Property | Description |\n|---|---|\n| sections | Array of sections of the data that shall be drawn. If not specified it's assumed `[{start:0,end:data.length-1}]` |\n\nExample:\n\n```javascript\ndatasets: [\n  {\n    ...\n    // Configuration of the plugin per dataset (only will be drawn the datasets with this property) \n    regressions: {\n      type: ['linear','exponential'],\n      line: { color: '#ff0', width: 3},\n      calculation: { precision: 5 },\n      sections: [{startIndex: 10, endIndex: 50}],\n      ...\n    }\n  }\n]\n```\n\n### Per Section\n\nEach section can be configured independently using all the common properties and the following properties:\n\n| Property | Description |\n|---|---|\n| startIndex | Start index on dataset's data. Default: 0 |\n| endIndex | End index on dataset's data. Default: data.length-1 |\n| label | Label that will be drawn in the top of the right border line. Default: xaxis' label |  \n| copy.fromSectionIndex | Copy the predictions calculated by other section (the one with index fromSectionIndex) |\n\nExample:\n\n```javascript\ndatasets: [\n  {\n    ...\n    // Configuration of the plugin per dataset (only will be drawn the datasets with this property) \n    regressions: {\n      line: { width: 3 },\n      calculation: { precision: 5 },\n      sections: [\n        {\n          type: ['linear','exponential'],\n          line: { color: 'red' },\n          startIndex: 10, \n          endIndex: 50\n        },\n        {\n          type: 'polynomial',\n          line: { color: 'green' },\n          startIndex: 50, \n          endIndex: 80,\n          calculation: { order: 4 }\n        },\n      ]\n    }\n  }\n  ...\n]\n```\n\n## API\n\n### .getDataset(chart, datasetIndex)\n\nReturns the metadata associated to one dataset used internally by the plugin to work.\n\n```javascript\nvar meta = ChartRegressions.getDataset(chart, datasetIndex);\n```\n\nThis object provides the following information:\n\n| Property | Description |\n|---|---|\n| `sections` | array of sections for each dataset (it will contain at least 1 section) |\n| `getXY(x, y)` | Returns the canvas coordinates {x,y} for the data point `x, y`. |\n| `topY` | Minimum y coordinate in the canvas. |\n| `bottomY` | Maximum y coordinate in the canvas. |\n\n### .getSections(chart, datasetIndex)\n\nReturns the sections with all the properties calculated (some with default values, or inherited from dataset's plugin configuration or the global configuration in options).\n\nThis object provides the following information:\n\n| Property | Description |\n|---|---|\n| `type` | array of regression types used to calculate and draw the section. |\n| `startIndex` | Index of the dataset's data. |\n| `endIndex` | Index of the dataset's data. |\n| `line` | Configuration used to draw the lines {color, width, dash}. |\n| `result` | Regression calculation result (see [demo](https://pomgui.github.io/chartjs-plugin-regression/demo/)) to see how to use this information. |\n\n## Events\n\n### onCompleteCalculation(chart)\n\nThe plugin provides one single event to inform when the calculation of all the regresions for a chart have been conmpleted. \n\nThis callback should be configured in the chart options.\n\nExample:\n\n```javascript\noptions: {\n  plugins: {\n    regressions: {\n      onCompleteCalculation: function callback(chart){ ... }\n    }\n  }\n}\n```\n\n## License\nThe project is released under the [ISC license](https://github.com/pomgui/chartjs-plugin-regression/blob/master/LICENSE).\n","funding_links":[],"categories":["Plugins"],"sub_categories":["Features"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomgui%2Fchartjs-plugin-regression","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpomgui%2Fchartjs-plugin-regression","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpomgui%2Fchartjs-plugin-regression/lists"}