{"id":13475685,"url":"https://github.com/valor-software/ng2-charts","last_synced_at":"2025-05-13T21:03:00.752Z","repository":{"id":37768421,"uuid":"41480724","full_name":"valor-software/ng2-charts","owner":"valor-software","description":"Beautiful charts for Angular based on Chart.js","archived":false,"fork":false,"pushed_at":"2025-01-06T11:46:03.000Z","size":56134,"stargazers_count":2377,"open_issues_count":70,"forks_count":575,"subscribers_count":67,"default_branch":"master","last_synced_at":"2025-04-30T06:03:03.458Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://valor-software.github.io/ng2-charts/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/valor-software.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-08-27T10:34:52.000Z","updated_at":"2025-04-29T15:36:01.000Z","dependencies_parsed_at":"2023-11-09T11:17:55.128Z","dependency_job_id":"3c0bec2f-9111-4b11-acad-7a0a044506be","html_url":"https://github.com/valor-software/ng2-charts","commit_stats":{"total_commits":451,"total_committers":38,"mean_commits":"11.868421052631579","dds":0.8314855875831486,"last_synced_commit":"b8bdfb58829369a7963ac7bfe5b424b6ae81cdaa"},"previous_names":[],"tags_count":90,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valor-software%2Fng2-charts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valor-software%2Fng2-charts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valor-software%2Fng2-charts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/valor-software%2Fng2-charts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/valor-software","download_url":"https://codeload.github.com/valor-software/ng2-charts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251966558,"owners_count":21672675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-07-31T16:01:22.578Z","updated_at":"2025-05-06T02:55:12.108Z","avatar_url":"https://github.com/valor-software.png","language":"TypeScript","funding_links":["https://www.buymeacoffee.com/santam)!"],"categories":["TypeScript","Uncategorized","Data","Third Party Components","Components","Complete projects","Awesome Angular [![Awesome TipeIO](https://img.shields.io/badge/Awesome%20Angular-@TipeIO-6C6AE7.svg)](https://github.com/gdi2290/awesome-angular) [![Awesome devarchy.com](https://img.shields.io/badge/Awesome%20Angular-@devarchy.com-86BDC1.svg)](https://github.com/brillout/awesome-angular-components)","UI","Integrations"],"sub_categories":["Uncategorized","Charts","Charts/Diagram","Angular \u003ca id=\"angular\"\u003e\u003c/a\u003e","- Charts/Diagram","JavaScript"],"readme":"# ng2-charts [![npm version](https://badge.fury.io/js/ng2-charts.svg)](http://badge.fury.io/js/ng2-charts) [![npm downloads](https://img.shields.io/npm/dm/ng2-charts.svg)](https://npmjs.org/ng2-charts) ![Travis CI](https://travis-ci.org/valor-software/ng2-charts.svg?branch=development) [slack](https://ngx-home.slack.com)\n\nBeautiful charts for Angular based on Chart.js\n\n# Usage \u0026 Demo\n\nSamples using `ng2-charts`\n\nhttps://valor-software.com/ng2-charts/\n\n---\n\n### Installation\n\nYou can install **_ng2-charts_** by using the Angular CLI:\n\n```bash\nng add ng2-charts\n```\n\nThe required packages will be automatically installed, and your `app.config.ts` will be updated with the required\nchanges to start using the library right away.\n\n#### Manual install through package managers\n\n1. You can install **_ng2-charts_** using npm:\n\n   ```bash\n   npm install ng2-charts --save\n   ```\n\n   or yarn:\n\n   ```bash\n   yarn add ng2-charts --save\n   ```\n\n2. You will also need to install and include `Chart.js` library in your application (it is a peer dependency of this\n   library, more info can be found in the\n   official `chart.js` [documentation](http://www.chartjs.org/docs/#getting-started))\n\n   ```bash\n   npm install chart.js --save\n   ```\n\n   or with yarn:\n\n   ```bash\n   yarn add  chart.js --save\n   ```\n\n3. Import the directive in your standalone component:\n\n   ```typescript\n   import { BaseChartDirective } from 'ng2-charts';\n\n   @Component({\n     standalone: true,\n     imports: [BaseChartDirective],\n   })\n   export class MyComponent {}\n   ```\n\n4. Provide a configuration, typically in your `main.ts`:\n\n   ```typescript\n   import { provideCharts, withDefaultRegisterables } from 'ng2-charts';\n\n   bootstrapApplication(AppComponent, {\n     providers: [provideCharts(withDefaultRegisterables())],\n   }).catch((err) =\u003e console.error(err));\n   ```\n\n   Alternatively, include a minimal configuration to reduce the bundle size, eg:\n\n   ```typescript\n   provideCharts({ registerables: [BarController, Legend, Colors] });\n   ```\n\n   Or in your AppModule:\n\n   ```typescript\n   import { provideCharts, withDefaultRegisterables } from 'ng2-charts';\n\n   @NgModule({\n     providers: [provideCharts(withDefaultRegisterables())],\n     bootstrap: [AppComponent],\n   })\n   export class AppModule {}\n   ```\n\n### Angular version compatibility table\n\n\u003ctable role=\"table\"\u003e\n \u003ctbody\u003e\u003ctr\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd colspan=\"7\"\u003eng2-chart version\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003eAngular version\u003c/td\u003e\n  \u003ctd\u003ev1.x\u003c/td\u003e\n  \u003ctd\u003ev2.x\u003c/td\u003e\n  \u003ctd\u003ev3.x\u003c/td\u003e\n  \u003ctd\u003ev4.x\u003c/td\u003e\n  \u003ctd\u003ev5.x\u003c/td\u003e\n  \u003ctd\u003ev6.x\u003c/td\u003e\n  \u003ctd\u003ev7.x\u003c/td\u003e\n  \u003ctd\u003ev8.x\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e2 - 9\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e10\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e11\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e12\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e13\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e14\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e15\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e16\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e17\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e18\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\n \u003ctr\u003e\n  \u003ctd\u003e19\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003ctd\u003e✓\u003c/td\u003e\n \u003c/tr\u003e\n\n\u003c/tbody\u003e\u003c/table\u003e\n\n## API\n\n### Chart types\n\nThere is one directive for all chart types: `baseChart`, and there are 8 types of charts: `line`, `bar`, `radar`, `pie`\n, `polarArea`, `doughnut`, `bubble` and `scatter`. You can use the directive on a `canvas` element as follows:\n\n```html\n\u003ccanvas baseChart [data]=\"barChartData\" [options]=\"barChartOptions\" [type]=\"'bar'\"\u003e \u003c/canvas\u003e\n```\n\n### Properties\n\n**Note**: For more information about possible options please refer to original [chart.js](http://www.chartjs.org/docs)\ndocumentation\n\n- `type`: (`ChartType`) - indicates the type of chart, it can be: `line`, `bar`, `radar`, `pie`, `polarArea`, `doughnut`\n  or any custom type added to Chart.js\n- `data`: (`ChartData\u003cTType, TData, TLabel\u003e`) - the whole data structure to be rendered in the chart. Support different\n  flexible formats and parsing options,\n  see [here](https://www.chartjs.org/docs/latest/general/data-structures.html#object). In alternative, and depending on\n  the `type` of your chart, you can use the `labels` and `datasets` properties to specify individual options.\n- `labels`: (`TLabel[]`) - Datasets labels. It's necessary for charts: `line`, `bar` and `radar`. And just labels (on\n  hover) for charts: `polarArea`, `pie` and `doughnut`. Labels are matched in order with the `datasets` array.\n- `datasets`: (` ChartDataset\u003cTType, TData\u003e[]`) - Same as the `datasets` property of the `data` input.\n  See [here](https://www.chartjs.org/docs/latest/general/data-structures.html#dataset-configuration) for details.\n- `options`: (`ChartOptions\u003cTType\u003e`) - chart options (as\n  per [chart.js documentation](https://www.chartjs.org/docs/latest/general/options.html)).\n- `legend`: (`boolean = false`) - if true, chart legend is shown.\n\n### Events\n\n- `chartClick`: fires when click on a chart has occurred, returns information regarding active points and labels\n- `chartHover`: fires when mousemove (hover) on a chart has occurred, returns information regarding active points and\n  labels\n\n### Colors\n\nBy default, this library uses the colors as [defined by Chart.js](https://www.chartjs.org/docs/latest/general/colors.html#default-color-palette).\nIf you need more control on colors, eg: generating colors on the fly, see [the advanced color palettes](https://www.chartjs.org/docs/latest/general/colors.html#advanced-color-palettes).\n\n### Dynamic Theming\n\nThe `ThemeService` allows clients to set a structure specifying colors\noverride settings. This service may be called when the dynamic theme changes, with colors which fit the theme. The\nstructure is interpreted as an override, with special functionality when dealing with arrays. Example:\n\n```typescript\ntype Theme = 'light-theme' | 'dark-theme';\n\nprivate _selectedTheme: Theme = 'light-theme';\npublic get selectedTheme(){\n  return this._selectedTheme;\n}\n\npublic set selectedTheme(value){\n  this._selectedTheme = value;\n  let overrides: ChartOptions;\n  if (this.selectedTheme === 'dark-theme') {\n    overrides = {\n      legend: {\n        labels: { fontColor: 'white' }\n      },\n      scales: {\n        xAxes: [ {\n          ticks: { fontColor: 'white' },\n          gridLines: { color: 'rgba(255,255,255,0.1)' }\n        } ],\n        yAxes: [ {\n          ticks: { fontColor: 'white' },\n          gridLines: { color: 'rgba(255,255,255,0.1)' }\n        } ]\n      }\n    };\n  } else {\n    overrides = {};\n  }\n  this.themeService.setColorschemesOptions(overrides);\n}\n\nconstructor(private themeService: ThemeService\u003cAppChartMetaConfig\u003e){\n}\n\nsetCurrentTheme(theme: Theme){\n  this.selectedTheme = theme;\n}\n```\n\nThe `overrides` object has the same type as the chart options object `ChartOptions`, and wherever a simple field is\nencountered it replaces the matching field in the `options` object. When an array is encountered (as in the `xAxes`\nand `yAxes` fields above), the single object inside the array is used as a template to override all array elements in\nthe matching field in the `options` object. So in the case above, every axis will have its ticks and gridline colors\nchanged.\n\n## Troubleshooting\n\nPlease follow this guidelines when reporting bugs and feature requests:\n\n1. Use [GitHub Issues](https://github.com/valor-software/ng2-charts/issues) to report bugs and feature requests.\n2. Please **always** provide an example project and write steps to reproduce the error. That way we can focus on fixing the bug, not scratching our\n   heads trying to reproduce it.\n\nThanks for understanding!\n\n### License\n\nThe MIT License (see the [LICENSE](https://github.com/valor-software/ng2-charts/blob/master/LICENSE) file for the full\ntext)\n\nIf you like this library and want to say thanks, consider [buying me a coffee](https://www.buymeacoffee.com/santam)!\n\n[//]: # 'super hidden section about running `npm test:ci` in win11 wsl2'\n[//]: # 'export CHROME_BIN=/mnt/c/Program\\\\ Files\\\\ (x86)/Google/Chrome/Application/chrome.exe'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalor-software%2Fng2-charts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalor-software%2Fng2-charts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalor-software%2Fng2-charts/lists"}