You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

chartjs-plugin-center-text-doughnut

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartjs-plugin-center-text-doughnut

Chart.js plugin to display centered text within a doughnut chart

1.0.2
latest
Source
npmnpm
Version published
Weekly downloads
18
-45.45%
Maintainers
1
Weekly downloads
 
Created
Source

Overview

Greatly adaptive Chart.js plugin that provides proper text centering within Doughnut Chart, even if additional options (for example: legend) are included.

Requires Chart.js 3.x.

Installation

npm i chartjs-plugin-center-text-doughnut

Usage

import ChartDoughnutCenterTextPlugin from 'chartjs-plugin-center-text-doughnut';

Once imported, the plugin needs to be registered.

var chart = new Chart(ctx, {
  plugins: [ChartDoughnutCenterTextPlugin],
  options: {
    // ...
  }
})

The plugin options can be changed in order to customize text and its style.

new Chart(ctx, {
  plugins: [
    // ... other plugins
    ChartDoughnutCenterTextPlugin
  ],
  options: {
    // ... other options
    plugins: {
      doughnutCenterText: {
        text: "Test",
        color: '#FF0000',
        font: {
          family: 'Arial',
          size: '14px',
          weight: 700,
          style: 'italic', 
          variant: 'small-caps',
        }
      }
    }
  }
});

Development

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

npm install

The following commands will then be available from the repository root:

npm run build            // build dist files
npm run build:dev        // build and watch for changes

License

chartjs-plugin-center-text-doughnut is available under the MIT license.

Keywords

chart.js

FAQs

Package last updated on 15 Nov 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts