PHP code example of webeweb / highcharts-bundle

1. Go to this page and download the library: Download webeweb/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/ */

    

webeweb / 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
    ]);