Skip to content

Commit

Permalink
Namespace fix [for 2.4] (#14)
Browse files Browse the repository at this point in the history
* Namespace fix

* Update unit-tests.yml
  • Loading branch information
DarkSide666 authored Dec 5, 2020
1 parent ee63d17 commit e0e1cbb
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 36 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
}
}
}
17 changes: 9 additions & 8 deletions demo/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="atk4\core\AtkPhpunit\ResultPrinter">
<phpunit colors="true" bootstrap="vendor/autoload.php" printerClass="Atk4\Core\AtkPhpunit\ResultPrinter">
<php>
<var name="DB_DSN" value="sqlite::memory:" />
<var name="DB_USER" value="" />
Expand Down
2 changes: 1 addition & 1 deletion src/BarChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace atk4\chart;
namespace Atk4\Chart;

class BarChart extends Chart
{
Expand Down
16 changes: 8 additions & 8 deletions src/Chart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/ChartBox.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 5 additions & 5 deletions src/PieChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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, ",");
Expand Down
6 changes: 3 additions & 3 deletions tests/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -13,6 +13,6 @@ class BasicTest extends AtkPhpunit\TestCase
*/
public function testTesting()
{
$this->assertSame('foo', 'foo');
$this->assertTrue(true);
}
}

0 comments on commit e0e1cbb

Please sign in to comment.