Skip to content

Commit

Permalink
Updated documentation. Added Engine constants. Removed skipped tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Nov 26, 2023
1 parent 72a6fc7 commit b45bba9
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 214 deletions.
27 changes: 18 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
## [Unreleased]

TBD
### [2.19.18] - 2023-11.26
* Updated documentation
* Added Engine constants
* Removed skipped tests

### [2.0.0] - 2022-03-21
* Added PHP version 8.0.
* Update composer.json
* Update composer.json

### [1.7.0] - 2020-01-12

Expand Down Expand Up @@ -67,12 +76,12 @@ as possible. See http://framework.zend.com/security/advisory/ZF2014-01

* Initial release

[Unreleased]: https://github.com/marcaube/ObHighchartsBundle/compare/1.7...HEAD
[1.7.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.6...1.7
[1.6.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.5...1.6
[1.5.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.4...1.5
[1.4.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.3...1.4
[1.3.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.2...1.3
[1.2.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.1...1.2
[1.1.0]: https://github.com/marcaube/ObHighchartsBundle/compare/1.0.1...1.1
[1.0.1]: https://github.com/marcaube/ObHighchartsBundle/compare/1.0...1.0.1
[Unreleased]: https://github.com/laurentmuller/HighchartsBundle/compare/1.7...HEAD
[1.7.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.6...1.7
[1.6.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.5...1.6
[1.5.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.4...1.5
[1.4.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.3...1.4
[1.3.0]: https://github.com/laurentmuller/HighchartsBundle/1.2...1.3
[1.2.0]: https://github.com/laurentmuller/HighchartsBundle/1.1...1.2
[1.1.0]: https://github.com/laurentmuller/HighchartsBundle/1.0.1...1.1
[1.0.1]: https://github.com/laurentmuller/HighchartsBundle/1.0...1.0.1
59 changes: 33 additions & 26 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
# Contributing

First of all, **thank you** for contributing, **you are awesome**!

Here are a few rules to follow in order to ease code reviews, and discussions before maintainers accept and merge your work.

You MUST follow the [PSR-4](http://www.php-fig.org/psr/psr-4) and [PSR-2](http://www.php-fig.org/psr/2/). If you don't know
about any of them, you should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer tool](http://cs.sensiolabs.org/).

You MUST run the test suite.

You MUST write (or update) unit tests.

You SHOULD write documentation.

Please, write [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) before submitting your Pull Request.

One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
too. This is used to "clean" your Pull Request before merging it (we don't want commits such as `fix tests`, `fix 2`,
`fix 3`, etc.).

Also, while creating your Pull Request on GitHub, you MUST write a description which gives the context and/or explains
why you are creating it.

Thank you!
# Contributing

First of all, **thank you** for contributing, **you are awesome**!

Here are a few rules to follow in order to ease code reviews, and discussions before maintainers accept and merge your work.

You MUST follow the [PSR-4](http://www.php-fig.org/psr/psr-4) and [PSR-2](http://www.php-fig.org/psr/2/). If you don't know
about any of them, you should really read the recommendations. Can't wait? Use the [PHP-CS-Fixer tool](http://cs.sensiolabs.org/).

You MUST run the test suite.

You MUST write (or update) unit tests.

You SHOULD write documentation.

Please, write [commit messages that make sense](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html),
and [rebase your branch](http://git-scm.com/book/en/Git-Branching-Rebasing) before submitting your Pull Request.

One may ask you to [squash your commits](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)
too. This is used to "clean" your Pull Request before merging it (we don't want commits such as `fix tests`, `fix 2`,
`fix 3`, etc.).

Also, while creating your Pull Request on GitHub, you MUST write a description which gives the context and/or explains
why you are creating it.

Thank you!

## See also:

- [Installation](resources/doc/installation.md)
- [Usage](resources/doc/usage.md)
- [Cookbook](resources/doc/cookbook.md)
- [Home Page](README.md)
38 changes: 19 additions & 19 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
Copyright (c) 2015 Marc Aube

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Copyright (c) 2023 Laurent Muller
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# HighchartsBundle

This is fork of the [ObHighchartsBundle](https://github.com/marcaube/ObHighchartsBundle) with support for PHP 8.0.

`HighchartsBundle` eases the use of highcharts to display rich graphs and charts in your Symfony application by
providing Twig extensions and PHP objects to do the heavy lifting. The bundle uses the excellent JS library
[Highcharts](https://www.highcharts.com).


DRY out your chart code by writing it all in PHP!

[![Php-cs-fixer](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-cs-fixer.yaml/badge.svg)](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-cs-fixer.yaml)
[![PHP-Stan](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-stan.yaml/badge.svg)](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-stan.yaml)
[![Rector](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/rector.yaml/badge.svg)](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/rector.yaml/badge.svg)
[![PHPUnit](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-unit.yaml/badge.svg)](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/php-unit.yaml)
[![Psalm Static analysis](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/psalm.yaml/badge.svg)](https://github.com/laurentmuller/ObHighchartsBundle/actions/workflows/psalm.yaml)
[![Php-cs-fixer](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-cs-fixer.yaml/badge.svg)](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-cs-fixer.yaml)
[![PHP-Stan](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-stan.yaml/badge.svg)](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-stan.yaml)
[![Rector](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/rector.yaml/badge.svg)](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/rector.yaml)
[![PHPUnit](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-unit.yaml/badge.svg)](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/php-unit.yaml)
[![Psalm Static analysis](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/psalm.yaml/badge.svg)](https://github.com/laurentmuller/HighchartsBundle/actions/workflows/psalm.yaml)
[![StyleCI](https://github.styleci.io/repos/472412531/shield?branch=master)](https://github.styleci.io/repos/472412531?branch=master)

## Documentation
Expand All @@ -26,7 +29,7 @@ See [CONTRIBUTING](CONTRIBUTING.md) file.

## License

ObHighchartsBundle is released under the MIT License. See the bundled [LICENSE](LICENSE) file for details.
HighchartsBundle is released under the MIT License. See the bundled [LICENSE](LICENSE) file for details.

Please note that the Highcharts JS library is **not** free for commercial use, see their
[FAQ](http://shop.highsoft.com/faq) for more details on what constitutes a non-commercial project or their
Expand Down
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions resources/doc/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,9 @@ $formatter = new Expr('function () {
$chart->tooltip->formatter($formatter);
$chart->series($series);
```

## See also:

- [Installation](installation.md)
- [Usage](usage.md)
- [Home Page](../../README.md)
6 changes: 6 additions & 0 deletions resources/doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@
...
]
```

## See also:

- [Usage](usage.md)
- [Cookbook](cookbook.md)
- [Home Page](../../README.md)
6 changes: 6 additions & 0 deletions resources/doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,9 @@ $chart = new Highchart();
$chart->tooltip->formatter($func);
// ...
```

## See also:

- [Installation](installation.md)
- [Cookbook](cookbook.md)
- [Home Page](../../README.md)
24 changes: 15 additions & 9 deletions src/Highcharts/AbstractChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
abstract class AbstractChart implements ChartInterface
{
// the script end line
private const END_LINE = ",\n";
protected const END_LINE = ",\n";

// the script new line
protected const NEW_LINE = "\n";

// the space prefix
private const SPACE = ' ';
protected const SPACE = ' ';

// The Zend json encode options.
private const ZEND_ENCODE_OPTIONS = ['enableJsonExprFinder' => true];
Expand Down Expand Up @@ -75,7 +78,10 @@ public function __call(string $name, mixed $value): static
return $this;
}

public function render(string $engine = 'jquery'): string
/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
public function render(string $engine = self::ENGINE_JQUERY): string
{
$chartJS = '';
$this->renderChartStart($chartJS, $engine);
Expand Down Expand Up @@ -188,9 +194,9 @@ protected function renderChartCommon(string &$chartJS): void
protected function renderChartEnd(string &$chartJS, string $engine): void
{
// trim last trailing comma and close parenthesis
$chartJS = \rtrim($chartJS, self::END_LINE) . "\n });\n";
$chartJS = \rtrim($chartJS, self::END_LINE) . "\n });" . self::NEW_LINE;
if ('' !== $engine) {
$chartJS .= "});\n";
$chartJS .= '});' . self::NEW_LINE;
}
}

Expand All @@ -217,8 +223,8 @@ protected function renderCredits(): string
protected function renderEngine(string $engine): string
{
return match ($engine) {
'mootools' => 'window.addEvent(\'domready\', function () {',
'jquery' => '$(function () {',
self::ENGINE_MOOTOOLS => 'window.addEvent(\'domready\', function () {',
self::ENGINE_JQUERY => '$(function () {',
default => '',
};
}
Expand Down Expand Up @@ -249,11 +255,11 @@ protected function renderOptions(): string
return '';
}

$result = "\n Highcharts.setOptions({\n";
$result = self::NEW_LINE . self::SPACE . ' Highcharts.setOptions({' . self::NEW_LINE;
$result .= $this->renderGlobal();
$result .= $this->renderLang();

return $result . " });\n";
return $result . self::SPACE . '});' . self::NEW_LINE;
}

protected function renderPlotOptions(): string
Expand Down
9 changes: 9 additions & 0 deletions src/Highcharts/ChartInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,14 @@
*/
interface ChartInterface
{
public const ENGINE_JQUERY = 'jquery';

public const ENGINE_MOOTOOLS = 'mootools';

public const ENGINE_NONE = '';

/**
* @psalm-param self::ENGINE_* $engine
*/
public function render(string $engine): string;
}
2 changes: 1 addition & 1 deletion src/Highcharts/Highchart.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function renderChartOptions(string &$chartJS): void
protected function renderChartStart(string &$chartJS, string $engine): void
{
parent::renderChartStart($chartJS, $engine);
$chartJS .= " const {$this->getRenderTo()} = new Highcharts.Chart({\n";
$chartJS .= self::SPACE . "const {$this->getRenderTo()} = new Highcharts.Chart({" . self::NEW_LINE;
}

private function renderColorAxis(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Highcharts/Highstock.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function renderChartOptions(string &$chartJS): void
protected function renderChartStart(string &$chartJS, string $engine): void
{
parent::renderChartStart($chartJS, $engine);
$chartJS .= " const {$this->getRenderTo()} = new Highcharts.StockChart({\n";
$chartJS .= self::SPACE . "const {$this->getRenderTo()} = new Highcharts.StockChart({" . self::END_LINE;
}

protected function renderRangeSelector(): string
Expand Down
5 changes: 4 additions & 1 deletion src/Twig/HighchartsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@

class HighchartsExtension extends AbstractExtension
{
public function chart(ChartInterface $chart, string $engine = 'jquery'): string
/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
public function chart(ChartInterface $chart, string $engine = ChartInterface::ENGINE_JQUERY): string
{
return $chart->render($engine);
}
Expand Down
3 changes: 3 additions & 0 deletions tests/AbstractChartTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

class AbstractChartTestCase extends TestCase
{
/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
protected function assertChartMatchesRegularExpression(ChartInterface $chart, string $regex, string $engine = 'jquery'): void
{
$result = $chart->render($engine);
Expand Down
13 changes: 0 additions & 13 deletions tests/Highcharts/ExportingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,6 @@ public function testButtons(): void
// width option (integer - width in px)
// x option (integer - horizontal offset in px)
// y option (integer - vertical offset in px)
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}

/**
* chartOptions option.
*/
public function testChartOptions(): void
{
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}

/**
Expand Down
7 changes: 0 additions & 7 deletions tests/Highcharts/PaneTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
*/
class PaneTest extends AbstractChartTestCase
{
public function testBackground(): void
{
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}

public function testCenter(): void
{
$chart = new Highchart();
Expand Down
Loading

0 comments on commit b45bba9

Please sign in to comment.