Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chartjs-plugin-datalabels

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chartjs-plugin-datalabels

Chart.js plugin to display labels on data elements

  • 2.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
608K
increased by8.41%
Maintainers
2
Weekly downloads
 
Created

What is chartjs-plugin-datalabels?

The chartjs-plugin-datalabels package is a plugin for Chart.js that allows you to display labels on data points in your charts. It provides a variety of customization options for positioning, styling, and formatting the labels, making it easier to enhance the readability and presentation of your data visualizations.

What are chartjs-plugin-datalabels's main functionalities?

Basic Label Display

This feature allows you to display basic labels on your chart's data points. The labels are displayed in white color by default.

const chart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    plugins: {
      datalabels: {
        display: true,
        color: 'white'
      }
    }
  }
});

Custom Label Formatting

This feature allows you to customize the format of the labels. In this example, the labels are formatted to display a percentage sign after the value.

const chart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    plugins: {
      datalabels: {
        formatter: function(value, context) {
          return value + '%';
        }
      }
    }
  }
});

Label Positioning

This feature allows you to control the positioning of the labels. In this example, the labels are anchored to the end of the data points and aligned to the top.

const chart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    plugins: {
      datalabels: {
        anchor: 'end',
        align: 'top'
      }
    }
  }
});

Label Styling

This feature allows you to style the labels. In this example, the labels are styled with a blue color and a bold font of size 14.

const chart = new Chart(ctx, {
  type: 'bar',
  data: data,
  options: {
    plugins: {
      datalabels: {
        color: 'blue',
        font: {
          size: 14,
          weight: 'bold'
        }
      }
    }
  }
});

Other packages similar to chartjs-plugin-datalabels

Keywords

FAQs

Package last updated on 10 Dec 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc