I'm using JSON data to feed a line chart, and the first column is all unix timestamps.
Is there an easy way to have the chart automatically show those as readable dates instead of just the number of seconds?
here is my code as of now:
<head>
<title>KEGERATOR</title>
<link rel="stylesheet" type="text/css" href="style/style.css" media="screen" />
<!-- Load jQuery -->
<script language="javascript" type="text/javascript"
</script>
<!-- Load Google JSAPI -->
<script type="text/javascript">
$.ajaxSetup ({
// Disable caching of AJAX responses */
cache: false
});
google.load("visualization", "1", { packages: ["corechart"] });
google.load('visualization', '1.0', {'packages':['controls']});
google.setOnLoadCallback(drawChart);
function drawChart() {
var jsonData = $.ajax({
url: "chartselect.php?limit=<?php echo $limit;?>&s1=<?php echo $s1;?>&s2=<?php echo $s2;?>&s3=<?php echo $s3;?>&s4=<?php echo $s4;?>&s5=<?ph\
p echo $s5?>&s6=<?php echo $s6?><?php if ($res) echo '&res='.$res?>",
dataType: "json",
async: false
}).responseText;
var obj = jQuery.parseJSON(jsonData);
var data = google.visualization.arrayToDataTable(obj);
var chart = new google.visualization.ChartWrapper({
chartType: 'LineChart',
containerId: 'chart_div',
options: {
chartArea: {
left: '0%',
width: '100%',
top: '0%',
height: '100%'
},
theme: 'maximized'
}});
var control = new google.visualization.ControlWrapper({
controlType: 'ChartRangeFilter',
containerId: 'control_div',
options: {
filterColumnIndex: 0, //set the column index to filter on here
ui: {
chartOptions: {
chartArea: {
left: '0%',
width: '100%',
top: '10%',
height: '100%'
},
}
}
}
});
var dashboard = new google.visualization.Dashboard(document.querySelector('#dashboard'));
dashboard.bind([control], [chart]);
dashboard.draw(data);
}