Thanks a ton mate.... it worked like magic...
the only thing .... how can i set more options to it...like changing colors
, etc...
and why is the date interval coming of two days instead of one day ......
how to make it daily basis x axis and what will happen to the graph size if
i continue for say 1000+ days... ?
On Friday, September 7, 2012 3:54:16 PM UTC+5:30, gnik wrote:
>
> i have a mysql database . i want to plot a dynamic graph between two of
> my table colums named as date and sales .where date is stored in this
> format("yyyy-mm-dd") and sales are integers (not float )
> please help me with this. though i am successful in plotting data but the
> graph is not properly drawn . i guess there's an issue with intervals.
>
> i want
> x axis interval as : aug 30 , aug 31 , sep 01 , sep 02 and so on.....
> y axis interval as : 0 , 10 , 20 ,30 ....
>
>
> my code goes like this :
>
>
> <?php
> include('dbconnect.php');
> $sql_data = mysql_query("SELECT date , sales FROM analytics WHERE
> id ='12345' ORDER BY date ASC");
>
> ?>
>
> <html>
> <head>
> <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>
> <?php
> echo "<script type=text/javascript>";
> echo "google.load(\"visualization\", \"1\",
> {packages:[\"corechart\"]});";
> echo "google.setOnLoadCallback(drawChart);";
>
> echo "function drawChart() { ";
> echo "var data = google.visualization.arrayToDataTable([
> ['Date', 'Score'],";
> while($result = mysql_fetch_array($sql_data))
> {
> $t1 = strtotime($result['date']);
> $t2 = date("d",$t1);
> $display .= "[".$t2.",".$result['sales']."],";
> }
>
> $display .= " ]);";
>
> echo $display;
>
> echo "var options = {
> title: 'Sales Analysis' ,
> vAxis: {title: \"sales\"},
> hAxis: {title: \"date\"} ,
>
> };";
>
> echo "var chart = new
> google.visualization.LineChart(document.getElementById('chart_div'));";
> echo "chart.draw(data, options);";
> echo "}
> </script>";
>
> ?>
> </head>
> <body>
> <div id="chart_div" style="width: 900px; height: 500px;"></div>
> </body>
> </html>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/9BH3vjeausgJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.