Hi,
Thanx alot for your feedback..will do it as per your suggestion..
On Wednesday, August 14, 2013 3:23:54 PM UTC+5:30, soumya reubro wrote:
>
> Hi,
>
> I am trying to draw a line chart using *Google chart *in which data is
> retrieved from mysql table.But i get the error as follows
> Error: Invalid JSON string:
> {"cols":[{"label":"id","type":"string"},{"label":"date","type":"string"}],"rows":["1","2013-08-13
>
> 00:00:00"]}{"cols":[{"label":"id","type":"string"},{"label":"date","type":"string"}],"rows":["2","2013-08-13
>
> 00:00:00"]}
>
> the json encoded data looks as follows
> {"cols":[{"label":"id","type":"string"},{"label":"date","type":"string"}],"rows":["1","2013-08-13
>
> 00:00:00"]}{"cols":[{"label":"id","type":"string"},{"label":"date","type":"string"}],"rows":["2","2013-08-13
>
> 00:00:00"]}
>
>
>
> Here is the code which i used for line chart developement
>
> <html>
> <head>
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
> <script type="text/javascript" src="jquery.js"></script>
> <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
> <script type="text/javascript">
> google.load("visualization", "1", {packages:["corechart"]});
> google.setOnLoadCallback(drawChart);
> function drawChart() {
> var jsonData = $.ajax({
> url: "graph1.php",
> dataType:"json",
> async: false
> }).responseText;
> var data = new google.visualization.DataTable(jsonData);
> var chart = new
> google.visualization.LineChart(document.getElementById('chart_div'));
> chart.draw(data, {width: 400, height: 240});
> }
> </script>
> </head>
> <body>
> <div id="chart_div" style="width: 900px; height: 500px;"></div>
> </body>
> </html>
>
>
> PHP part:
>
>
> $sql = mysql_query("SELECT * FROM `da_insulin_details` LIMIT 0,2 ");
> $rows['cols'] = array( array('label' => 'id', 'type' => 'string'),
> array('label' => 'date', 'type' => 'string'));
> while($row = mysql_fetch_array($sql))
> {
>
> $rows['rows'] [0] = $row['id'];
> $rows['rows'][1] = $row['date'];
> $jsonTable = json_encode($rows);
> echo $jsonTable;
>
> }
>
>
> I am new to this section..anybody pls help me to solve the issue
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.