3.0.7 • Published 9 months ago

@mauro.panzeri/chartjs-plugin-doughnutlabel v3.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

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: 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!

<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

In Angular

For an example on how to use this plugin with angular, please check this stackblitz prototype: doughnutlabel plugin in angular

License

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

acorn-jsxansi-colorsajvacornansi-regexansi-stylesastral-regexargparsebabel-plugin-dynamic-import-nodearray-unionbabel-plugin-polyfill-corejs3babel-plugin-polyfill-corejs2babel-plugin-polyfill-regeneratorbalanced-matchbrowserslistbrace-expansionbracescall-bindbuiltin-modulesbuffer-fromchart.jscaniuse-litecallsiteschalkcommandercolor-convertcolor-namecolorettecommondircore-js-compatconcat-mapconvert-source-mapcross-spawndebugdeepmergedoctrinedeep-isdir-globdefine-propertiesenquirerelectron-to-chromiumescaladeemoji-regexescape-string-regexpeslint-scopeeslint-utilseslintespreeeslint-visitor-keysesprimaesqueryesrecurseestree-walkerestraversefast-deep-equalesutilsfast-globfast-json-stable-stringifyfast-levenshteinfile-entry-cachefastqflat-cacheflattedfill-rangefs.realpathgensyncfunction-bindglobfunctional-red-black-treeget-intrinsicglobalsglob-parentglobbyhashas-flaghas-symbolsignoreimport-freshinflightis-core-moduleinheritsis-extglobis-fullwidth-code-pointis-globis-referenceis-modulejest-workeris-numberisexejs-yamljs-tokensjsescjson-stable-stringify-without-jsonifyjson5json-schema-traverselodash.clonedeeplevnlodash.mergelodash.debouncelru-cachelodash.truncatemerge2micromatchmagic-stringmerge-streamminimistminimatchnatural-comparemsnode-releasesobject.assignobject-keysoptionatoroncepath-is-absoluteparent-modulepath-keypath-parsepicomatchpath-typeprogressprelude-lspunycodequeue-microtaskrandombytesregenerateregenerate-unicode-propertiesregexppregenerator-transformregexpu-coreregjsgenregjsparserregenerator-runtimerequire-from-stringresolve-fromresolvereusifyrun-parallelrimrafsemverserialize-javascriptsafe-buffershebang-commandshebang-regexslashslice-ansisource-mapsourcemap-codecsource-map-supportsprintf-jsstring-widthstrip-json-commentsterserstrip-ansisupports-colortext-tabletableto-fast-propertiesto-regex-rangetsutilsunicode-canonical-property-names-ecmascripttype-checkunicode-match-property-value-ecmascriptunicode-match-property-ecmascripttype-festv8-compile-cacheunicode-property-aliases-ecmascripturi-jswhichimurmurhashwrappyword-wrapyallist
3.0.7

9 months ago

3.0.6

2 years ago

3.0.5

2 years ago

3.0.4

2 years ago