PDA

View Full Version : How to add null values to store connected to chart?



maniac
20 Aug 2009, 3:45 AM
Hi,

I am trying to use the charting feature of Gxt 2.0 and am stumbling over a problem: I'd like the chart to skip some data items I have no data for. According to the documentation, this should be possible using e.g.



LineChart chart = new LineChart();
for (int i = 0; i < 10; i++) chart.addDots(new Dot(i));
chart.addNullValue();
for (int i = 0; i < 10; i++) chart.addDots(new Dot(i));


My question is: how can I do the same if I have a DataProvider connected to the ChartConfig which reads its data out of a ListStore? Simply passing null as the value part of the ModelData instance doesn't seem to work (it's converted to a dot with value=0).
If it's not possible, I'd like to report that as a bug ;)

sven
20 Aug 2009, 3:59 AM
If it's not possible, I'd like to report that as a bug

If something isnt possible it is not a bug.

maniac
20 Aug 2009, 5:21 AM
If something isnt possible it is not a bug.
Does that mean it isn't possible?
Personally I don't really care about what to call it (bug, feature request, etc.), but I really think it _would_ make sense to be possible ;)

maniac
25 Aug 2009, 7:55 AM
Here's a simple patch to fix the mentioned problem/add the desired feature:


Index: src/com/extjs/gxt/charts/client/model/LineDataProvider.java
===================================================================
--- src/com/extjs/gxt/charts/client/model/LineDataProvider.java
+++ src/com/extjs/gxt/charts/client/model/LineDataProvider.java
@@ -48,9 +48,10 @@
Object v = m.get(valueProperty);
Number n = v instanceof String ? Double.parseDouble((String) v) : (Number) v;
if (n == null) {
- n = 0;
+ chart.addNullValue();
+ } else {
+ chart.addValues(n);
}
- chart.addValues(n);
minYValue = Math.min(minYValue, n.doubleValue());
maxYValue = Math.max(maxYValue, n.doubleValue());
if (xAxis != null) xAxis.addLabels(getLabel(m, valueProperty));

sven
25 Aug 2009, 2:10 PM
Added to SVN