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

Colors for bars within series? #3

Open
rbishop-bah opened this issue May 20, 2015 · 2 comments
Open

Colors for bars within series? #3

rbishop-bah opened this issue May 20, 2015 · 2 comments

Comments

@rbishop-bah
Copy link

Is there a way to assign distinct colors to bars within the same series?

@jolleekin
Copy link
Owner

The package doesn't have this feature yet. That said, I can think of two ways to enable it:

  1. Google's way: add role columns
    var data = google.visualization.arrayToDataTable([
      ['Element', 'Density', { role: 'style' }, { role: 'annotation' } ],
      ['Copper', 8.94, '#b87333', 'Cu' ],
      ['Silver', 10.49, 'silver', 'Ag' ],
      ['Gold', 19.30, 'gold', 'Au' ],
      ['Platinum', 21.45, 'color: #e5e4e2', 'Pt' ]
    ]);

https://developers.google.com/chart/interactive/docs/gallery/columnchart
2. My way: use inline objects

    var data = google.visualization.arrayToDataTable([
      ['Element', 'Density'],
      ['Copper', { 'value': 8.94, 'color': '#b87333', 'annotation': 'Cu' }],
      ['Silver', { 'value': 10.49, 'color': 'silver', 'annotation': 'Ag' }],
      ['Gold', { 'value': 19.30, 'color': 'gold', 'annotation': 'Au' }],
      ['Platinum', { 'value': 21.45, 'color': '#e5e4e2', 'annotation': 'Pt' }]
    ]);

I'm leaning toward the second option as it's more flexible. Do you have any suggestion?

@rbishop-bah
Copy link
Author

I prefer the inline maps as well as long as the supported properties are documented.

@jolleekin jolleekin reopened this Jun 9, 2017
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