Skip to content

Commit

Permalink
Added chart class property. Added lint markdown action.
Browse files Browse the repository at this point in the history
  • Loading branch information
laurentmuller committed Nov 28, 2023
1 parent f2d3c49 commit 35773c9
Show file tree
Hide file tree
Showing 7 changed files with 123 additions and 79 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/markdown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Markdown Lint

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Lint
uses: DavidAnson/markdownlint-cli2-action@v14
with:
globs: '*.md'
131 changes: 72 additions & 59 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,87 +1,100 @@
# Changelog
# Change log

## [Unreleased]

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

### [2.20.1] - 2023-11-28

- Added chart class property
- Added lint markdown action

### [2.20.0] - 2023-11-28

- Removed pretty print option

### [2.19.19] - 2023-11-28

- Updated tests
- Reworked script output.

### [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

### [1.7.0] - 2020-01-12
- Added PHP version 8.2.
- Update composer.json

* Add support for Symfony 5
* Add support for Twig 3
* Drop support for PHP < 7.2
### 1.7.0 - 2020-01-12

### [1.6.0] - 2017-12-27
- Add support for Symfony 5
- Add support for Twig 3
- Drop support for PHP < 7.2

* Add support for Symfony 4
### 1.6.0 - 2017-12-27

### [1.5.0] - 2016-07-26
- Add support for Symfony 4

* Improve Travis configuration, test on PHP 7
* Add support for zend-json ~3.0
* Fix Symfony 3.1 deprecation notice for YAML scalars starting with `%`
### 1.5.0 - 2016-07-26

### [1.4.0] - 2016-01-10
- Improve Travis configuration, test on PHP 7
- Add support for zend-json ~3.0
- Fix Symfony 3.1 deprecation notice for YAML scalars starting with `%`

* Update version constraint to support Symfony 3
### 1.4.0 - 2016-01-10

### [1.3.0] - 2015-10-10
- Update version constraint to support Symfony 3

* Update to PSR-4 auto-loading
* Add support for colorAxis
* Add support for noData
### 1.3.0 - 2015-10-10

### [1.2.0] - 2014-08-04
- Update to PSR-4 auto-loading
- Add support for colorAxis
- Add support for noData

* Refactor deprecated Twig_Function_Method to Twig_SimpleFunction
* Add support for lang
* Test on more PHP versions and also HHVM
* Add support for drilldown
* Add support for setOptions
* Drop support for deprecated versions of Symfony
* Add support for scrollbar
### 1.2.0 - 2014-08-04

### [1.1.0] - 2014-06-26
- Refactor deprecated Twig_Function_Method to Twig_SimpleFunction
- Add support for lang
- Test on more PHP versions and also HHVM
- Add support for drilldown
- Add support for setOptions
- Drop support for deprecated versions of Symfony
- Add support for scrollbar

### 1.1.0 - 2014-06-26

This release fixes a security issue. You are encouraged to update to it as soon
as possible. See http://framework.zend.com/security/advisory/ZF2014-01

Check failure on line 71 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / build

Bare URL used

CHANGELOG.md:71:18 MD034/no-bare-urls Bare URL used [Context: "http://framework.zend.com/secu..."] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md034.md

* Add support for pane option
* Add support for Highstock
* Extract a common interface from Highchart and Highstock
* Add support for rangeSelector
* Add a branch alias to composer.json
* Update to Highcharts v4
* Update Zend\Json for a security issue
* Remove bundled assets in favor of Highcharts' CDN (http://code.highcharts.com/)
- Add support for pane option
- Add support for Highstock
- Extract a common interface from Highchart and Highstock
- Add support for rangeSelector
- Add a branch alias to composer.json
- Update to Highcharts v4
- Update Zend\Json for a security issue
- Remove bundled assets in favor of Highcharts' CDN (http://code.highcharts.com/)

Check failure on line 80 in CHANGELOG.md

View workflow job for this annotation

GitHub Actions / build

