Working with dates is a bit tricky, made more so by transmitting your data
over AJAX. Since JSON does not support date objects, you have to transmit
dates as a string in JSON, but the arrayToDataTable method will not work
with date strings, you have to use the full DataTable constructor (search
these forums for PHP examples, there are many to choose from). When using
the full DataTable JSON format, your dates have to be strings in this
format:
"Date(year, month, day)"
where month is zero-indexed (so January is 0, not 1). As an example, April
8, 2014 would be "Date(2014, 3, 8)".
On Tuesday, April 8, 2014 2:07:15 AM UTC-4, harshitha wrote:
>
> 1) I want each date to be displayed only once. But every value for the
> x-axis is being displayed.
> I am getting json data from php file through ajax call.
> this is my data
>
> [["Timestamp","Cpu","Hstatus","Free"],["05-03",0.6,1,0],["05-03",0.9,1,0],["05-03",0.1,1,0],["05-03",0.6,1,0.849],["05-03",0.4,1,0],["05-03",0.23,1,0],["06-03",0.45,1,0.34],["06-03",0.81,1,3.45],["07-03",0.65,1,0.34],["07-03",0.35,1,0.34],["07-03",0.81,1,3.45],["07-03",0.21,1,3.45]]
> //to draw the chart
> function drawChart(response) {
> var data = google.visualization.arrayToDataTable(response);
>
> var options = {
> title: 'Host 1', colors:['blue','green','red',],
> chartArea:{left:40,top:25,width:450,height:200},
> height:270,
> };
>
> var chart = new google.visualization.LineChart(
> document.getElementById('graph1'));
> chart.draw(data, options);
> }
>
> is there a way to display each date only once?
>
> 2) I tried to do this with annotation timeline too but it always says date
> format wrong.
> in my php code i do this
> $a= date('Y,m,d',strtotime($row['Timestamp']);
> $temp[] = ( $a);
> the error is:Uncaught Error: Type mismatch. Value 2014,03,05 does not
> match type date in column index 0
>
>
--
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/d/optout.