Skip to content

How to merge three different bar charts into one  #556

Not planned

Description

@DannyThomas2

Hi,

I've been trying to look online on how to achieve having three different bar charts into one chart. Is this even possible?

I want to get something that look like this:
chart

Activity

  1. jkotova commented on Sep 24, 2020

    @jkotova

    Hi, you just need to pass datasets as an array:

    Below is the data object for this chart:

    grouped_bars

    const data = {
      labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
      datasets: [
        {
          label: 'My First dataset',
          backgroundColor: 'rgba(255,99,132,0.2)',
          borderColor: 'rgba(255,99,132,1)',
          borderWidth: 1,
          hoverBackgroundColor: 'rgba(255,99,132,0.4)',
          hoverBorderColor: 'rgba(255,99,132,1)',
          data: [65, 59, 80, 81, 56, 55, 40],
        },
        {
          label: 'My Second dataset',
          backgroundColor: 'rgba(255, 205, 86, 0.2)',
          borderColor: 'rgb(255, 205, 86)',
          borderWidth: 1,
          hoverBackgroundColor: 'rgba(255, 205, 86, 0.4)',
          hoverBorderColor: 'rgb(255, 205, 86)',
          data: [45, 69, 85, 75, 26, 65, 45],
        },
        {
          label: 'My Third dataset',
          backgroundColor: 'rgba(153, 102, 255, 0.2)',
          borderColor: 'rgb(153, 102, 255)',
          borderWidth: 1,
          hoverBackgroundColor: 'rgba(153, 102, 255, 0.4)',
          hoverBorderColor: 'rgb(153, 102, 255)',
          data: [85, 49, 88, 86, 49, 45, 48],
        },
      ],
    };
  2. DannyThomas2 commented on Sep 24, 2020

    @DannyThomas2
    Author

    Hey thanks for the reply! Unfortunately that isn't what I'm trying to accomplish. I need the datasets for each label to be different and not linked to each other. So for example ill have for the label department ['corporate':10, 'hr':14 ....] and for the label gender ill have ['male':123, 'female':31] and lastly for age it'll be ['20-30':31, '31-44':42]. These three labels have their own data associated with them, I'm just trying to have all three in one bar chart, is that possible?

  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