I'm using GWT 2.4 in conjunction with GFlot 2.4.3 and have a strange issue regarding the stacking of six series.
You can see my bars along with the issue in the picture below. I have six series (handler1 to handler6) that represent percentages, the color is for distinguishing the series and has its own meaning, but that's not important for my problem. I only add DataPoints to the series if the value is greater than 0.0.
This table shows the data for the first four bars, the day is converted from a Timestamp in milliseconds :
12.9.2012 | 0 0 0 0 100
13.9.2012 | 0 0 0 99,529 0,417
14.9.2012 | 0 0 99,935 0 0,065
15.9.2012 | 0 99,93 0 0 0,07
As you may see the red series gets stacked correctly on Sep 12 and 13, but then Flot suddenly stops stacking the bars as of Sep 14 and further, as you can see with the tiny red bars on the bottom. Also note the red bar on Sep 14 is a bit shifted into Sep 13, this continues with the following dates/x-values.
I have added a fixed number to the values to increase the bar's size and were able to see that the reason for GFlot for not stacking the bars correctly is that they don't share the same x-value, but this is ridiculous as I have also verified - with outputs to System.err
- that the x-values are the same for all of the series!
For example: For the second bar with yellow and red and correct stacking this output is being generated:
series handler 3: x-value: 1.347.487.200.000
series handler 4: x-value: 1.347.487.200.000
The third bar with incorrect stacking has this output:
series handler 2: x-value: 1.347.573.600.000
series handler 4: x-value: 1.347.573.600.000
So for both bars the x-values for each relevant series are the same, but stacking stops working after the second bar. How can this be and what am I to do to prevent this from happening?
This issue only seems to occur for this data, when plotting different data it works as expected, as this screenshot shows:
Here's the code for adding the data to the series. multipleData
is an object with a Double
for the x-value and an ArrayList<Double>
for y-values, query.getData()
returns an ArrayList<multipleData>
and md.getvalue()
returns the ArrayList
with the y-values contained in the multipleData
object.
handlers[]
-array is obviously the array with the six series handlers. And YES, I have an options.setStack(true);
in my plot code ;)
for(multipleData md : query.getData()) {
if(!md.getValue().isEmpty()) {
for(int i=0; i < 5; i++) {
if(md.getValue().get(i) > 0.0) {
handlers[i].add(new DataPoint((md.getPoint(), md.getValue().get(i)));
}
}
}
}
Edit from Oct 17: This image has a completely different data base and shows the issue very clearly. At first the bars not get stacked and suddenly stacking works as expected: