iam trying to show multiple Graphs in one diagram. The datasource is a MySQL database which is connected via PHP. My Problem: I cant figure out how to add the data to the RGraph Script. I managed to show one graph via PHP, bt i cant add a seconde one. This is how i succsessfully get the Data (After connecting to the Database ofc.): Important!: (At least i guess it is) i have two different cases, in one Case the return Data is a single Number (eg: "2") in my seconde case it is an array of 52 different numbers.
$1 = mysql_query("SELECT * FROM Table WHERE spalte1 ='XX' AND spalte2 ='XX' ORDER BY Datum DESC Limit 1");
if ($1) {
$labels = array();
$data = array();
while ($row = mysql_fetch_assoc($1)) {
$labels[] = $row["datum"];
$2[] = $row["max"];
}
// Now you can aggregate all the data into one string
$2_string = "[" . join(", ", $2) . "]";
$labels_string = "['" . join("', '", $labels) . "']";
}
else
{
print('MySQL query failed with error: ' . mysql_error());
}
This is how i draw the Graph:
<canvas id="cvs" width="1200" height="250">[Browser not supported]</canvas>
<script>
//window.onload = function ()
//{
new RGraph.Line({
id:'cvs',
data:[<?php print($2_string) ?>],
options: {
colors:['#B71A1A'],
backgroundGrid: true,
//xaxisLabels: [<?php print($labels_string) ?>],
//xaxisLabelsAngle: 25,
xaxis: true,
yaxis: true,
yaxisScale: true,
yaxisScaleUnitsPost:'%',
yaxisScaleMax: 100,
title: 'XX',
textAccessible: true,
key: ['XX'],
keyPosition: 'margin',
keyPositionX: 25,
}
}).draw();
But how can i add a seconde graph into this diagram? All the Demos say something like:
data = [[1,2,3],[4,5,6]]
So i tryed different versions (just one example):
data = [[<?php print($1_string) ?>],[<?php print($2_string) ?>]]
Hopefully someone has an Idea ... :)
Thx for every try :)