Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to group in bar chart? #804

Open
SoftCircuits opened this issue May 27, 2022 · 4 comments
Open

Is it possible to group in bar chart? #804

SoftCircuits opened this issue May 27, 2022 · 4 comments

Comments

@SoftCircuits
Copy link

(BTW, it's currently not possible to view any of the samples on JS Bin. The message "This bin needs a pro account" is displayed.)

But we have the need to group bar charts. Specifically, I want two show two related bars next to each other. Is this supported?

@pierresh
Copy link

Hello,

Yes, you can play with the options barGap and barSizeRatio.

With barSizeRatio: 0.7 and barGap: 0, you should get something like:

WX20220528-104511

@SoftCircuits
Copy link
Author

SoftCircuits commented May 28, 2022

@pierresh Thanks, but I don't see anything about barSizeRatio or barGap on the documentation page. Any chance you could post a simple example?

@pierresh
Copy link

Not all the options are described in the documentation, you can see them in the file lib/morris.bar.coffee around line 17.

Here is an example:

Morris.Bar({
      element: 'chart_hist_3',
      data: [
        {team: 'Brazil', nb: 5, avg: 2.2},
        {team: 'Italy', nb: 4, avg: 1.9},
        {team: 'Germany', nb: 4, avg: 2.1},
        {team: 'Uruguay', nb: 2, avg: 1.4},
        {team: 'Argentina', nb: 2, avg: 1.8},
      ],
      xkey: 'team',
      ykeys: ['nb', 'avg'],
      barSizeRatio: 0.7,
      barGap: 0,
      dataLabels: false,
      labels: ['Editions Wins', 'Average Points'],
    });

@SoftCircuits
Copy link
Author

Thanks, I'll play with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants