From 33b7377fca38ea2f8ea46a4e13c87373aa094d69 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 13:04:17 +0200
Subject: [PATCH 01/15] Update composer.json
---
composer.json | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/composer.json b/composer.json
index 19e1b77..58c76f5 100644
--- a/composer.json
+++ b/composer.json
@@ -1,28 +1,28 @@
{
- "name": "ob/highcharts-bundle",
+ "name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
- "homepage": "https://github.com/marcaube/ObHighchartsBundle",
+ "homepage": "https://github.com/mpescador1/ObHighchartsBundle",
"license": "MIT",
"authors": [
{
"name": "Marc Aubé"
- }
+ },{ "name": "Miguel Angel Pescador Santirso"
],
"require": {
- "php": "^7.2",
- "symfony/http-kernel": "^4.4 || ^5.0",
- "symfony/dependency-injection": "^4.4 || ^5.0",
- "symfony/config": "^4.4 || ^5.0",
- "symfony/yaml": "^4.4 || ^5.0",
+ "php": "^7.2||^8.0",
+ "symfony/http-kernel": "^4.4 || ^5.0|| ^5.3",
+ "symfony/dependency-injection": "^4.4 || ^5.0 || ^5.3",
+ "symfony/config": "^4.4 || ^5.0 || ^5.3",
+ "symfony/yaml": "^4.4 || ^5.0 || ^5.3",
"twig/twig": "^2.10 || ^3.0",
"laminas/laminas-json": "^3.1"
},
"require-dev": {
- "symfony/phpunit-bridge": "^4.4 || ^5.0",
- "symfony/framework-bundle": "^4.4 || ^5.0",
+ "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^5.3",
+ "symfony/framework-bundle": "^4.4 || ^5.0 || ^5.3",
"nyholm/symfony-bundle-test": "^1.6.1"
},
"autoload": {
From 03ba541f4656a089edbb6de656a77d54c953949a Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 13:05:10 +0200
Subject: [PATCH 02/15] Update composer.json
---
composer.json | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 58c76f5..6a789ce 100644
--- a/composer.json
+++ b/composer.json
@@ -8,7 +8,9 @@
"authors": [
{
"name": "Marc Aubé"
- },{ "name": "Miguel Angel Pescador Santirso"
+ },{
+ "name": "Miguel Angel Pescador Santirso"
+ }
],
"require": {
From a5972d81b1fb0eddcaa67a5faa904d10c201f022 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 13:08:52 +0200
Subject: [PATCH 03/15] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index 00a5972..011c26b 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,7 @@
# ObHighchartsBundle
+*Updated to work with Symfony 5.3
+
`ObHighchartsBundle` 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](http://www.highcharts.com).
From 16d931742d5f59ad84ef04b3eccdebe506643858 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:38:56 +0200
Subject: [PATCH 04/15] Update README.md
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 011c26b..695758f 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# ObHighchartsBundle
-*Updated to work with Symfony 5.3
+* Updated to work with Symfony 5.3
`ObHighchartsBundle` 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
@@ -21,7 +21,7 @@ DRY out your chart code by writing it all in PHP!
* [Usage](Resources/doc/usage.md)
* [Cookbook](Resources/doc/cookbook.md)
* [Highcharts API](http://api.highcharts.com/highcharts)
-
+* [SonataAdmin integration](Resources/doc/sonataadmin.md)
## Contributing
From f398312094111873f94f53678bec5a84435e265e Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:47:50 +0200
Subject: [PATCH 05/15] Create sonataadmin.md
---
Resources/doc/sonataadmin.md | 172 +++++++++++++++++++++++++++++++++++
1 file changed, 172 insertions(+)
create mode 100644 Resources/doc/sonataadmin.md
diff --git a/Resources/doc/sonataadmin.md b/Resources/doc/sonataadmin.md
new file mode 100644
index 0000000..e01ec34
--- /dev/null
+++ b/Resources/doc/sonataadmin.md
@@ -0,0 +1,172 @@
+# Sonata Admin Integration
+
+Requirements
+- SonataAdminBundle (4.x)
+- ObHighChartsBundle (https://github.com/mpescador1/ObHighchartsBundle)
+
+templates/Form/chart_block_single.html.twig
+´´´twig
+{% extends sonata_block.templates.block_base %}
+{% block block %}
+
+
+
+
+{% endblock %}
+´´´
+config/packages/sonata_admin.yaml
+´´´yaml
+sonata_admin:
+ dashboard:
+ ....
+ blocks:
+ ....
+ - { type: admin.block.service.registrations_chart, position: left }
+sonata_block:
+ blocks:
+ admin.block.service.registrations_chart: #This is the chart block - RegistrationsChartBlockService (below)
+ contexts: [ admin ]
+´´´
+
+src/Block/Service/RegistrationsChartService.php
+´´´php
+pool = $pool;
+ $this->chartBuilder = $chartBuilder;
+ }
+ /**
+ * {@inheritdoc}
+ */
+ public function execute(BlockContextInterface $blockContext, ?Response $response = null): Response
+ {
+
+ $end = new \DateTime();
+ $start = new \DateTime('7 days ago');
+
+ $chart = $this->chartBuilder->getRegistrationsChart($start, $end);
+
+ return $this->renderPrivateResponse($blockContext->getTemplate(), array(
+ 'chart' => $chart,
+ 'block' => $blockContext->getBlock(),
+ 'settings' => $blockContext->getSettings(),
+ ), $response);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getName()
+ {
+ return 'Users Chart';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function configureSettings(OptionsResolver $resolver): void
+ {
+ $resolver->setDefaults(array(
+ 'title' => 'Users',
+ 'summaries' => false,
+ 'template' => 'Form/chart_block_single.html.twig',
+ ));
+ }
+}
+´´´
+
+src/Service/ChartService.php
+´´´php
+em = $em;
+ }
+
+ public function getRegistrationsChart(\DateTime $start,\DateTime $end){
+ $ob = new Highchart();
+ $ob->chart->renderTo('piechart');
+ $ob->title->text('Browser market shares at a specific website in 2010');
+ $ob->plotOptions->pie(array(
+ 'allowPointSelect' => true,
+ 'cursor' => 'pointer',
+ 'dataLabels' => array('enabled' => false),
+ 'showInLegend' => true
+ ));
+ $data = array(
+ array('Firefox', 45.0),
+ array('IE', 26.8),
+ array('Chrome', 12.8),
+ array('Safari', 8.5),
+ array('Opera', 6.2),
+ array('Others', 0.7),
+ );
+ $ob->series(array(array('type' => 'pie','name' => 'Browser share', 'data' => $data)));
+ return $ob;
+ }
+}
+´´´
+
+config/services.yaml
+´´´yaml
+services:
+ ....
+ admin.block.service.chart:
+ class: App\Service\ChartService
+ arguments: ['@doctrine.orm.entity_manager']
+ public: true
+ admin.block.service.registrations_chart:
+ class: App\Block\Service\RegistrationsChartService
+ arguments:
+ - "@twig"
+ - "@sonata.admin.pool"
+ - "@admin.block.service.chart"
+ tags:
+ - { name: sonata.block }
+ public: true
+ ....
+´´´
From 5a0f51a42ef40a08938559f227a24a8a2df2a4f7 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:48:57 +0200
Subject: [PATCH 06/15] Update sonataadmin.md
---
Resources/doc/sonataadmin.md | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/Resources/doc/sonataadmin.md b/Resources/doc/sonataadmin.md
index e01ec34..1df372f 100644
--- a/Resources/doc/sonataadmin.md
+++ b/Resources/doc/sonataadmin.md
@@ -5,7 +5,7 @@ Requirements
- ObHighChartsBundle (https://github.com/mpescador1/ObHighchartsBundle)
templates/Form/chart_block_single.html.twig
-´´´twig
+```twig
{% extends sonata_block.templates.block_base %}
{% block block %}
@@ -20,9 +20,9 @@ templates/Form/chart_block_single.html.twig
{% endblock %}
-´´´
+```
config/packages/sonata_admin.yaml
-´´´yaml
+```yaml
sonata_admin:
dashboard:
....
@@ -33,10 +33,10 @@ sonata_block:
blocks:
admin.block.service.registrations_chart: #This is the chart block - RegistrationsChartBlockService (below)
contexts: [ admin ]
-´´´
+```
src/Block/Service/RegistrationsChartService.php
-´´´php
+```php
Date: Fri, 27 Aug 2021 14:50:50 +0200
Subject: [PATCH 07/15] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 695758f..e139def 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ DRY out your chart code by writing it all in PHP!
[](https://packagist.org/packages/ob/highcharts-bundle)
[](https://scrutinizer-ci.com/g/marcaube/ObHighchartsBundle/)
[](https://scrutinizer-ci.com/g/marcaube/ObHighchartsBundle/)
-[](https://insight.sensiolabs.com/projects/4cf81d53-f79c-478e-a172-ac2f60b55f02)
+
## Documentation
From 2ea6c4a00dfcb7c42c1b4e5a4bbd05fdcd2741a5 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 14:53:37 +0200
Subject: [PATCH 08/15] Update installation.md
---
Resources/doc/installation.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Resources/doc/installation.md b/Resources/doc/installation.md
index 8cf3e0c..24cf13c 100644
--- a/Resources/doc/installation.md
+++ b/Resources/doc/installation.md
@@ -1,6 +1,6 @@
# Installation
-1. Run `composer require ob/highcharts-bundle`
+1. Run `composer require mpescador1/highcharts-bundle`
2. Register the bundle in your `app/AppKernel.php`:
From 458f1d4b3d29cedcc795d766233433d798fe2ef5 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Fri, 27 Aug 2021 15:02:17 +0200
Subject: [PATCH 09/15] Update sonataadmin.md
---
Resources/doc/sonataadmin.md | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/Resources/doc/sonataadmin.md b/Resources/doc/sonataadmin.md
index 1df372f..4de27dc 100644
--- a/Resources/doc/sonataadmin.md
+++ b/Resources/doc/sonataadmin.md
@@ -4,6 +4,10 @@ Requirements
- SonataAdminBundle (4.x)
- ObHighChartsBundle (https://github.com/mpescador1/ObHighchartsBundle)
+## Render Template
+
+The template uses in this example reder a block of sonata Admin with the defined chart.
+
templates/Form/chart_block_single.html.twig
```twig
{% extends sonata_block.templates.block_base %}
@@ -21,6 +25,12 @@ templates/Form/chart_block_single.html.twig
{% endblock %}
```
+
+## Sonata Admin Yaml Config
+
+We add the block in sonata_admin.blocks and register de block in sonata_blocks.blocks.
+The registered services are below in the services.yaml file.
+
config/packages/sonata_admin.yaml
```yaml
sonata_admin:
@@ -34,6 +44,11 @@ sonata_block:
admin.block.service.registrations_chart: #This is the chart block - RegistrationsChartBlockService (below)
contexts: [ admin ]
```
+## Block definition
+
+We define the block service to show in the dashboard. We can add any injected class to build the block.
+
+In this case we inject de ChartService (below) to get the Hightchart object.
src/Block/Service/RegistrationsChartService.php
```php
@@ -53,7 +68,7 @@ use Twig\Environment;
class RegistrationsChartService extends AbstractBlockService
{
-//Services are injected in the abstract class
+ //Services are injected in the abstract class
//Register class as a service in the container e.g. admin.block.service.registrations_chart
//$chartbuilder is a service that has our default chart configuration, which in turn uses the ObHighCharts bundle to render the charts.
/**
@@ -108,6 +123,12 @@ class RegistrationsChartService extends AbstractBlockService
}
}
```
+## Service definition
+
+This file do the magic, call the HightChart class to build our chart.
+I inject the entity manager because, in many cases, the chart will be populated with database data.
+
+In this example was not use at all.
src/Service/ChartService.php
```php
@@ -150,6 +171,9 @@ class ChartService
}
}
```
+## Services configuration
+
+We need configure the services injecting the diferent services as shown below.
config/services.yaml
```yaml
From bfd8dfd026490159c5b17477f8f4291f85986c99 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Tue, 28 May 2024 20:10:12 +0200
Subject: [PATCH 10/15] Update composer.json
---
composer.json | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/composer.json b/composer.json
index 6a789ce..9b0a0c6 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,7 @@
{
"name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
+ "version": "1.0.1
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
"homepage": "https://github.com/mpescador1/ObHighchartsBundle",
@@ -14,11 +15,11 @@
],
"require": {
- "php": "^7.2||^8.0",
- "symfony/http-kernel": "^4.4 || ^5.0|| ^5.3",
- "symfony/dependency-injection": "^4.4 || ^5.0 || ^5.3",
- "symfony/config": "^4.4 || ^5.0 || ^5.3",
- "symfony/yaml": "^4.4 || ^5.0 || ^5.3",
+ "php": "^8.3",
+ "symfony/http-kernel": "^6.4",
+ "symfony/dependency-injection": "^6.4",
+ "symfony/config": "^6.4",
+ "symfony/yaml": "^6.4",
"twig/twig": "^2.10 || ^3.0",
"laminas/laminas-json": "^3.1"
},
From b3783752ed29d43576174e2a9d2b2fad9469cdb2 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Tue, 28 May 2024 20:10:21 +0200
Subject: [PATCH 11/15] Update composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 9b0a0c6..0b4bd93 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
- "version": "1.0.1
+ "version": "1.0.1"
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
"homepage": "https://github.com/mpescador1/ObHighchartsBundle",
From 6693159d3fa245e8c19982ca3ef52f5f9acfa565 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Tue, 28 May 2024 20:11:43 +0200
Subject: [PATCH 12/15] Update composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 0b4bd93..ec776c9 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
- "version": "1.0.1"
+ "version": "1.0.1",
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
"homepage": "https://github.com/mpescador1/ObHighchartsBundle",
From 997a56c4c582190ce05a83484ccff52fd49a5536 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Sat, 22 Nov 2025 13:29:11 +0100
Subject: [PATCH 13/15] Update composer.json
---
composer.json | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/composer.json b/composer.json
index ec776c9..8c9bf43 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
- "version": "1.0.1",
+ "version": "1.0.2",
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
"homepage": "https://github.com/mpescador1/ObHighchartsBundle",
@@ -16,16 +16,16 @@
"require": {
"php": "^8.3",
- "symfony/http-kernel": "^6.4",
- "symfony/dependency-injection": "^6.4",
- "symfony/config": "^6.4",
- "symfony/yaml": "^6.4",
+ "symfony/http-kernel": "^6.4|^7",
+ "symfony/dependency-injection": "^6.4|^7",
+ "symfony/config": "^6.4|^7",
+ "symfony/yaml": "^6.4|^7",
"twig/twig": "^2.10 || ^3.0",
"laminas/laminas-json": "^3.1"
},
"require-dev": {
- "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^5.3",
- "symfony/framework-bundle": "^4.4 || ^5.0 || ^5.3",
+ "symfony/phpunit-bridge": "^4.4 || ^5.0 || ^6 || ^7",
+ "symfony/framework-bundle": "^4.4 || ^5.0 || ^6 ||^7",
"nyholm/symfony-bundle-test": "^1.6.1"
},
"autoload": {
From 34d77099cecad48194d4ba404cd2beb2ff67aff0 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Sat, 22 Nov 2025 13:34:17 +0100
Subject: [PATCH 14/15] Update composer.json
---
composer.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/composer.json b/composer.json
index 8c9bf43..fc6b13a 100644
--- a/composer.json
+++ b/composer.json
@@ -1,7 +1,7 @@
{
"name": "mpescador1/highcharts-bundle",
"type": "symfony-bundle",
- "version": "1.0.2",
+ "version": "1.8",
"description": "Symfony Bundle that ease the use of highcharts to display rich graph and charts in your app",
"keywords": ["symfony", "charting", "charts", "highcharts", "chart", "graph", "graphs", "ob", "marcaube"],
"homepage": "https://github.com/mpescador1/ObHighchartsBundle",
From a1ecfbbe7b1ecf1a8df8b7a7ab9081c9f437b941 Mon Sep 17 00:00:00 2001
From: mpescador1 <56395851+mpescador1@users.noreply.github.com>
Date: Sat, 22 Nov 2025 13:34:31 +0100
Subject: [PATCH 15/15] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e139def..c64afd4 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# ObHighchartsBundle
-* Updated to work with Symfony 5.3
+* Updated to work with Symfony 7
`ObHighchartsBundle` 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