Skip to content

Commit

Permalink
Version 2.20.10.
Browse files Browse the repository at this point in the history
Updated psalm annotation.
Updated change log.
Updated render functions.
  • Loading branch information
laurentmuller committed Mar 21, 2024
1 parent 9254897 commit 970e204
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 102 deletions.
53 changes: 30 additions & 23 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,101 @@
# Change log

### [Unreleased]
## [Unreleased]

### [2.20.9] - 2024-03-20
## [2.20.10] - 2024-03-21

- Updated psalm annotation.
- Updated change log.
- Updated render functions.

## [2.20.9] - 2024-03-20

- Updated CI actions.
- Completed tests.
- Added new tests.
- Updated psalm configuration and annotations.
- Removed `$trim` parameter for `createExpression` function.

### [2.20.8] - 2024-01-09
## [2.20.8] - 2024-01-09

- Set function `createExpression` as static.

### [2.20.7] - 2024-01-08
## [2.20.7] - 2024-01-08

- Symfony 7 support for required development.

### [2.20.6] - 2023-12-20
## [2.20.6] - 2023-12-20

- Symfony 7 support.

### [2.20.5] - 2023-12-09
## [2.20.5] - 2023-12-09

- Update named service.

### [2.20.4] - 2023-12-08
## [2.20.4] - 2023-12-08

- Moved is expression from chart option to abstract chart.

### [2.20.3] - 2023-11-28
## [2.20.3] - 2023-11-28

- Replaced comma by new line when render chart class

### [2.20.2] - 2023-11-28
## [2.20.2] - 2023-11-28

- Simplified encoding options

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

- Added chart class property
- Added lint markdown action

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

- Removed pretty print option

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

- Updated tests
- Reworked script output.

### [2.19.18] - 2023-11-26
## [2.19.18] - 2023-11-26

- Updated documentation
- Added Engine constants
- Removed skipped tests

### [2.0.0] - 2022-03-21
## [2.0.0] - 2022-03-21

- Added PHP version 8.2.
- Update composer.json

### 1.7.0 - 2020-01-12
## 1.7.0 - 2020-01-12

- Add support for Symfony 5
- Add support for Twig 3
- Drop support for PHP < 7.2

### 1.6.0 - 2017-12-27
## 1.6.0 - 2017-12-27

- Add support for Symfony 4

### 1.5.0 - 2016-07-26
## 1.5.0 - 2016-07-26

- 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.4.0 - 2016-01-10
## 1.4.0 - 2016-01-10

- Update version constraint to support Symfony 3

### 1.3.0 - 2015-10-10
## 1.3.0 - 2015-10-10

- Update to PSR-4 auto-loading
- Add support for colorAxis
- Add support for noData

### 1.2.0 - 2014-08-04
## 1.2.0 - 2014-08-04

- Refactor deprecated Twig_Function_Method to Twig_SimpleFunction
- Add support for lang
Expand All @@ -99,7 +105,7 @@
- Drop support for deprecated versions of Symfony
- Add support for scrollbar

### 1.1.0 - 2014-06-26
## 1.1.0 - 2014-06-26

