kalamurda / amcharts-bundle
Symfony-bundle for building amcharts with php code
Installs: 2 977
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.0.8|>=8.1
- symfony/framework-bundle: ^3.4 || ^4.2 || ^5.4 || ^6.2
- twig/twig: ^3.0
README
symfony-amcharts
Already implemented charts:
3d funnel chart
funnel chart
combined bullet column line chart
AmCharts for symfony Build your chart with twig and php only! You can create reusable code.
How to get started
Installation
-
Add the following to your
composer.json
file"require": { ... "kalamurda/amcharts-bundle": "dev-master@dev" ... }
-
Run
php composer.phar update "kalamurda/amcharts-bundle"
-
Register the bundle in your
app/AppKernel.php
:<?php ... public function registerBundles() { $bundles = array( ... new \IK\AmChartsBundle\IKAmChartsBundle(), ... ); ...
Usage
-
phpController
$preperadArr = [ [ 'column1' => 5, 'column2' => 9, 'date' => '2017-06-01' ],[ 'column1' => 5, 'column2' => 9, 'date' => '2017-06-02' ],[ 'column1' => 5, 'column2' => 9, 'date' => '2017-06-03' ], ...... ]; $dataProvider = new DataProvider($preperadArr); $chart = new CombinedBulletColumnLineChart(); $chart->setTheme('dark'); $chart->setDataProvider($dataProvider); return $this->render('default/index.html.twig', [ 'chart' => $chart ]);
-
twig index.html.twig
... <!-- Load jQuery from Google's CDN if needed --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> {{ chart.libraryScripts.standart|raw }} <style>{{ chart.style }}</style> {{ chart.libraryScripts.theme|raw }} <script>{{ amchart(chart) }}</script> <div id="{{ chart.selector }}"></div> ...
for more details look examples in root directory. You can override any property.