Bare URL used

CHANGELOG.md:80:54 MD034/no-bare-urls Bare URL used [Context: "http://code.highcharts.com/"] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md034.md

### [1.0.1] - 2013-11-08
### 1.0.1 - 2013-11-08

* Make the JS wrapper optional
* Add support for multiple x-axis
* Update to Highcharts v3.0.6
* Add license to composer.json
* Add doc blocks for IDE type hinting
* Configure Travis to test on Symfony 2.1, 2.2 and 2.3
- Make the JS wrapper optional
- Add support for multiple x-axis
- Update to Highcharts v3.0.6
- Add license to composer.json
- Add doc blocks for IDE type hinting
- Configure Travis to test on Symfony 2.1, 2.2 and 2.3

### 1.0.0 - 2013-08-06

* Initial release

[Unreleased]: https://github.com/laurentmuller/HighchartsBundle/compare/2.19.18...HEAD
[2.0.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.7...2.0
[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
- Initial release

[Unreleased]: https://github.com/laurentmuller/HighchartsBundle/compare/1.7...HEAD
[2.20.1]: https://github.com/laurentmuller/HighchartsBundle/compare/2.20.0...2.20.1
[2.20.0]: https://github.com/laurentmuller/HighchartsBundle/compare/2.19.19...2.20.0
[2.19.19]: https://github.com/laurentmuller/HighchartsBundle/compare/2.19.18...2.19.19
[2.19.18]: https://github.com/laurentmuller/HighchartsBundle/compare/2.0.0...2.19.18
[2.0.0]: https://github.com/laurentmuller/HighchartsBundle/compare/1.7...2.0.0
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HighchartsBundle

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

Check failure on line 3 in README.md

View workflow job for this annotation

GitHub Actions / build

Line length

README.md:3:81 MD013/line-length Line length [Expected: 80; Actual: 114] https://github.com/DavidAnson/markdownlint/blob/v0.32.1/doc/md013.md

`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
Expand All @@ -27,6 +27,10 @@ DRY out your chart code by writing it all in PHP!

See [CONTRIBUTING](CONTRIBUTING.md) file.

## Change log

See [CHANGELOG](CHANGELOG.md) file.

## License

HighchartsBundle is released under the MIT License. See the bundled [LICENSE](LICENSE.md) file for details.
Expand Down
6 changes: 3 additions & 3 deletions resources/doc/cookbook.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Pie chart with legend

This is a simple recipe to re-create the pie-chart demo with legend at [highcharts.com/demo/pie-legend](http://www.highcharts.com/demo/pie-legend)
This is a simple recipe to re-create the pie-chart demo with legend at [highcharts.com/demo/pie-legend](https://www.highcharts.com/demo/pie-legend)

```php
$chart = new Highchart();
Expand Down Expand Up @@ -31,7 +31,7 @@ $chart->series([

## Pie chart with Drilldown

This is a simple recipe to re-create a chart similar to the drilldown pie-chart demo at [highcharts.com/demo/pie-drilldown](http://www.highcharts.com/demo/pie-drilldown)
This is a simple recipe to re-create a chart similar to the drilldown pie-chart demo at [highcharts.com/demo/pie-drilldown](https://www.highcharts.com/demo/pie-drilldown)

```php
$chart = new Highchart();
Expand Down Expand Up @@ -104,7 +104,7 @@ $chart->drilldown->series($drilldown);

## Multi-axes plot

This is a simple recipe for creating a plot with multiple y-axes, similar to [the highcharts demo](http://www.highcharts.com/demo/combo-multi-axes)
This is a simple recipe for creating a plot with multiple y-axes, similar to [the highcharts demo](https://www.highcharts.com/demo/combo-multi-axes)

```php
$series = [
Expand Down
21 changes: 17 additions & 4 deletions src/Highcharts/AbstractChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ protected function createExpression(string $expression, bool $trim = true): Expr
return new Expr($expression);
}

/**
* Gets the chart class (type) to create.
*/
abstract protected function getChartClass(): string;

/**
* Gets the chart render to (target) property.
*/
Expand Down Expand Up @@ -144,7 +149,7 @@ protected function jsonEncode(ChartOption|array $data, string $name = ''): strin

$encoded = \json_encode($data);

return self::SPACE . "$name: $encoded" . self::END_LINE;
return self::SPACE . $name . ': ' . $encoded . self::END_LINE;
}

protected function renderAccessibility(): string
Expand All @@ -167,14 +172,22 @@ protected function renderCallback(ChartOption $option): string
// Zend\Json is used in place of json_encode to preserve JS anonymous functions
$encoded = Json::encode(valueToEncode: $data, options: self::ZEND_ENCODE_OPTIONS);

return self::SPACE . "$name: $encoded" . self::END_LINE;
return self::SPACE . $name . ': ' . $encoded . self::END_LINE;
}

protected function renderChart(): string
{
return $this->renderCallback($this->chart);
}

protected function renderChartClass(): string
{
$renderTo = $this->getRenderTo();
$class = $this->getChartClass();

return self::NEW_LINE . self::HALF_SPACE . "const $renderTo = new Highcharts.$class({" . self::END_LINE;
}

protected function renderChartCommon(string &$chartJS): void
{
$chartJS .= $this->renderChart();
Expand All @@ -195,7 +208,6 @@ 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) . self::NEW_LINE . self::HALF_SPACE . '});' . self::NEW_LINE;
if ('' !== $engine) {
$chartJS .= '});' . self::NEW_LINE;
Expand All @@ -210,6 +222,7 @@ protected function renderChartStart(string &$chartJS, string $engine): void
{
$chartJS .= $this->renderEngine($engine);
$chartJS .= $this->renderOptions();
$chartJS .= $this->renderChartClass();
}

protected function renderColors(): string
Expand Down Expand Up @@ -261,7 +274,7 @@ protected function renderOptions(): string
$result .= $this->renderGlobal();
$result .= $this->renderLang();

return $result . self::HALF_SPACE . '});' . self::NEW_LINE;
return $result . self::HALF_SPACE . '});';
}

protected function renderPlotOptions(): string
Expand Down
11 changes: 5 additions & 6 deletions src/Highcharts/Highchart.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ public function __construct()
}
}

protected function getChartClass(): string
{
return 'Chart';
}

protected function renderChartOptions(string &$chartJS): void
{
parent::renderChartOptions($chartJS);
Expand All @@ -42,12 +47,6 @@ protected function renderChartOptions(string &$chartJS): void
$chartJS .= $this->renderDrilldown();
}

protected function renderChartStart(string &$chartJS, string $engine): void
{
parent::renderChartStart($chartJS, $engine);
$chartJS .= self::NEW_LINE . self::HALF_SPACE . "const {$this->getRenderTo()} = new Highcharts.Chart({" . self::NEW_LINE;
}

private function renderColorAxis(): string
{
return $this->renderCallback($this->colorAxis);
Expand Down
11 changes: 5 additions & 6 deletions src/Highcharts/Highstock.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,15 @@ public function __construct()
$this->initChartOption('rangeSelector');
}

protected function renderChartOptions(string &$chartJS): void
protected function getChartClass(): string
{
parent::renderChartOptions($chartJS);
$chartJS .= $this->renderRangeSelector();
return 'StockChart';
}

protected function renderChartStart(string &$chartJS, string $engine): void
protected function renderChartOptions(string &$chartJS): void
{
parent::renderChartStart($chartJS, $engine);
$chartJS .= self::NEW_LINE . self::HALF_SPACE . "const {$this->getRenderTo()} = new Highcharts.StockChart({" . self::END_LINE;
parent::renderChartOptions($chartJS);
$chartJS .= $this->renderRangeSelector();
}

protected function renderRangeSelector(): string
Expand Down

0 comments on commit 35773c9

Please sign in to comment.