draw one graph with data from different database datas

459 views
Skip to first unread message

Nadja

unread,
Sep 24, 2019, 6:28:31 AM9/24/19
to Google Visualization API
Hi,
I have a problem to draw the following graph.

I have different databases with datas (f.e. database1 width data zone1, zone2, zone3 and database2 with data zone1, zone2, zone3 )
I want do draw one graph for the two databases. Each zone should be one line.

What I have done:
- get the datas from the database and write into an array like this
- for the first database:
 $data[]=array($timed." ".$hourd, $chad1, $chad2, $chad3, $tooltip, $error, $errortext);

for the second database:
 $data[]=array($timed." ".$hourd, $chad1_2, $chad2_2, $chad3_2, $tooltip, $error, $errortext);

- after added all datas to the array I use json_encode()

- in the Javascript I add the coloums like this (for all zones)
if(<?php if(isset($cha1_2)) echo $cha1_2; else echo "0"; ?>==1) {data.addColumn('number', 'Zone 1 <?php echo $geraetename2; ?>');}

  var options = {
  title: 'Data',
  width: '100%',
height: 600,
tooltip: {isHtml: true},

annotations: {
textStyle: {
fontSize: 18,
bold: true,
color: '#f02516',
}},
colors:['#438b08','#f7c220', '#1a15ec', '#810fb0', '#356909', '#f3d064', '#1411a2', '#b30bf8'],

  series: {
  0: {targetAxisIndex: 0},
  1: {targetAxisIndex: 0},
  2: {targetAxisIndex: 0},
  3: {targetAxisIndex: 0},
  4: {targetAxisIndex: 0},
  5: {targetAxisIndex: 0},
},
vAxes: {
  // Adds titles to each axis.
  0: {title: '<?php echo $unitaktuell ?>'},
}
   };}

But if I run the script I get the error:
Uncaught (in promise) Error: Row given with size different than 6 (the number of columns in the table).

I think because the values for the different databases are in different rows.

Is there are possibility to draw this graph? The first axe is the time. But the time in the datas can be different. So I cannot add the data from the second database to the first one.

I really hope, you can understand my problem.

Thank you
Nadja

Nadja

unread,
Sep 25, 2019, 10:02:32 AM9/25/19
to Google Visualization API
is it to complicated? Do nobody understand my problem?
Regards
nadja 
Reply all
Reply to author
Forward
0 new messages