PHP code example of mwardi / highcharts-bundle

1. Go to this page and download the library: Download mwardi/highcharts-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mwardi / highcharts-bundle example snippets


    public function registerBundles() {
        $bundles = [
            // ...
            new WBW\Bundle\HighchartsBundle\HighchartsBundle(),
        ];

        // ...

        return $bundles;
    }

    // Prepare the data.
    $data = [["name" => "Female", "y" => 25 ], ["name" => "Male", "y" => 25], ["name" => "Unknown", "y" => 50]];

    // Initialize the series.
    $series = [["colorByPoint" => true, "data" => $data, "name" => "Gender distribution"]];

    // Initialize the chart.
    $chart = new HighchartsChart;
    $chart->newChart()->setType("pie");
    $chart->newPlotOptions()->newPie()
        ->setAllowPointSelect(true)
        ->setCursor("pointer")
        ->setShowInLegend(true)
        ->newDataLabels()->setEnabled(true);
    $chart->setSeries($series);
    $chart->newTitle()->setText("Gender distribution");
    $chart->newTooltip()->setPointFormat("{series.name}: <b>{point.percentage:.1f}%</b>");

    return $this->render('::your_template.html.twig', [
        'chart' => $chart
    ]);