Hi
I'd like to know if it's possible to show dates and hours on the x-axis of the Line chart.
Indeed I'd like to show a stock value which is updated twice a day (11:00 AM and 11:00 PM).
So is it possible to show 2 values within the same day ?
I tried that code :[new Date(year, month ,day , hour, minutes), value, null, null],
But it didn't work.
Is there an answer to my issue ?
PS : excuse my english
{format:'Y,M,d,H'} )
the error is "missing } after property list (retrieve_cache?unique_id=eab68f34d8191baa7031f8541e6e6a71062a8bd5,61)"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Google Visualization API Sample</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {packages: ['annotatedtimeline']});
function drawVisualization() {
var data = new google.visualization.DataTable();
data.addColumn('date', 'Date');
data.addColumn('number', 'Sold Pencils');
data.addColumn('string', 'title1');
data.addColumn('string', 'text1');
data.addRows([
[new Date(12133699), 30000, 'title', 'message1'],
[new Date(12139699), 30000, 'title2', 'message 2'],
[new Date(1224445555), 14045, null, null],
[new Date(1236547890), 55022, null, null],
[new Date(124569873), 75284, null, null],
[new Date(156987413), 41476, 'Bought Pens', 'Bought 200k pens'],
]);
var annotatedtimeline = new google.visualization.AnnotatedTimeLine(
document.getElementById('visualization'));
annotatedtimeline.draw(data, {'displayAnnotations': true});
var dateFormatter = new google.visualization.DateFormat({pattern: 'Y,M,d,H'});
dateFormatter.format(data, 0);
}
google.setOnLoadCallback(drawVisualization);
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="visualization" style="width: 800px; height: 400px;"></div>
</body>
</html>
The date and dateTime formating in the right top corner you can easily control with one option:
vizOptions = {
dateFormat: 'dd.MM.yy hh:mm'
};
vizChart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
vizChart.draw(vizTable, vizOptions);
}
I tried several ways to change the dateTime format on the x-axis but was not successful:
vizOptions = {
dateFormat: 'dd.MM.yy hh:mm',
hAxis: {format: 'Y,M,d,H'}
};
var formatter = new google.visualization.DateFormat({formatType: 'short'});
formatter.format(vizTable, 0);
vizChart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));
vizChart.draw(vizTable, vizOptions);
}
It is simply ignored by the Google API. Is this bug already in the official bug reporting?
alert(date.toLocaleDateString("ar-EG"));
// → "٢٠/١٢/٢٠١٢"var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));