2
Today I went to visualize a graph that I have and I realized that it was all messed up but I didn’t understand why. I looked, reviewed, retested and no going back to normal. I’m guessing it’s a date and time conversion problem for google Chart...
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Data', 'Sales', 'Expenses'],
[new Date(2020, 10, 30, 10, 36), 1000, 400],
[new Date(2020, 10, 30, 12, 36), 1170, 460],
[new Date(2020, 10, 30, 14, 36), 660, 1120],
[new Date(2020, 10, 31, 16, 36), 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: '#333'}},
vAxis: {minValue: 0}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 100%; height: 500px;"></div>
</body>
</html>
I am based on this basic example. The dates of the day 31/10/2020 ends up being converted to 01/12/2020.
Is that I’m missing something unnoticed or will be some conversion problem on google Chart?
Gosh, I’ve been putting the chart together for a few days now and it’s gone completely unnoticed, especially since I’m feeding it just data from the current day and all of a sudden it’s all messed up and I’m lost. Vlw For the help.
– MichellHenrique