{"id":13701923,"url":"https://github.com/kurkle/chartjs-plugin-autocolors","last_synced_at":"2025-04-04T10:05:28.488Z","repository":{"id":40044580,"uuid":"270899147","full_name":"kurkle/chartjs-plugin-autocolors","owner":"kurkle","description":"Automatic color generation for Chart.js","archived":false,"fork":false,"pushed_at":"2024-10-14T03:32:14.000Z","size":681,"stargazers_count":64,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-20T17:05:01.996Z","etag":null,"topics":["automatic","chart","colors","plugin"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/kurkle.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":"2020-06-09T04:03:53.000Z","updated_at":"2024-10-07T04:22:34.000Z","dependencies_parsed_at":"2024-01-14T19:14:10.987Z","dependency_job_id":"5230f1d8-99c7-4b50-84f3-0b56ad502886","html_url":"https://github.com/kurkle/chartjs-plugin-autocolors","commit_stats":{"total_commits":71,"total_committers":8,"mean_commits":8.875,"dds":0.323943661971831,"last_synced_commit":"7220dfcc8dd8724c10dc78f63bc94fc52bc8bf60"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurkle%2Fchartjs-plugin-autocolors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurkle%2Fchartjs-plugin-autocolors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurkle%2Fchartjs-plugin-autocolors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kurkle%2Fchartjs-plugin-autocolors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kurkle","download_url":"https://codeload.github.com/kurkle/chartjs-plugin-autocolors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247157046,"owners_count":20893202,"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":["automatic","chart","colors","plugin"],"created_at":"2024-08-02T21:00:27.580Z","updated_at":"2025-04-04T10:05:28.463Z","avatar_url":"https://github.com/kurkle.png","language":"JavaScript","funding_links":[],"categories":["Plugins"],"sub_categories":["Styling"],"readme":"# chartjs-plugin-autocolors\n\n*Automatic color generation for [Chart.js](https://www.chartjs.org)*\n\n![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/kurkle/chartjs-plugin-autocolors/ci.yml)\n\nThe generation is based on Janus Troelsen's answer at [Stack Overflow](https://stackoverflow.com/a/13781114/10359775).\n\nThis plugin requires Chart.js 3.0.0 or later. Could work with v2, but it is not supported.\n\n**NOTE** the plugin does not automatically register.\n\n## Example\n\n![Example chart](https://github.com/kurkle/chartjs-plugin-autocolors/raw/main/sample.png \"Example chart\")\n\n## Installation\n\nNPM:\n\n```bash\nnpm i --save chartjs-plugin-autocolors\n```\n\nCDN:\n\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/chartjs-plugin-autocolors\"\u003e\u003c/script\u003e\n```\n\n## Usage\n\n### loading\n\nESM\n\n```js\nimport autocolors from 'chartjs-plugin-autocolors';\n```\n\nCDN\n\n```js\nconst autocolors = window['chartjs-plugin-autocolors'];\n```\n\n### Registering\n\nAll charts\n\n```js\nChart.register(autocolors);\n```\n\nSingle chart\n\n```js\nconst chart = new Chart(ctx, {\n  // ...\n  plugins: [\n    autocolors\n  ]\n});\n```\n\n### Disabling (when registered for all charts)\n\nIf registered globally, it might be desirable to disable the autocolors for some charts\n\n```js\nconst chart = new Chart(ctx, {\n  // ...\n  options: {\n    plugins: {\n      autocolors: {\n        enabled: false\n      }\n    }\n  }\n});\n```\n\n### Mode\n\n**NOTE:** `'dataset'` mode does not work properly for **Pie / Doughnut** charts, so using `'data'` mode with those charts is advised.\n\nThere are two modes, `'dataset'` (default) `'data'` and `'label'`\n\n- In `'dataset'` mode, a new color is picked for each dataset.\n- In `'data'` mode, an array of colors, equivalent to the length of data is provided for each dataset.\n- In `'label'` mode, color is picked for each different dataset label.\n\n```js\nconst chart = new Chart(ctx, {\n  // ...\n  options: {\n    plugins: {\n      autocolors: {\n        mode: 'data'\n      }\n    }\n  }\n});\n```\n\n### Customize\n\nA `customize` function can be provided to customize the generated colors.\nThe function is expected to return object containing `background` and `border` properties,\nwith values acceptable as colors by Chart.js.\n\n```js\nconst lighten = (color, value) =\u003e Chart.helpers.color(color).lighten(value).rgbString();\n\nconst chart = new Chart(ctx, {\n  // ...\n  options: {\n    plugins: {\n      autocolors: {\n        customize(context) {\n          const colors = context.colors;\n          return {\n            background: lighten(colors.background, 0.5),\n            border: lighten(colors.border, 0.5)\n          };\n        }\n      }\n    }\n  }\n});\n```\n\n### Offset\n\n`offset` option can be used to offset the color generation by a number of colors.\n\n```js\nconst chart = new Chart(ctx, {\n  // ...\n  options: {\n    plugins: {\n      autocolors: {\n        offset: 5\n      }\n    }\n  }\n});\n```\n\n### Repeat\n\nSometimes you might need to color multiple adjacent datasets with same color. The `repeat` option is for that use case.\n\n\n```js\nconst chart = new Chart(ctx, {\n  // ...\n  options: {\n    plugins: {\n      autocolors: {\n        repeat: 2\n      }\n    }\n  }\n});\n```\n\n## Browser compatibility\n\nThis plugin uses a generator function, so it is not compatible with Internet Explorer.\n\n## License\n\n`chartjs-plugin-autocolors.js` is available under the [MIT license](https://github.com/kurkle/chartjs-plugin-autocolors/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurkle%2Fchartjs-plugin-autocolors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkurkle%2Fchartjs-plugin-autocolors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkurkle%2Fchartjs-plugin-autocolors/lists"}