mwardi/highcharts-bundle

将 HighchartsJS 集成到 Symfony 框架

安装: 7

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 1

类型:symfony-bundle

v2.0.1 2021-02-01 11:05 UTC

This package is auto-updated.

Last update: 2024-09-29 05:49:05 UTC


README

Build Status Coverage Status Scrutinizer Code Quality Latest Stable Version Latest Unstable Version License composer.lock

highcharts-bundle 通过提供 Twig 扩展和 PHP 对象来简化 Highcharts 的使用,以便在 Symfony 2 应用程序中显示丰富的图表和图形。该软件包包含出色的 JS 库 Highcharts

通过将所有图表代码都写在 PHP 中来简化你的图表代码!

包含

如果你喜欢这个软件包,请请我喝啤酒(或咖啡) paypal.me

兼容性

PHP Symfony

使用 v2.0 与 Symfony 兼容

安装

打开命令行,进入您的项目目录,并执行以下命令以下载此软件包的最新稳定版本

$ composer require webeweb/highcharts-bundle

此命令要求您全局安装 Composer,如 Composer 文档中的 安装章节 所述。

然后,通过将其添加到项目 app/AppKernel.php 文件中注册的软件包列表中来启用该软件包

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

        // ...

        return $bundles;
    }

一旦添加了软件包,然后执行以下操作

$ php bin/console assets:install

用法

在您的控制器中...

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

在您的模板中...

    <div id="Container"></div>
    {{ highchartsScript('highcharts') }}
    {{ highchartsScript('modules/exporting') }}
    {{ highchartsChart('Container', chart) }}

测试

为了测试这个软件包,最好在您的计算机上克隆这个仓库。打开命令行,并执行以下命令以下载此软件包的最新稳定版本

$ git clone https://github.com/webeweb/highcharts-bundle.git
$ cd highcharts-bundle
$ composer install

一旦安装了所有必要的库,然后执行以下操作

$ vendor/bin/phpunit

许可

highcharts-bundle 在 MIT 许可下发布。有关详细信息,请参阅捆绑的 LICENSE 文件。

请注意,Highcharts JS 库 对商业用途免费,请参阅他们的 FAQ 了解构成非商业项目的内容,或查看他们的 产品页面 了解定价详情。

捐赠

如果您喜欢这项工作,请考虑在 paypal.me 进行捐赠