-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6bed94
commit 6108000
Showing
3 changed files
with
16 additions
and
9 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,35 @@ | ||
<?php | ||
require '../vendor/autoload.php'; | ||
|
||
use atk4\chart\ChartBox; | ||
use atk4\chart\BarChart; | ||
use atk4\chart\PieChart; | ||
use atk4\data\Model; | ||
use atk4\data\Persistence\Array_; | ||
use atk4\ui\App; | ||
|
||
$p = ['t'=>[ | ||
[ 'name'=>'January', 'sales'=>20000, 'purchases'=>10000, ], | ||
[ 'name'=>'February', 'sales'=>23000, 'purchases'=>12000, ], | ||
[ 'name'=>'March', 'sales'=>16000, 'purchases'=>11000, ], | ||
[ 'name'=>'April', 'sales'=>14000, 'purchases'=>13000, ], | ||
]]; | ||
$m = new \atk4\data\Model(new \atk4\data\Persistence_Array($p), 't'); | ||
$m = new Model(new Array_($p), 't'); | ||
$m->addFields(['name', 'sales', 'purchases', 'profit']); | ||
$m->addHook('afterLoad', function($m) { $m['profit'] = $m['sales'] - $m['purchases']; }); | ||
$app = new \atk4\ui\App('Chart Demo'); | ||
$app = new App('Chart Demo'); | ||
$app->initLayout('Centered'); | ||
|
||
// Lets put your chart into a box: | ||
$columns = $app->layout->add('Columns'); | ||
$cb = $columns->addColumn(10)->add(new \atk4\chart\ChartBox(['label'=>['Demo Chart', 'icon'=>'book']])); | ||
$chart = $cb->add(new \atk4\chart\BarChart()); | ||
$cb = $columns->addColumn(10)->add(new ChartBox(['label'=>['Demo Chart', 'icon'=>'book']])); | ||
$chart = $cb->add(new BarChart()); | ||
$chart->setModel($m, ['name', 'sales', 'purchases','profit']); | ||
$chart->withCurrency('$'); | ||
|
||
// Tweak our chart to support currencies better | ||
|
||
$cb = $columns->addColumn(6)->add(new \atk4\chart\ChartBox(['label'=>['Demo Chart', 'icon'=>'book']])); | ||
$chart = $cb->add(new \atk4\chart\PieChart()); | ||
$cb = $columns->addColumn(6)->add(new ChartBox(['label'=>['Demo Chart', 'icon'=>'book']])); | ||
$chart = $cb->add(new PieChart()); | ||
$chart->setModel($m, ['name', 'profit']); | ||
$chart->withCurrency('$'); |
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
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