diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index 38f71c9..d7a89d2 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -30,13 +30,9 @@ jobs: - name: Configure PHP run: | - if [ -z "$LOG_COVERAGE" ]; then rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini ; fi + if [ -n "$LOG_COVERAGE" ]; then echo "xdebug.mode=coverage" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; else rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini; fi php --version - # trick composer that this is a "atk4/data:develop" dependency to install atk4/schema - - name: Rename HEAD to develop for Composer - run: git switch -C develop HEAD - - name: Setup cache 1/2 id: composer-cache run: | diff --git a/composer.json b/composer.json index 3f0e9e3..fd3e72f 100644 --- a/composer.json +++ b/composer.json @@ -36,12 +36,12 @@ }, "autoload": { "psr-4": { - "atk4\\chart\\": "src/" + "Atk4\\Chart\\": "src/" } }, "autoload-dev": { "psr-4": { - "atk4\\chart\\tests\\": "tests/" + "Atk4\\Chart\\Tests\\": "tests/" } } } diff --git a/demo/index.php b/demo/index.php index 5554a45..ea22262 100644 --- a/demo/index.php +++ b/demo/index.php @@ -4,13 +4,14 @@ require '../vendor/autoload.php'; -use atk4\chart\BarChart; -use atk4\chart\ChartBox; -use atk4\chart\PieChart; -use atk4\data\Model; -use atk4\data\Persistence\Array_; -use atk4\ui\App; -use atk4\ui\Columns; +use Atk4\Chart\BarChart; +use Atk4\Chart\ChartBox; +use Atk4\Chart\PieChart; +use Atk4\Data\Model; +use Atk4\Data\Persistence\Array_; +use Atk4\Ui\App; +use Atk4\Ui\Columns; +use Atk4\Ui\Layout; $p = ['t' => [ ['name' => 'January', 'sales' => 20000, 'purchases' => 10000], @@ -22,7 +23,7 @@ $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([Layout\Centered::class]); // split in columns $columns = Columns::addTo($app->layout); diff --git a/phpunit.xml.dist b/phpunit.xml.dist index aeb0eac..2beed80 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,4 +1,4 @@ - + diff --git a/src/BarChart.php b/src/BarChart.php index 0fc6b98..e3550ff 100644 --- a/src/BarChart.php +++ b/src/BarChart.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace atk4\chart; +namespace Atk4\Chart; class BarChart extends Chart { diff --git a/src/Chart.php b/src/Chart.php index be9d83a..84d5403 100644 --- a/src/Chart.php +++ b/src/Chart.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace atk4\chart; +namespace Atk4\Chart; -use atk4\core\Exception; -use atk4\data\Model; -use atk4\ui\jsExpression; -use atk4\ui\View; +use Atk4\Core\Exception; +use Atk4\Data\Model; +use Atk4\Ui\JsExpression; +use Atk4\Ui\View; /** * Implement basic logic for ChartJS. @@ -59,7 +59,7 @@ protected function init(): void */ public function renderView(): void { - $this->js(true, new jsExpression('new Chart([], []);', [$this->name, $this->getConfig()])); + $this->js(true, new JsExpression('new Chart([], []);', [$this->name, $this->getConfig()])); parent::renderView(); } @@ -175,13 +175,13 @@ public function withCurrency(string $char = '€', string $axis = 'y') // magic regex adds commas as thousand separators: http://009co.com/?p=598 $options['scales'][$axis . 'Axes'] = [['ticks' => [ - 'userCallback' => new jsExpression('{}', ['function(value) { value=Math.round(value*1000000)/1000000; return "' . $char . ' " + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }']), + 'userCallback' => new JsExpression('{}', ['function(value) { value=Math.round(value*1000000)/1000000; return "' . $char . ' " + value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); }']), ]]]; $options['tooltips'] = [ 'enabled' => true, 'mode' => 'single', - 'callbacks' => ['label' => new jsExpression('{}', ['function(item, data) { return item.' . $axis . 'Label ? "' . $char . ' " + item.' . $axis . 'Label.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : "No Data"; }'])], + 'callbacks' => ['label' => new JsExpression('{}', ['function(item, data) { return item.' . $axis . 'Label ? "' . $char . ' " + item.' . $axis . 'Label.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",") : "No Data"; }'])], ]; $this->setOptions($options); diff --git a/src/ChartBox.php b/src/ChartBox.php index ce80089..8cee983 100644 --- a/src/ChartBox.php +++ b/src/ChartBox.php @@ -2,10 +2,10 @@ declare(strict_types=1); -namespace atk4\chart; +namespace Atk4\Chart; -use atk4\ui\Label; -use atk4\ui\View; +use Atk4\Ui\Label; +use Atk4\Ui\View; /** * Implements a box that contains a chart. diff --git a/src/PieChart.php b/src/PieChart.php index 18b9c42..f1f309a 100644 --- a/src/PieChart.php +++ b/src/PieChart.php @@ -2,11 +2,11 @@ declare(strict_types=1); -namespace atk4\chart; +namespace Atk4\Chart; -use atk4\core\Exception; -use atk4\data\Model; -use atk4\ui\jsExpression; +use Atk4\Core\Exception; +use Atk4\Data\Model; +use Atk4\Ui\JsExpression; class PieChart extends Chart { @@ -77,7 +77,7 @@ public function withCurrency(string $char = '€', string $axis = 'y') //'enabled' => true, //'mode' => 'single', 'callbacks' => [ - 'label' => new jsExpression('{}', [ + 'label' => new JsExpression('{}', [ 'function(item, data, bb) { var val = data.datasets[item.datasetIndex].data[item.index]; return "' . $char . '" + val.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); diff --git a/tests/BasicTest.php b/tests/BasicTest.php index dd4c122..ba27383 100644 --- a/tests/BasicTest.php +++ b/tests/BasicTest.php @@ -2,9 +2,9 @@ declare(strict_types=1); -namespace atk4\ui\tests; +namespace Atk4\Chart\Tests; -use atk4\core\AtkPhpunit; +use Atk4\Core\AtkPhpunit; class BasicTest extends AtkPhpunit\TestCase { @@ -13,6 +13,6 @@ class BasicTest extends AtkPhpunit\TestCase */ public function testTesting() { - $this->assertSame('foo', 'foo'); + $this->assertTrue(true); } }