<?php

	$data = mysql_select("check_ins", "`createdDate` > '2019-01-01 00:01:00' GROUP BY DATE_FORMAT(`createdDate`, '%Y-%m-%d')", "DATE_FORMAT(`createdDate`, '%Y-%m-%d') as date, count(num) as value");
	
?>

<div id="lineChart"></div>
<script>
/**
 * ---------------------------------------
 * This demo was created using amCharts 4.
 * 
 * For more information visit:
 * https://www.amcharts.com/
 * 
 * Documentation is available at:
 * https://www.amcharts.com/docs/v4/
 * ---------------------------------------
 */

// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end

var chart = am4core.create("lineChart", am4charts.XYChart);

var data = <?php echo json_encode($data); ?>;
var value = 50;
// for(let i = 0; i < 300; i++){
//   let date = new Date();
//   date.setHours(0,0,0,0);
//   date.setDate(i);
//   value -= Math.round((Math.random() < 0.5 ? 1 : -1) * Math.random() * 10);
//   data.push({date:date, value: value});
// }

chart.data = data;

// Create axes
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.renderer.minGridDistance = 60;

var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());

// Create series
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = "value";
series.dataFields.dateX = "date";
series.tooltipText = "{date} : {value}"

series.tooltip.pointerOrientation = "vertical";

chart.cursor = new am4charts.XYCursor();
chart.cursor.snapToSeries = series;
chart.cursor.xAxis = dateAxis;

//chart.scrollbarY = new am4core.Scrollbar();
chart.scrollbarX = new am4core.Scrollbar();
</script>