teamupdivision/fusionexport-upd

UPD 的 FusionExport PHP 客户端

1.0.5 2023-07-25 07:59 UTC

This package is auto-updated.

Last update: 2024-09-25 10:36:13 UTC


README

FusionExport 的 PHP SDK。允许使用 FusionExport 从 PHP 导出。

安装

要安装此包,只需使用 composer

composer require fusioncharts/fusionexport

使用

在您的项目中使用 SDK

use FusionExport\ExportManager;
use FusionExport\ExportConfig;

入门指南

从简单的图表导出开始。对于导出单个图表,只需传递与传递给 FusionCharts 构造函数相同的图表配置即可。

<?php

require __DIR__ . '/../vendor/autoload.php';

// Use the FusionExport components
use FusionExport\ExportManager;
use FusionExport\ExportConfig;

// Instantiate ExportManager
$exportManager = new ExportManager();

// Instantiate ExportConfig
$exportConfig = new ExportConfig();

$config = (object)[
    "type" => "column2d",
    "renderAt" => "chart-container",
    "width" => "550",
    "height" => "350",
    "id" => "myChartId",
    "dataFormat" => "json",
    "dataSource" => (object)[
        "chart" => (object)[
            "caption" => "Number of visitors last week",
            "theme" => "ocean",
            "subCaption" => "Bakersfield Central vs Los Angeles Topanga"
        ],
        "data" => [
            (object)[
                "label" => "Mon",
                "value" => "15123"
            ],
            (object)[
                "label" => "Tue",
                "value" => "14233"
            ],
            (object)[
                "label" => "Wed",
                "value" => "25507"
            ]
        ]
    ]
];

$exportConfig->set('chartConfig', $config);

// Export the chart by providing the exportConfig to the exportManager
$files = $exportManager->export($exportConfig, '.', true);

foreach ($files as $file) {
    echo $file . "\n";
}

API 参考

您可以在这里找到完整的参考。