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

Multiple colors on BarChart #8

Closed
Ghriim opened this issue Jun 14, 2012 · 5 comments
Closed

Multiple colors on BarChart #8

Ghriim opened this issue Jun 14, 2012 · 5 comments

Comments

@Ghriim
Copy link

Ghriim commented Jun 14, 2012

Hi,
I'm trying to set different colors for each bar on my bar chart.
I use Peity to show small graph with 2 bars on for a periode n and the other for perdiode n-1 so i need to have 2 differents colors for each of my bars.

I haven't find a way to do so.

Thanks.

@benpickles
Copy link
Owner

I'm afraid that's not possible at the moment. It could be though, I'll have a think about how it might be achieved.

@ryhan
Copy link

ryhan commented Jun 21, 2012

Perhaps a peity.colours array similar to the one in the pie chart implementation? Charts iterate through those colors, and some accessor function allows a dev to set it to be whatever they want?

@benpickles
Copy link
Owner

I was thinking you could pass a function which would receive the value, index and all values (much like Array#forEach - https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach callback signature) like so:

$("span").peity("bar", {
  colours: function(value, index, all) {
    // return a colour
  }
})

It could also work for other options... The only problem is that you can already pass a function which acts in a different way - http://benpickles.github.com/peity/#tips.

@benpickles
Copy link
Owner

I just pushed a branch with support for passing multiple colours to a bar chart - https://github.com/benpickles/peity/compare/multicoloured-bar-charts

Take a look and let me know what you think.

@benpickles
Copy link
Owner

I just released version 1.0.0 which includes support for setting per-bar colour.

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

3 participants