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

Stacking bars with colors that make sense #7

Closed
PaulWieland opened this issue Mar 22, 2019 · 4 comments
Closed

Stacking bars with colors that make sense #7

PaulWieland opened this issue Mar 22, 2019 · 4 comments

Comments

@PaulWieland
Copy link

PaulWieland commented Mar 22, 2019

I have a stacked series of bars. I would like to force the colors of the upper bar in the stack to be a ligher/less saturated hue than the lower color. Is this possible to do?

The default looks like this using brewer.Paired12.

I want to make the pink bar a lighter blue to match the bar below it, the red bar a light blue to match the dark blue below it, and so on.

Is it possible to reference the color in a series and adjust the saturation?

@PaulWieland
Copy link
Author

I discovered a work around - You can access the global color schemes that come with the plugin like this:

var _chartcolors = Chart["colorschemes"].office.Aspect6;

And then assign them to the data series manually:

var i = 0; // in place of a for loop to build the series
//...
series1.backgroundColor = Color(window._chartcolors[i]).hexString();
//...
series2.backgroundColor = Color(window._chartcolors[i]).lighten(.5).hexString();

In this scenario we have series 2 stacked on top of series 1. Series 1 is the base color from the colors plugin, while series 2 is a lighter version of the same color.

@JohnArcher
Copy link
Contributor

Could you also provide a screenshot for how it looks now working? Thanks!

@PaulWieland
Copy link
Author

Here's what it looks like, though I have changed the chart theme to a completely custom color set: https://i.imgur.com/ba62tBg.png

@JohnArcher
Copy link
Contributor

Very nice, now I understand. Looks cool. Thank you!

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