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

Stacked bar chart valueColors #945

Open
dxclancy opened this issue Apr 12, 2016 · 3 comments
Open

Stacked bar chart valueColors #945

dxclancy opened this issue Apr 12, 2016 · 3 comments
Assignees
Milestone

Comments

@dxclancy
Copy link

Hi, I'm not sure the intent of Charts, so I'm not sure if this is a bug or just an implementation detail.

Say you have a stacked bar chart with 3 values per bar, and want to control the text color of the value within each part.

BarChartDataSet dataSet; 
(...)
dataSet.colors = @[[UIColor yellowColor], [UIColor purpleColor], [UIColor darkRedColor]];
// chosen to contrast with above, as black will be hard to read on purple and darkRed
dataSet.valueColors = @[[UIColor blackColor], [UIColor whiteColor], [UIColor whiteColor]];

In the current implementation you end up with the 1st bar drawing black text over yellow, purple, and darkRed, and the 2nd bar drawing white over yellow, purple, and darkRed.

What I would like is to have those colors rotated per bar part. So that black text is drawn over yellow, white over purple, white over darkRed.

For bar charts, this seems more logical to me then the colors applying to the entire bar, but I'm sure I haven't considered all the cases, or perhaps I am missing some other configuration that accomplishes this.

The behavior that I describe as desired above can be accomplished in HorizontalBarChartRenderer by changing this:

                                drawValue(context: context,
                                    value: valueText,
                                    xPos: x,
                                    yPos: y + yOffset,
                                    font: valueFont,
                                    align: textAlign,
                                    color: dataSet.valueTextColorAt(j))
to this:
                                color: dataSet.valueTextColorAt(k))
@liuxuan30
Copy link
Member

I see your point. you want to label has different color for each segment, and each bar has the same pattern. Currently the same bar will have the same text color, not the segment. Currently you can change to k on your side. We need time on this.

However, people may want what the current is. Seems we could add more switches?
@danielgindi what you think?

@danielgindi
Copy link
Collaborator

I'm not sure. @PhilJay ? 🎱

@jjatie jjatie closed this as completed Apr 1, 2018
@dxclancy
Copy link
Author

dxclancy commented Apr 2, 2018

Curious why this was closed? Issue has not been addressed.

@jjatie jjatie reopened this Apr 2, 2018
@jjatie jjatie self-assigned this Apr 2, 2018
@jjatie jjatie added this to the 4.0.0 milestone Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants