Reputation: 27
I'd like to change the color of the graph at the top of the limit line. We've now implemented changing the color of chart bars across the limit line. But what I want to do is change the color of the chart where it crosses the limit line.
Upvotes: 0
Views: 396
Reputation: 356
I'm assuming you are using a BarChart
here
It turns out that this response was addressing your needs, maybe I can try to clarify a bit more:
It seems that a normal BarChart data no longer suits your need. In order to stack different colours in the same bar, you'll need what's called a StackedBarChart
For using the aforementioned StackedBarChart
(which is almost the same as the BarChart
) you need to adapt the data and the colours for the data:
So here, A value cannot be higher than your limit. Let's give an example:
Limit = 10
Total value = 12
A = 10
B = 2
Then, you should input your data as follows (assuming the first bar starts at X=0):
BarEntry stackedEntry = new BarEntry(0f, new float[] { 10, 2 });
dataSet.color = listOf(LightBlue, Darkblue)
(kotlin code)
The dataSet here, is the object with all the BarEntries we have defined above.
I hope this clarifies and solves your needs, good luck :)
Upvotes: 1