There's a starter PHP script here for the query: 
https://groups.google.com/d/msg/google-visualization-api/-zapZe7dH7Y/U1sl7j34d6oJ.
 
 The javascript would look something like this:

google.load('visualization', '1', {packages: ['corechart']});
google.setOnLoadCallback(drawChart);

function drawChart () {
    // send an AJAX query to the data source script
    $.ajax({
        url: '/path/to/data/source.php',
        data: {
            // key: value pairs that you can set to send information to the 
query to change what is queried
        },
        dataType: 'json',
        type: 'POST',
        success: function (response) {
            var data = new google.visualization.DataTable(response);
            var chart = new 
google.visualization.LineChart(document.getElementById('chart_div'));
            chart.draw(data, {
                // chart options
                height: 400,
                width: 600
            });
        }
    });
}

On Tuesday, January 8, 2013 11:03:59 PM UTC-5, DP wrote:
>
> Hi asgallant,
> *thanks for ur quick reply.I am new to php verymuch.*
> *in that example u have sent hardcoded data as rows.but in here i need to 
> pass data which i queried from mysql query.*
> *so can you tell me how can i do that?I am confused on  this*
> *
> *
> *Thanks*
> *
> *
> On Tuesday, January 8, 2013 10:02:28 PM UTC+5:30, asgallant wrote:
>>
>> Yes, you can send multiple columns of data to the charts.
>>
>> The chart's color columns by data series, so what you want may be 
>> possible, depending on exactly how you want to present it.  In general, 
>> most people who come here looking to color bars in different colors colors 
>> are working with a single data series to start with, which allows them to 
>> use a hack like this: http://jsfiddle.net/asgallant/QHJA6/.  In your 
>> case, this may not work as it relies on stacking columns to get rid of the 
>> extra space in the chart where the bars belonging to data with null values 
>> would otherwise be.  If you already have multiple columns of data, this 
>> will only work if you actually want to have the columns stacked to begin 
>> with.
>>
>> On Tuesday, January 8, 2013 4:48:44 AM UTC-5, DP wrote:
>>>
>>> Hi asgallant,
>>> *I was reading this and trying to configure to my application.*
>>> *Let me tell you what i have being trying.*
>>> *Can we send multiple queried data into a single chart.*
>>> *Assume:*
>>> *There can be multiple users.They can work 8 hours per day.*
>>> *User1=*
>>> *Development time: 5hrs*
>>> *Issue fixing time:3 hrs*
>>> *
>>> *
>>> *User2*
>>> *Development time:8hrs*
>>> *Issue fixing time:0 hrs*
>>> *
>>> *
>>> *User3*
>>> *Development time:2hrs*
>>> *Issue fixing time:6 hrs*
>>> * *
>>> *So can i display these data in the same column chart.So there will be 
>>> 6 columns.1st,3rd and 5th columns will be in common color, while rest will 
>>> be in a different color.*
>>> *please help me with this.*
>>> *waiting for your quick reply*
>>> *thanks in advance 
>>> *
>>> On Thursday, December 6, 2012 12:16:00 PM UTC+5:30, asgallant wrote:
>>>>
>>>> Ok, here's example PHP to get you started:
>>>>
>>>> <?php
>>>> /* $server = the IP address or network name of the server
>>>>  * $userName = the user to log into the database with
>>>>  * $password = the database account password
>>>>  * $databaseName = the name of the database to pull data from
>>>>  */
>>>> $con = mysql_connect($server, $userName, $password) or die('Error 
>>>> connecting to server');
>>>>  
>>>> mysql_select_db($databaseName, $con); 
>>>>
>>>> // write your SQL query here (you may use parameters from $_GET or 
>>>> $_POST if you need them)
>>>> $query = mysql_query('SELECT column1, column2, column3 FROM myTable');
>>>>
>>>> $table = array();
>>>> $table['cols'] = array(
>>>> /* define your DataTable columns here
>>>>  * each column gets its own array
>>>>  * syntax of the arrays is:
>>>>  * label => column label
>>>>  * type => data type of column (string, number, date, datetime, boolean)
>>>>  */
>>>>     array('label' => 'Label of column 1', 'type' => 'string'),
>>>> array('label' => 'Label of column 2', 'type' => 'number'),
>>>> array('label' => 'Label of column 3', 'type' => 'number')
>>>> // etc...
>>>> );
>>>>
>>>> $rows = array();
>>>> while($r = mysql_fetch_assoc($query)) {
>>>>     $temp = array();
>>>> // each column needs to have data inserted via the $temp array
>>>> $temp[] = array('v' => $r['column1']);
>>>> $temp[] = array('v' => $r['column2']);
>>>> $temp[] = array('v' => $r['column3']);
>>>> // etc...
>>>>  // insert the temp array into $rows
>>>>     $rows[] = array('c' => $temp);
>>>> }
>>>>
>>>> // populate the table with rows of data
>>>> $table['rows'] = $rows;
>>>>
>>>> // encode the table as JSON
>>>> $jsonTable = json_encode($table);
>>>>
>>>> // return the JSON data
>>>> echo $jsonTable;
>>>> ?>
>>>>
>>>> You will have to fill in the database connection information, write 
>>>> your SQL query, define the columns in $table['cols'], and adjust the 
>>>> while loop to ensure that all columns of data get populated.  You 
>>>> should be able to navigate to that page in your browser and see a string 
>>>> of 
>>>> JSON data.  When you have a basic version running, I'll help you hook it 
>>>> up 
>>>> to your chart(s).
>>>>
>>>> On Wednesday, December 5, 2012 10:54:01 PM UTC-5, Chrystopher Medina 
>>>> wrote:
>>>>>
>>>>> hi my frined thanks for answering me my question. could you be more 
>>>>> expecific u know i really dont know speak english very well. and i just 
>>>>> began to study this about how to program whit ajax .... really its 
>>>>> posible 
>>>>> .... could u help me my friend could u give me ur email or ur facebook 
>>>>> page. or something like that. ....... its very important to me to do 
>>>>> this. 
>>>>> i ve spend months with this work. and it doesnt work ....... please 
>>>>> explaime how i can do in order to achieve this ............
>>>>>
>>>>>

-- 
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/-/GVgmKEfYtfgJ.
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.

Reply via email to