join() method for more than 2 DataTable

948 views
Skip to first unread message

rafLab

unread,
Jul 9, 2015, 4:39:35 PM7/9/15
to google-visua...@googlegroups.com
Hi!.

Is there a way to join more than 2 DataTable to a linear graph?

I've tried joining an already joined DataTable(dt1,dt2) with a third Data(dt3) but it doesn't work.

var data1 = google.visualization.arrayToDataTable(arrayData1);
var data2 = google.visualization.arrayToDataTable(arrayData2); 

arrayData1 is similar to arrayData2
| Date           | Temp |
| 2015-07-07  | 1       |
| 2015-07-08  | 2       |
| 2015-07-09  | 5       |

var data12 = google.visualization.data.join(data1,data2,'full',[[0,0]],[1],[1]); 

My understanding is that now i have something like this:

| Date           | Temp | Temp |
| 2015-07-07  | 1       |   4      |
| 2015-07-08  | 2       |    5     |
| 2015-07-09  | 5       |    8     |

Now, data 3... is the same-
| Date           | Temp |
| 2015-07-03  | 1       |
| 2015-07-04  | 22      |
| 2015-07-05  | 5       |

var data = google.visualization.data.join(data12,data3,'full',[[0,0]],[[1,2]],[1]);  //<---- is that correct?


if I joing the two first arrays it works like a charm... the issue is with the third. Is there any way to do it or I'm being too creative?


Thanks in advance.
Regards
Rafael.

Daniel LaLiberte

unread,
Jul 9, 2015, 7:59:28 PM7/9/15
to google-visua...@googlegroups.com
Hi Rafael,

It's not clear from your examples what you expect the output of your join of data12 and data3 should be.  Can you give an example of that output table?

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.



--
dlaliberte@Google.com   5CC, Cambridge MA
daniel.laliberte@GMail.com 9 Juniper Ridge Road, Acton MA

Rafael Labarca

unread,
Jul 10, 2015, 8:05:51 AM7/10/15
to google-visua...@googlegroups.com
Daniel,

Thanks for your help

dt1
| Date           | Temp1 |
| 2015-07-07  | 1         |
| 2015-07-08  | 2         |
| 2015-07-09  | 5         |

dt2
| Date           | Temp2 |
| 2015-07-05  | 1         |
| 2015-07-06  | 2         |
| 2015-07-07  | 5         |

after join of dt1 and dt2(resulting dt12)
dt12 (this one works perfectly)
| Date           | Temp1 | Temp2|
| 2015-07-05  | null      |1         |
| 2015-07-06  | null      | 2        |
| 2015-07-07  | 1         |           |
| 2015-07-08  | 2         |           |
| 2015-07-09  | 5         |           |


dt3
| Date           | Temp3 |
| 2015-07-04  | 1       |
| 2015-07-05  | 2       |
| 2015-07-08  | 5       |

the expected output of dt12 and dt3 should be

| Date           | Temp1 | Temp2|Temp3|
| 2015-07-04  | null      |null      |    1    |
| 2015-07-05  | null      |1         |      2  |
| 2015-07-06  | null      | 2        |          |
| 2015-07-07  | 1         |           |          |
| 2015-07-08  | 2         |           |      5  |
| 2015-07-09  | 5         |           |          |


Thanks!
Rafael.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/NRWMmMzbsKM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.

Daniel LaLiberte

unread,
Jul 10, 2015, 8:20:06 AM7/10/15
to google-visua...@googlegroups.com
Did you try: var data = google.visualization.data.join(data12,data3,'full', [[0,0]], [1,2], [1]);

The last two arguments must be arrays of columns, but your dt1Columns argument was an array of array.

Rafael Labarca

unread,
Jul 10, 2015, 8:30:09 AM7/10/15
to google-visua...@googlegroups.com
It worked!!

thanks a lot!

Imágenes integradas 1

Regards.
Rafael.

Shinn Chyang CHEN

unread,
May 17, 2017, 10:05:55 PM5/17/17
to Google Visualization API



I have a question not about the method to join several datatable but on the result. My datatables have the same columns as user "rafLab", dt1[date, temp], dt2[date, temp]....dtn[date, temp]. I have the impression the join method is omitting some rows on my tables. After I join those datatable, the serie get a different end date.


          end date    join end date

2014   06/02        05/26

2015   05/30        05/29

2016   06/02        06/05

2017   


I have a website you can see what's wrong, moncompost.com. I have several datables (saisons). I only join datatable for Spring datatable (ie 'Printemps 2017', 'Printemps 2016', 'Printemps 2015', 'Printemps 2014'). The join method is invoked when I chose the dropdown menu Visualisation 'Annees Anterieures'.

Shinn Chyang CHEN

unread,
May 18, 2017, 8:31:40 AM5/18/17
to Google Visualization API
I am sorry there no error with the join method! Everything is correct.
Reply all
Reply to author
Forward
0 new messages