kalitics/amchart-bundle

Create easy am charts (WIP)

Installs: 93

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Forks: 0

Type:symfony-bundle

1.0.1 2021-01-26 12:21 UTC

This package is auto-updated.

Last update: 2025-02-26 20:14:41 UTC


README

symfony-amcharts

AmCharts for symfony Build your chart with twig and php only! You can create reusable code.

How to get started

Installation

  1. Add the following to your composer.json file

        "require": {
            ...
            "kalamurda/amcharts-bundle": "dev-master@dev"
            ...
        }
    
  2. Run php composer.phar update "kalamurda/amcharts-bundle"

  3. Register the bundle in your app/AppKernel.php:

        <?php
        ...
        public function registerBundles()
        {
            $bundles = array(
                ...
                new \IK\AmChartsBundle\IKAmChartsBundle(),
                ...
            );
        ...
    

Usage

  1. 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,
         'style' => $chart->getStyle(),
         'scripts' => $chart->getLibraryScripts()
     ]);
            
    
  2. twig index.html.twig

         ...
         <!-- Styles -->
            
         <style>
             {{ style }}
         </style>
         <!-- 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>
            
         {{ scripts.standart|raw }}
         {{ scripts.theme|raw }}
         <script type="text/javascript">
             {{ amchart(chart) }}
         </script>
    
         <div id="chartdiv"></div>
         ...
    

for more details look examples in root directory. You can override any property.