Example #1
0
<script type="text/javascript" src="../../JSC/JSCharting.js"></script>
<?php 
$startDate = new DateTime('2014-10-1');
$endDate = new DateTime('2014-10-31 23:59:59');
$title = 'Sales From ' . date_format($startDate, 'm/d/Y') . ' to ' . date_format($endDate, 'm/d/Y') . ',  Total : %sum';
$de = new DataEngine();
$de->addParameter($startDate);
$de->addParameter($endDate);
$de->sqlStatement = 'SELECT OrderDate AS Month, SUM(Total) AS Sales FROM Orders
WHERE OrderDate >=? And OrderDate <=?
    GROUP BY DAY(OrderDate)
    ORDER BY DAY(OrderDate);';
$de->dataFields = 'xAxis=Month,yAxis=Sales';
//default setting
$de->dateGrouping = "Month";
$series = $de->getSeries();
?>


		<title>JSCharting  Month DB Chart</title>
		  <style type="text/css">/*CSS*/</style>
	</head>
	<body>
	<div id="cc" style="width: 840px; height: 400px"></div>
	
<script type="text/javascript">
/*
Query a Database using PHP to get day data for a month.
Learn how to:

  - Select MySql database data based on a date range.
Example #2
0
$startDate = new DateTime('2014-1-1');
$endDate = new DateTime('2014-12-31 23:59:59');
$de->addParameter($startDate);
$de->addParameter($endDate);
$title = 'Orders From ' . date_format($startDate, 'm/d/Y') . ' to ' . date_format($endDate, 'm/d/Y');
$de->sqlStatement = 'SELECT MONTH(OrderDate) AS Month, SUM(1) AS Orders FROM Orders
WHERE OrderDate >=? And OrderDate <=? GROUP BY MONTH(OrderDate)ORDER BY MONTH(OrderDate);';
$series = $de->getSeries();
//Second Chart Data
$de = new DataEngine();
$de->addParameter($startDate);
$de->addParameter($endDate);
$title2 = 'Sales From ' . date_format($startDate, 'm/d/Y') . ' to ' . date_format($endDate, 'm/d/Y');
$de->sqlStatement = 'SELECT MONTH(OrderDate) AS Month, SUM(Total) AS Sales FROM Orders
WHERE OrderDate >=? And OrderDate <=? GROUP BY MONTH(OrderDate)ORDER BY MONTH(OrderDate);';
$series2 = $de->getSeries();
?>


		<title>JSCharting  Multi Chart DB Chart</title>
		  <style type="text/css">/*CSS*/</style>
	</head>
	<body>
	<div id="cc" style="width: 840px; height: 400px"></div>
            <div id="cc2" style="width: 840px; height: 400px"></div>
	
<script type="text/javascript">
/*
Multiple charts that query a Database using PHP.
Learn how to: