npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

chartjs-plugin-line-value-label

v2.1.12

Published

Chart.js plugin for displaying title labels on line charts

Readme

npm version license

🎨 Demo

📦 Installation

Install the plugin via npm:

npm install chartjs-plugin-line-value-label

Or using yarn:

yarn add chartjs-plugin-line-value-label

🚀 Quick Start

import { Chart, registerables } from 'chart.js';
import LineValueLabelPlugin from 'chartjs-plugin-line-value-label';

Chart.register(...registerables, LineValueLabelPlugin);

const ctx = document.getElementById('myChart').getContext('2d');
const chart = new Chart(ctx, {
  type: 'line',
  data: {
    labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May'],
    datasets: [{
      label: 'Sales',
      data: [12, 19, 15, 25, 22]
    }]
  },
  options: {
    plugins: {
      lineValueLabel: {
        enabled: true,
        text: 'Max Value',
        dataset: {
          label: 'Sales'
        },
        position: 'left',
        style: {
          color: '#21B800',
          backgroundColor: '#F5F5F5'
        }
      }
    }
  }
});

⚙️ Configuration Options

Plugin Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | enabled | boolean | true | Enable or disable the plugin | | text | string | required | The text to display in the label | | dataset | object | required | Configuration for targeting a dataset | | position | 'left' \| 'right' | 'left' | Position of the label relative to the chart | | offset | number | 0 | Horizontal offset in pixels | | style | object | {} | Style options for the label |

Dataset Configuration

| Option | Type | Description | |--------|------|-------------| | label | string | Target dataset by its label (alternative to index) | | index | number | Target dataset by its index (alternative to label) |

Style Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | color | string | '#21B800' | Text color | | backgroundColor | string | '#F5F5F5' | Background color of the label badge | | padding | number | 6 | Padding around the text (in pixels) | | radius | number | 6 | Border radius of the label badge (in pixels) | | font | string | '12px sans-serif' | Font specification (CSS font property) |

📚 Examples

Basic Usage

Custom Styling

options: {
  plugins: {
    lineValueLabel: {
      text: 'Maximum',
      dataset: { index: 0 },
      position: 'left',
      offset: 10,
      style: {
        color: '#FFFFFF',
        backgroundColor: '#4F46E5',
        padding: 10,
        radius: 8,
        font: 'bold 14px Arial'
      }
    }
  }
}

Multiple Labels (Using Multiple Charts)

// Chart 1 - Label on left
const chart1 = new Chart(ctx1, {
  // ... config
  options: {
    plugins: {
      lineValueLabel: {
        text: 'Start Value',
        dataset: { index: 0 },
        position: 'left'
      }
    }
  }
});

// Chart 2 - Label on right
const chart2 = new Chart(ctx2, {
  // ... config
  options: {
    plugins: {
      lineValueLabel: {
        text: 'End Value',
        dataset: { index: 0 },
        position: 'right'
      }
    }
  }
});

Targeting by Dataset Index

options: {
  plugins: {
    lineValueLabel: {
      text: 'Dataset 0 Maximum',
      dataset: { index: 0 }, // First dataset
      position: 'left'
    }
  }
}

Targeting by Dataset Label

options: {
  plugins: {
    lineValueLabel: {
      text: 'Sales Peak',
      dataset: { label: 'Sales' }, // Dataset with label "Sales"
      position: 'right'
    }
  }
}

📝 TypeScript Support

The package includes full TypeScript definitions:

import LineValueLabelPlugin, { LineValueLabelOptions } from 'chartjs-plugin-line-value-label';

const options: LineValueLabelOptions = {
  enabled: true,
  text: 'Max Value',
  dataset: {
    label: 'Sales'
  },
  position: 'left',
  style: {
    color: '#21B800',
    backgroundColor: '#F5F5F5',
    padding: 6,
    radius: 6,
    font: '12px sans-serif'
  }
};

🤝 Compatibility

  • Chart.js: ^4.5.0
  • TypeScript: ^5.0.0 (for TypeScript users)

Made with ❤️ for the Chart.js community