From 4414290e7f8cefb228e2201543d045e4fdf185de Mon Sep 17 00:00:00 2001 From: DarkSide Date: Mon, 29 Jun 2020 21:01:20 +0300 Subject: [PATCH] fix --- demo/index.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/demo/index.php b/demo/index.php index a75d4b2..5554a45 100644 --- a/demo/index.php +++ b/demo/index.php @@ -22,18 +22,19 @@ $m->addFields(['name', 'sales', 'purchases', 'profit']); $m->onHook($m::HOOK_AFTER_LOAD, function ($m) { $m->set('profit', $m->get('sales') - $m->get('purchases')); }); $app = new App('Chart Demo'); -$app->initLayout(\atk4\ui\Layout\Centered::class); +$app->initLayout([\atk4\ui\Layout\Centered::class]); + +// split in columns +$columns = Columns::addTo($app->layout); // Lets put your chart into a box: -$columns = $app->layout->add(Columns::class); -$cb = $columns->addColumn(8)->add(new ChartBox(['label' => ['Demo Bar Chart', 'icon' => 'book']])); -$chart = $cb->add(new BarChart()); +$cb = ChartBox::addTo($columns->addColumn(8), ['label' => ['Demo Bar Chart', 'icon' => 'book']]); +$chart = BarChart::addTo($cb); $chart->setModel($m, ['name', 'sales', 'purchases', 'profit']); $chart->withCurrency('$'); // Tweak our chart to support currencies better - -$cb = $columns->addColumn(8)->add(new ChartBox(['label' => ['Demo Pie Chart', 'icon' => 'book']])); -$chart = $cb->add(new PieChart()); +$cb = ChartBox::addTo($columns->addColumn(8), ['label' => ['Demo Pie Chart', 'icon' => 'book']]); +$chart = PieChart::addTo($cb); $chart->setModel($m, ['name', 'profit']); $chart->withCurrency('$');