There are a few things wrong here:

1) there is PHP code in this page that isn't getting parsed.  Make sure 
that the file has a .php extension and is getting processed correctly.
2) the DataTable's date column is still formatted incorrectly: "2013-03-07" 
needs to be formatted as "Date(2013, 2, 7)"
3) you have a DataView that selects columns 0 and 3, but the DataTable only 
has two columns.

On Saturday, March 16, 2013 4:16:25 PM UTC-4, [email protected] wrote:
>
> But it still not work:(
>
> The problem is here:
> <?php
> $chart_type = $_POST['selectcharttype'];
> ?>
> <html>
> <head> 
> <meta charset="utf-8">
>     <script type="text/javascript" src="https://www.google.com/jsapi
> "></script>
>     <script type="text/javascript" src="
> https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
> "></script>
>     <script type="text/javascript">
> var chartType = new String("<?php echo $chart_type; ?>");
>  function drawChart() {
> // you can handle the query outside the if statements since it is the same 
> for both
> var jsonData = 
> '{"cols":[{"label":"Date_of_Measure","type":"date"},{"label":"BloodGlucose","type":"number"}],"rows":[{"c":[{"v":"2013-03-07"},{"v":25}]},{"c":[{"v":"2013-03-07"},{"v":5}]},{"c":[{"v":"2013-03-07"},{"v":15}]},{"c":[{"v":"2013-03-07"},{"v":85}]}]}';
> // Create the data table.
> var data = new google.visualization.DataTable(jsonData); 
>             var view = new google.visualization.DataView(data);
>        view.setColumns([0,3]); 
> if (chartType == 'Line Chart'){ 
> var options = {
> // chartTitle isn't defined anywhere
> title: 'Line chart for Blood Glucose Measures',
> width: 400,
> height: 400,
> backgroundColor: {
> fill: 'black'
> },
> is3D: true,
> titleTextStyle: {
> color: 'white',
> fontSize: '16'
> },
> legend: {
> textStyle: {
> color: 'white'
> }
> } 
> };
> var chart = new 
> google.visualization.LineChart(document.getElementById('chart_div'));
> }
> else if (chartType == 'Bar Chart'){
> var options = {
> // chartTitle isn't defined anywhere
> title: 'bar chart for Blood Glucose Measures',
> width: 400,
> height: 400,
> backgroundColor: {
> fill: 'black'
> },
> titleTextStyle: {
> color: 'white',
> fontSize: '16'
> },
> hAxis: {
> title: 'BloodGlucose_Measure',
> titleTextStyle: {
> color: 'white'
> },
> textStyle: {
> color: 'white'
> }
> },
> vAxis: {
> title: 'Date of measure',
> titleTextStyle: {
> color: 'white'
> },
> textStyle: {
> color: 'white'
> }
> },
> legend: {
> position: 'bottom',
> textStyle: {
> color: 'white'
> }
> }
> };
> var chart = new 
> google.visualization.BarChart(document.getElementById('chart_div'));
> }
>
> chart.draw(view,options);
> }
> google.load("visualization", "1", {packages: ["corechart"]});
>
>
> google.setOnLoadCallback(drawChart);
> </script>
> </head>
> <body>
> <div id="chart_div" ></div>
> </body>
> </html>
>
>

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to