Created
February 17, 2016 20:55
-
-
Save kevinkhill/f049e08b0ea159f60b68 to your computer and use it in GitHub Desktop.
Testing 3.1 branch with lava.js overhaul
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(-1); | |
require('Carbon-1.18.0\src\Carbon\Carbon.php'); | |
require('../lavacharts/src/Lavacharts.php'); | |
use \Khill\Lavacharts\Lavacharts; | |
$lava = new Lavacharts; | |
$lineData = $lava->DataTable(); | |
$lineData->addDateColumn('Dates') | |
->addNumberColumn('Prices'); | |
for ($i=1; $i < 30; $i++) { | |
$lineData->addRow(["2016-1-".$i, rand(50,100)]); | |
} | |
$lava->LineChart('Prices Of Goods', $lineData->bare(), [ | |
'elementId' => 'line', | |
'legend' => 'none', | |
'pointSize' => 5 | |
]); | |
$scatterData = $lava->DataTable(); | |
$scatterData->addNumberColumn('Diameter') | |
->addNumberColumn('Age') | |
->addRows([ | |
[8, 37], [4, 19.5], [11, 52], [4, 22], [3, 16.5], [6.5, 32.8], [14, 72] | |
]); | |
$lava->ScatterChart('Trees', $scatterData->bare(), [ | |
'trendlines' => [ | |
0 => [ | |
'type' => 'linear', | |
'color' => 'red', | |
'pointsVisible'=>true, | |
'pointSize' => 1 | |
] | |
] | |
], 'scatter'); | |
$areaData = $lava->DataTable(); | |
$areaData->addDateColumn('Dates') | |
->addNumberColumn('Prices'); | |
for ($i=1; $i < 30; $i++) { | |
$areaData->addRow(["2016-1-".$i, rand(50,100)]); | |
} | |
$lava->AreaChart('Prices', $areaData->bare()); | |
?> | |
<html> | |
<head> | |
<title>Test</title> | |
<link rel="shortcut icon" href="data:image/x-icon;," type="image/x-icon"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script> | |
</head> | |
<body> | |
<div id="line"></div> | |
<div id="scatter"></div> | |
<div id="prices"></div> | |
<?php | |
echo $lava->renderAll(); | |
?> | |
<script type="text/javascript"> | |
lava.ready(function() { | |
$.getJSON('http://localhost:8000/data.php', function (data) { | |
lava.loadData('Prices', data.area); | |
lava.loadData('Trees', data.scatter); | |
lava.loadData('Prices Of Goods', data.line); | |
}) | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment