I am being unclear: What I can't figure out, is a way to insert null
values into the DataTable itself. I need a function in the datasource
API that a) sets an arbitrary value in a datatable (I don't see a
setvalue() function anywhere in the api), or b) a function that allows
you to set a null value in the data table. Or c) maybe I need to use
a different type besides NUMBER?
I passed a null value to the addCell() method by casting null to a
Double: addCell((Double)null). Unfortunately generateDataTable()
throws a 'nulll pointer exception' when I do this.
To create a 2x3 data table with the datasource api I did the
following. Let's say for this example that I want the first cell to
be null but everything else to have a numerical value. Thanks for
your help!
DataTable data = new DataTable();
data.addColumn(new ColumnDescription("col1",ValueType.NUMBER,"col1"));
data.addColumn(new ColumnDescription("col2",ValueType.NUMBER,"col2"));
data.addColumn(new ColumnDescription("col3",ValueType.NUMBER,"col3"));
TableRow tr = new TableRow();
tr.addCell(0); // I want to make this cell null!
tr.addCell(1);
tr.addCell(1);
data.addRow(tr);
TableRow tr2 = new TableRow();
tr2.addCell(2);
tr2.addCell(3);
tr2.addCell(3);
On Feb 5, 10:09 am, ChartMan <[email protected]> wrote:
> Null cells will be omitted from the data table json response (replaced with
> commas
> ,,,)http://www.google.com/codesearch/p?hl=en#aLJwv4TSmDw/trunk/src/java/c...
>
> <http://www.google.com/codesearch/p?hl=en#aLJwv4TSmDw/trunk/src/java/c...>As
> for null rows, I am quite sure you can omit them from the json response but
> it seems that the library does not do that for you.
>
> ChartMan
>
>
>
> On Fri, Feb 5, 2010 at 4:54 AM, carlos <[email protected]> wrote:
> > Sorry, I don't quite follow. I'm using the Java namespace
> > com.google.visualization.datasource.datatable to generate a data table
> > that will get output as json. The only way I see to build a table is
> > to addRow(Row r). and the only way to build a row, is to serially add
> > cells. r.addcell(). Am I missing something? Is there a way to set
> > the value of a certain cell?
>
> > -Carlos
>
> > On Feb 4, 2:28 am, ChartMan <[email protected]> wrote:
> > > don't add anything to rows/cells that are empty. This will result in
> > empty
> > > sections of the json.
> > > E.g., {v:1},,,,,,,,,{v:2}
>
> > > ChartMan
>
> > > On Thu, Feb 4, 2010 at 6:44 AM, carlos <[email protected]> wrote:
> > > > I am writing a datasource in java to feed data to a scatterplot from a
> > > > mysql database. The data is sparse: not every column has a value for
> > > > every row. I can easily plot sparse data manually in javascript or in
> > > > the java GWT by only setting certain values in a DataTable. Is there
> > > > a way to generate sparse data from a servlet with the Visualization-
> > > > DataSource java API?
>
> > > > Using addCell to add an empty string to numerical data throws an
> > > > error.
>
> > > > Thanks,
> > > > Carlos
>
> > > > --
> > > > You received this message because you are subscribed to the Google
> > Groups
> > > > "Google Visualization API" group.
> > > > To post to this group, send email to
> > > > [email protected].
> > > > To unsubscribe from this group, send email to
> > > > [email protected]<google-visualization-
> > > > api%[email protected]><google-visualization-
> > api%[email protected] <api%[email protected]>>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/google-visualization-api?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Google Visualization API" group.
> > To post to this group, send email to
> > [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<google-visualization-
> > api%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-visualization-api?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.