jonathancounihan / chartjs-plugin-doughnutlabel

Chart.js plugin for doughnut chart to display text in the center

Home Page:https://ciprianciurea.github.io/chartjs-plugin-doughnutlabel/samples/index.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.

Table of contents

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: 'The subtitle',
            font: {
              size: '50'
            },
            color: 'grey'
          },
          {
            text: '$100.000',
            font: {
              size: '30'
            },
            color: 'red'
          },
          {
            text: '95%',
            font: {
              size: '45'
            },
          color: 'green'
          }
        ]
      }
    }		
  }
});

Usage without a module bundler

The plugin can be manually downloaded from the Releases page on GitHub!

<script src="chartjs-plugin-doughnutlabel.js"></script>

or use the minified version

<script src="chartjs-plugin-doughnutlabel.min.js"></script>

Development

You first need to install node dependencies (requires Node.js):

> 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

License

chartjs-plugin-doughnutlabel is available under the MIT license.

About

Chart.js plugin for doughnut chart to display text in the center

https://ciprianciurea.github.io/chartjs-plugin-doughnutlabel/samples/index.html

License:MIT License


Languages

Language:JavaScript 100.0%