Iam using Google Chart to Show my sales Graph
In my chart in need to display the date wise sales
in X-axis the dates and Y Axis Amount
But in google chart, I can't able to print the date. Below is my code
<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js">
</script>
</head>
<body>
<div id="curve_chart" style="width: 900px; height: 500px"></div>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart(){
var data = new google.visualization.DataTable();
data.addColumn('datetime', 'Time of Day');
data.addColumn('number','Head Office');
data.addColumn('number','Mohans Shoppy');
data.addColumn('number','My shoppy');
data.addRows([
[[new Date(2019,03,02)],2599,0,0],[[new Date(2019,03,03)],0,0,0],[[new Date(2019,03,04)],28625,0,15900],[[new Date(2019,03,05)],3934,0,0],[[new Date(2019,03,06)],0,0,0],[[new Date(2019,03,07)],3201,0,0],[[new Date(2019,03,09)],1500,0,0],
]);
var options = {
title: 'Sales Chart',
legend: { position: 'bottom' },
width: 900,
height: 500
};
var chart = new google.visualization.LineChart(document.getElementById('curve_chart'));
chart.draw(data, options);
}
</script>
</body>
</html>
Iam getting the error in console: Uncaught (in promise) Error: Type mismatch. Value Tue Apr 02 2019 00:00:00 GMT+0530 (India Standard Time) does not match type datetime in column index 0
答案 0 :(得分:1)
[new Date(2019,03,02),2599,0,0],
[new Date(2019,03,03),0,0,0],
[new Date(2019,03,04),28625,0,15900],
[new Date(2019,03,05),3934,0,0],
[new Date(2019,03,06),0,0,0],
[new Date(2019,03,07),3201,0,0],
[new Date(2019,03,09),1500,0,0],
您又添加了一个[]。