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

@uk-taniyama/chartjs-gauge-v3

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uk-taniyama/chartjs-gauge-v3

Gauge chart for chart.js v3

  • 3.0.0-alpha.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

chartjs-gauge logo chartjs-gauge

Simple gauge chart for Chart.js

Samples

Install

  • yarn install: yarn add chart.js chartjs-gauge
  • npm install: npm install --save chart.js chartjs-gauge

Configuration Options

The gauge chart is based on the Doughnut type. It defines the following additional configuration options. These options are merged with the global chart configuration options, Chart.defaults.global, to form the options passed to the chart.

NameTypeDefaultDescription
needle.radiusPercentagenumber2Needle circle radius as the percentage of the chart area width.
needle.widthPercentagenumber3.2Needle width as the percentage of the chart area width.
needle.lengthPercentagenumber80Needle length as the percentage of the interval between inner radius (0%) and outer radius (100%) of the arc.
needle.colorColor'rgba(0, 0, 0, 1)'The color of the needle.
valueLabel.displaybooleantrueIf true, display the value label.
valueLabel.formatterfunctionMath.roundReturns the string representation of the value as it should be displayed on the chart.
valueLabel.fontSizenumberundefinedThe font size of the label.
valueLabel.colorColor'rgba(255, 255, 255, 1)'The text color of the label.
valueLabel.backgroundColorColor'rgba(0, 0, 0, 1)'The background color of the label.
valueLabel.borderRadiusnumber5Border radius of the label.
valueLabel.padding.topnumber5Top padding of the label.
valueLabel.padding.rightnumber5Right padding of the label.
valueLabel.padding.bottomnumber5Bottom padding of the label.
valueLabel.padding.leftnumber5Left padding of the label.
valueLabel.bottomMarginPercentagenumber5Bottom margin as the percentage of the chart area width.

Default Options

It is common to want to apply a configuration setting to all created gauge charts. The global gauge chart settings are stored in Chart.defaults.gauge. Changing the global options only affects charts created after the change. Existing charts are not changed.

For example, to configure all line charts with radiusPercentage = 5 you would do:

Chart.defaults.gauge.needle.radiusPercentage = 5;

Dataset Properties

The gauge chart requires a value to be specified for the dataset. This is used to draw the needle for the dataset.

NameTypeDefaultDescription
valuenumberundefinedValue used for the needle.
minValuenumber0Used to offset the start value.

Example

var ctx = document.getElementById("canvas").getContext("2d");

var chart = new Chart(ctx, {
  type: 'gauge',
  data: {
    datasets: [{
      value: 0.5,
      minValue: 0,
      data: [1, 2, 3, 4],
      backgroundColor: ['green', 'yellow', 'orange', 'red'],
    }]
  },
  options: {
    needle: {
      radiusPercentage: 2,
      widthPercentage: 3.2,
      lengthPercentage: 80,
      color: 'rgba(0, 0, 0, 1)'
    },
    valueLabel: {
      display: true,
      formatter: (value) => {
        return '$' + Math.round(value);
      },
      color: 'rgba(255, 255, 255, 1)',
      backgroundColor: 'rgba(0, 0, 0, 1)',
      borderRadius: 5,
      padding: {
        top: 10,
        bottom: 10
      }
    }
  }
});

License

chartjs-gauge is available under the MIT license.

Keywords

FAQs

Package last updated on 27 Aug 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