modern_charts
modern_charts copied to clipboard
Colors for bars within series?
Is there a way to assign distinct colors to bars within the same series?
The package doesn't have this feature yet. That said, I can think of two ways to enable it:
- 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?
I prefer the inline maps as well as long as the supported properties are documented.