Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Visualization - joining multiple DataTables in Java
    text
    copied!<p>Basically I'm creating a GWT application using the google App Engine (Java), the Datastore and Google Visualization charts.</p> <p>I used a simple line chart to represent the following information - Value(Y-axis) over Year(X-axis)</p> <p>I'm getting the following values from the Datastore as a list of entities: </p> <p>Request for Jon returns Entities (each row is an entity):</p> <pre><code>Person | Value | Year Jon | 80% | 1992 Jon | 74% | 2010 Jon | 10% | 2011 Jon | 84% | 2012 </code></pre> <p>Request for Mike Returns: </p> <pre><code>Person | Value | Year Mike | 80% | 2000 Mike | 74% | 2001 Mike | 10% | 2002 Mike | 84% | 2003 Mike | 85% | 2006 Mike | 65% | 2011 Mike | 55% | 2012 </code></pre> <p>I can create a graph for each person easily. I do so by creating the <a href="https://developers.google.com/chart/interactive/docs/dev/dsl_javadocs/com/google/visualization/datasource/datatable/package-summary" rel="nofollow">DataTable</a> on the Server using the following <a href="https://developers.google.com/chart/interactive/docs/dev/dsl_javadocs/index?com/google/visualization/datasource/package-summary.html" rel="nofollow">Google Visualization Data Source Library</a> - I then send it back using Json. </p> <p>Now what I'd like is to create a graph which combines/joins both DataTables</p> <p>The only other way I can see myself implementing this is by creating each <a href="https://developers.google.com/chart/interactive/docs/dev/dsl_javadocs/com/google/visualization/datasource/datatable/TableRow" rel="nofollow">TableRow</a> individually - and this just feels like overkill for me at the moment because the data must be in the correct column for each person i.e. TableRow for year 2012 would need to be </p> <pre><code>Year |Mike | Jon 2006 | 85% | null 2011 | 65% | 10% 2010 | null| 84% 2011 | 65% | 10% 2012 | 55% | 84% </code></pre> <p>This is especially tricky for me because I send separate requests for each person - so for example if I request Jon then I get a list of entities representing each row , but when I want to JOIN them I need to go through the pain of getting the year, adding the value to the right column etc etc. This just all seems like overkill, there must be a way to merge tables so that you can generate the above set of rows automatically. </p> <p>What I want is simply to generate a DataTable for Jon and Mike and Sally if she comes along, and then Merge them all in one simple command so that I get a nice chart with each line mapped to the correct person.</p> <p>p.s I this code should be written in Java on the Server...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload