ATL charts require a "date" type domain column, while you are providing a
"string" type. You have to convert to a date type to make it work.
Assuming your dates are in the format "year-month-day", this is how you
would convert them to an API-compatible format:
$table['cols'] = array(
array('label' => 'fecha', 'type' => 'date'),
array('label' => 'msnm', 'type' => 'number')
);
$rows = array();
while($r = mysql_fetch_assoc($sth)) {
$temp = array();
$dateArr = explode('-', $r['fecha']);
$year = $dateArr[0];
$month = $dateArr[1] - 1; // months are zero-indexed
$day = $dateArr[2];
$temp[] = array('v' => "Date($year, $month, $day)";
$temp[] = array('v' => (float) $r['msnm']);
$rows[] = array('c' => $temp);
}
On Monday, March 18, 2013 1:44:20 PM UTC-4, Ian Haylock wrote:
>
> Hi asgallant, can you help me with this please? .. im trying to display a
> annotatedtimeline chart but i have not been able too... when i try it on
> barchart, column chart or line chart it displays fine, but
> annotatedtimetimeline would not show .. this is what i have for
> annotatetimeline chart (further below is the linechart version which wroks
> fine):
>
> ***************************************************************************************************************************************************************
> $sth = mysql_query("select fecha, msnm from embalse, diarioembalse WHERE
> embalse_idembalse=idembalse and fecha between (select min(fecha) from
> diarioembalse) and (select max(fecha) from diarioembalse) order by fecha
> limit 0,31 ");
> //echo mysql_num_rows($sth);
> $rows = array();
> $flag = true;
>
> $table = array();
> $table['cols'] = array(
> array('label' => 'fecha', 'type' => 'string'),
> array('label' => 'msnm', 'type' => 'number')
> );
>
> $rows = array();
> while($r = mysql_fetch_assoc($sth)) {
> $temp = array();
> $temp[] = array('v' => (string)$r['fecha']);
> $temp[] = array('v' => (float) $r['msnm']);
> $rows[] = array('c' => $temp);
> }
>
> $table['rows'] = $rows;
>
> $jsonTable = json_encode($table);
>
> echo $jsonTable;
> ?>
>
> <script type="text/javascript">
> /*
> grafico de capacidad de plantas
> */
> google.load('visualization', '1', {'packages':['annotatedtimeline']});
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
> var data = new google.visualization.DataTable(<?php echo $jsonTable;
> ?>);
>
>
> var chart = new
> google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
> chart.draw(data, {'displayAnnotations': true});
> }
>
> </script>
> <table>
> <tr>
> <td> <div id="chart_div" style="width: 700px; height: 500px;" ></div>
> </td>
> </tr>
>
> </table>
>
> *************************************************************************************************************************************
> the linechart version:
>
>
> $sth = mysql_query("select fecha, msnm from embalse, diarioembalse WHERE
> embalse_idembalse=idembalse and fecha between (select min(fecha) from
> diarioembalse) and (select max(fecha) from diarioembalse) order by fecha
> limit 0,31 ");
> //echo mysql_num_rows($sth);
> $rows = array();
> $flag = true;
>
> $table = array();
> $table['cols'] = array(
> array('label' => 'fecha', 'type' => 'string'),
> array('label' => 'msnm', 'type' => 'number')
> );
>
> $rows = array();
> while($r = mysql_fetch_assoc($sth)) {
> $temp = array();
> $temp[] = array('v' => (string)$r['fecha']);
> $temp[] = array('v' => (float) $r['msnm']);
> $rows[] = array('c' => $temp);
> }
>
> $table['rows'] = $rows;
>
> $jsonTable = json_encode($table);
>
> //echo $jsonTable;
> ?>
>
> <script type="text/javascript">
> /*
> grafico de capacidad de plantas
> */
> google.load('visualization', '1', {'packages':['corechart']});
> google.setOnLoadCallback(drawChart);
>
> function drawChart() {
> var data = new google.visualization.DataTable(<?php echo $jsonTable;
> ?>);
> var options = {'title':'nivel embalse',
> 'width':'1200',
> 'height':'800',
> 'chartArea':{'width':'70%','height':'80%'},
> 'backgroundColor':'transparent',
>
> };
>
> var chart = new
> google.visualization.LineChart(document.getElementById('chart_div'));
> chart.draw(data,options);
> }
>
>
>
> </script>
> <div id="chart_div" ></div>
>
> ***************************************************************************************************************
>
> what am i missing for the annotatedtimeline chart ??????
>
--
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.