Skip to content

each labels contains only 1 bar of data #498

Not planned

Description

@jacky-ew

may i know how to generate a bar chart with each labels contains its own bar of data

eg :

data = {
    labels: ["apple", "orange", "pear"],
    datasets: **this is the part where i stucked**
}

i want to have 3 bars displaying :
apples -> a bar (10 apples),
orange -> a bar (6 oranges),
pear -> a bar (4 pears)

Activity

  1. nicholasess commented on Apr 18, 2020

    @nicholasess

    @jacky-ew if you want to show labels without hover, you can use this lib
    https://www.npmjs.com/package/chartjs-plugin-datalabels

  2. Arantiryo commented on May 13, 2022

    @Arantiryo
    Collaborator

    Hi @jacky-ew 👋

    If I understand your problem correctly, you can just set up datasets like so:

    datasets: [
        {
          label: 'Fruit data',
          data: [10, 6, 4],
          backgroundColor: 'rgba(255, 99, 132, 0.5)',
          ...
        },
      ],

    to achieve desired result.

  3. dangreen commented on Nov 30, 2026

    @dangreen
    Collaborator

    Closing: this is a usage question rather than a bug report or a feature request. The docs of the wrapper are at https://react-chartjs-2.js.org and the chart options are described in the Chart.js docs: https://www.chartjs.org/docs/latest/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions