-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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 not working properly? #2683
Comments
I do not really understand what you do with For example
And
|
@tuantmdev I understand exactly what you're doing, but as mentioned in my description, my And the At index So then in this code:
What I tried to do was, the Therefore, if Since index In other words, in my However, the point of my question was how does the I was quoting what you said in another issue: "The value of x you pass when init BarChartDataEntry should be the same the value of formatter method". If what you said is what I think you said, then when I wish someone can help me understand what is happening, as I'm really stuck on this part and unsure how to fix it. |
I'm really confused, how and when does
stringForValue
actually work?I thought I knew how it is being called but I guess I don't.
I'm trying to combine data into one stacked bar if the x-axis values are the same, but I'm confused on when
stringForValue
is called to format the x-axis labels.This is currently what I'm seeing:
I was somewhat able to combine the data from the date label
08/06/17
because there's 2 data for that x-axis date (as can be seen in the table below), but the upper red part should be5.66
, not8.66
. Somehow, it is adding3.00
to5.66
to make8.66
.However, that's not what I'm concerned about. I'm trying to eliminate the first blank
08/06/17
x-axis label, but for some reason,stringForValue
is being called for each index.Here's a bit of my code:
The
dataPoints
array contains the following dates:[2017-08-05, 2017-08-06, 2017-08-06, 2017-08-07, 2017-08-10]
The
values
array contains the following:[8.0, 3.0, 5.66, 4.44, 5.0]
Now ignoring the trivial things happening in the
for
loop ofcreateBarChart
, every time I create theBarChartDataEntry
, the value inlastIndex
is0, 2, 3, 4
respectively.duplicateDateCosts
is an array ofDouble
costs value associated with thelastIndex
.However,
stringForValue
is called with thevalue
being passed in as0, 1, 2, 3, 4
. This causes the date x-axis label08/06/17
to be displayed twice even though I combined the two dates into one stacked bar, hence theduplicateDateCosts
array containing3.0
and5.66
for the associated08/06/17
date label.I thought the
value
instringForValue
corresponds to thex
Double value in the initializationBarChartDataEntry(x: [Double], yValues: [Double] )
. This is based on what @tuantmdev said in #1527: "The value of x you pass when init BarChartDataEntry should be the same the value of formatter method"Therefore, why isn't the
value
instringForValue
suppose to be0, 2, 3, 4
, but instead is0, 1, 2, 3, 4
???I don't understand. This is why I have a repeated x-axis label.
Can someone explain this to me?
The text was updated successfully, but these errors were encountered: