Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ciprianciurea/chartjs-plugin-doughnutlabel
Chart.js plugin for doughnut chart to display text in the center
https://github.com/ciprianciurea/chartjs-plugin-doughnutlabel
chartjs chartjs-doughnut chartjs-plugin doughnut doughnut-chart javascript
Last synced: about 14 hours ago
JSON representation
Chart.js plugin for doughnut chart to display text in the center
- Host: GitHub
- URL: https://github.com/ciprianciurea/chartjs-plugin-doughnutlabel
- Owner: ciprianciurea
- License: mit
- Created: 2018-05-22T18:59:59.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-08-06T21:08:09.000Z (over 3 years ago)
- Last Synced: 2024-11-02T00:33:24.951Z (12 days ago)
- Topics: chartjs, chartjs-doughnut, chartjs-plugin, doughnut, doughnut-chart, javascript
- Language: JavaScript
- Homepage: https://ciprianciurea.github.io/chartjs-plugin-doughnutlabel/samples/index.html
- Size: 75.2 KB
- Stars: 67
- Watchers: 5
- Forks: 23
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - doughnutlabel
README
# Chart.js Doughnut plugin to allow for lines of text in the middle
Chart.js plugin module that allows to display multiple lines of text centered in the middle area of the doughnut charts
## Demo
Have a look at the [Demo page](https://ciprianciurea.github.io/chartjs-plugin-doughnutlabel/samples/index.html).## Table of contents
- [Installation](#installation)
- [Usage example](#usage)
- [Development](#development)
- [License](#license)## Installation
Install through npm:
```
npm install --save chartjs-plugin-doughnutlabel
```## Usage
```
var myDoughnutChart = new Chart(ctx, {
type: 'doughnut',
data: data,
options: {
plugins: {
doughnutlabel: {
labels: [
{
text: 'The title',
font: {
size: '60'
}
},
{
text: getTotal,
font: {
size: '50'
},
color: 'grey'
},
{
text: '$100.000',
font: {
size: '30'
},
color: 'red'
},
{
text: '95%',
font: {
size: '45'
},
color: 'green'
}
]
}
}
}
});var getTotal = function(myDoughnutChart) {
var sum = myDoughnutChart.config.data.datasets[0].data.reduce((a, b) => a + b, 0);
return `Total: ${sum}`;
}
```### Usage without a module bundler
The plugin can be manually downloaded from the
[Releases page on GitHub!](https://github.com/ciprianciurea/chartjs-plugin-doughnutlabel/releases)
``````
or use the minified version
``````
## Development
You first need to install node dependencies (requires [Node.js](https://nodejs.org/)):
> npm install
The following commands will then be available from the repository root:
> gulp lint // perform code linting
> gulp build // build dist files
> gulp build --watch // build and watch for changes
> gulp package // create an archive with dist files and samples## In Angular
For an example on how to use this plugin with angular, please check this stackblitz prototype:
[doughnutlabel plugin in angular](https://stackblitz.com/edit/angular-v9tfg7)## License
`chartjs-plugin-doughnutlabel` is available under the [MIT license](LICENSE.md).