This release fixes a security issue. You are encouraged to update to it as soon
as possible. See [Security Advisory: ZF2014-01](https://framework.zend.com/security/advisory/ZF2014-01)
Expand All @@ -113,7 +119,7 @@ as possible. See [Security Advisory: ZF2014-01](https://framework.zend.com/secur
- Update Zend\Json for a security issue
- Remove bundled assets in favor of Highcharts' CDN ([https://code.highcharts.com](https://code.highcharts.com))

### 1.0.1 - 2013-11-08
## 1.0.1 - 2013-11-08

- Make the JS wrapper optional
- Add support for multiple x-axis
Expand All @@ -122,11 +128,12 @@ as possible. See [Security Advisory: ZF2014-01](https://framework.zend.com/secur
- 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
## 1.0.0 - 2013-08-06

- Initial release

[Unreleased]: https://github.com/laurentmuller/HighchartsBundle/compare/1.7...HEAD
[2.20.10]: https://github.com/laurentmuller/HighchartsBundle/compare/2.20.9...2.20.10
[2.20.9]: https://github.com/laurentmuller/HighchartsBundle/compare/2.20.8...2.20.9
[2.20.8]: https://github.com/laurentmuller/HighchartsBundle/compare/2.20.7...2.20.8
[2.20.7]: https://github.com/laurentmuller/HighchartsBundle/compare/2.20.6...2.20.7
Expand Down
131 changes: 69 additions & 62 deletions src/Highcharts/AbstractChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,46 +155,48 @@ protected function jsonEncode(ChartOption|array $data, string $name = ''): strin
return self::SPACE . $name . ': ' . $encoded . self::END_LINE;
}

protected function renderAccessibility(): string
protected function renderAccessibility(string &$chartJS): void
{
return $this->jsonEncode($this->accessibility);
$chartJS .= $this->jsonEncode($this->accessibility);
}

protected function renderChart(): string
protected function renderChart(string &$chartJS): void
{
return $this->jsonEncode($this->chart);
$chartJS .= $this->jsonEncode($this->chart);
}

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

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

protected function renderChartCommon(string &$chartJS): void
{
$chartJS .= $this->renderChart();
$chartJS .= $this->renderColors();
$chartJS .= $this->renderCredits();
$chartJS .= $this->renderExporting();
$chartJS .= $this->renderLegend();
$chartJS .= $this->renderScrollbar();
$chartJS .= $this->renderSubtitle();
$chartJS .= $this->renderTitle();
$chartJS .= $this->renderXAxis();
$chartJS .= $this->renderYAxis();
$chartJS .= $this->renderPlotOptions();
$chartJS .= $this->renderSeries();
$chartJS .= $this->renderTooltip();
$chartJS .= $this->renderAccessibility();
$this->renderChart($chartJS);
$this->renderColors($chartJS);
$this->renderCredits($chartJS);
$this->renderExporting($chartJS);
$this->renderLegend($chartJS);
$this->renderScrollbar($chartJS);
$this->renderSubtitle($chartJS);
$this->renderTitle($chartJS);
$this->renderXAxis($chartJS);
$this->renderYAxis($chartJS);
$this->renderPlotOptions($chartJS);
$this->renderSeries($chartJS);
$this->renderTooltip($chartJS);
$this->renderAccessibility($chartJS);
}

/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
protected function renderChartEnd(string &$chartJS, string $engine): void
{
$chartJS = \rtrim($chartJS, self::END_LINE) . self::NEW_LINE . self::HALF_SPACE . '});' . self::NEW_LINE;
if ('' !== $engine) {
if (self::ENGINE_NONE !== $engine) {
$chartJS .= '});' . self::NEW_LINE;
}
}
Expand All @@ -203,103 +205,108 @@ protected function renderChartOptions(string &$chartJS): void
{
}

/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
protected function renderChartStart(string &$chartJS, string $engine): void
{
$chartJS .= $this->renderEngine($engine);
$chartJS .= $this->renderOptions();
$chartJS .= $this->renderChartClass();
$this->renderEngine($chartJS, $engine);
$this->renderOptions($chartJS);
$this->renderChartClass($chartJS);
}

protected function renderColors(): string
protected function renderColors(string &$chartJS): void
{
return $this->jsonEncode($this->colors, 'colors');
$chartJS .= $this->jsonEncode($this->colors, 'colors');
}

protected function renderCredits(): string
protected function renderCredits(string &$chartJS): void
{
return $this->jsonEncode($this->credits);
$chartJS .= $this->jsonEncode($this->credits);
}

protected function renderEngine(string $engine): string
/**
* @psalm-param ChartInterface::ENGINE_* $engine
*/
protected function renderEngine(string &$chartJS, string $engine): void
{
return match ($engine) {
$chartJS .= match ($engine) {
self::ENGINE_MOOTOOLS => 'window.addEvent(\'domready\', function () {',
self::ENGINE_JQUERY => '$(function () {',
default => '',
};
}

protected function renderExporting(): string
protected function renderExporting(string &$chartJS): void
{
return $this->jsonEncode($this->exporting);
$chartJS .= $this->jsonEncode($this->exporting);
}

protected function renderGlobal(): string
protected function renderGlobal(string &$chartJS): void
{
return $this->jsonEncode($this->global);
$chartJS .= $this->jsonEncode($this->global);
}

protected function renderLang(): string
protected function renderLang(string &$chartJS): void
{
return $this->jsonEncode($this->lang);
$chartJS .= $this->jsonEncode($this->lang);
}

protected function renderLegend(): string
protected function renderLegend(string &$chartJS): void
{
return $this->jsonEncode($this->legend);
$chartJS .= $this->jsonEncode($this->legend);
}

protected function renderOptions(): string
protected function renderOptions(string &$chartJS): void
{
if (!$this->global->hasData() && !$this->lang->hasData()) {
return '';
return;
}

$result = self::NEW_LINE . self::HALF_SPACE . 'Highcharts.setOptions({' . self::NEW_LINE;
$result .= $this->renderGlobal();
$result .= $this->renderLang();

return $result . self::HALF_SPACE . '});';
$chartJS .= self::NEW_LINE . self::HALF_SPACE . 'Highcharts.setOptions({' . self::NEW_LINE;
$this->renderGlobal($chartJS);
$this->renderLang($chartJS);
$chartJS .= self::HALF_SPACE . '});';
}

protected function renderPlotOptions(): string
protected function renderPlotOptions(string &$chartJS): void
{
return $this->jsonEncode($this->plotOptions);
$chartJS .= $this->jsonEncode($this->plotOptions);
}

protected function renderScrollbar(): string
protected function renderScrollbar(string &$chartJS): void
{
return $this->jsonEncode($this->scrollbar);
$chartJS .= $this->jsonEncode($this->scrollbar);
}

protected function renderSeries(): string
protected function renderSeries(string &$chartJS): void
{
return $this->jsonEncode($this->series);
$chartJS .= $this->jsonEncode($this->series);
}

protected function renderSubtitle(): string
protected function renderSubtitle(string &$chartJS): void
{
return $this->jsonEncode($this->subtitle);
$chartJS .= $this->jsonEncode($this->subtitle);
}

protected function renderTitle(): string
protected function renderTitle(string &$chartJS): void
{
return $this->jsonEncode($this->title);
$chartJS .= $this->jsonEncode($this->title);
}

protected function renderTooltip(): string
protected function renderTooltip(string &$chartJS): void
{
return $this->jsonEncode($this->tooltip);
$chartJS .= $this->jsonEncode($this->tooltip);
}

protected function renderXAxis(): string
protected function renderXAxis(string &$chartJS): void
{
return $this->jsonEncode($this->xAxis);
$chartJS .= $this->jsonEncode($this->xAxis);
}

protected function renderYAxis(): string
protected function renderYAxis(string &$chartJS): void
{
return $this->jsonEncode($this->yAxis);
$chartJS .= $this->jsonEncode($this->yAxis);
}

private function isExpression(array $values): bool
Expand Down

0 comments on commit 970e204

Please sign in to comment.