deoliveiralucas/fusion-charts-api

This package is abandoned and no longer maintained. No replacement package was suggested.

This package can generate graphical charts using the FusionCharts API

3.0 2016-07-14 17:34 UTC

This package is auto-updated.

Last update: 2022-02-01 12:59:53 UTC


README

http://www.fusioncharts.com/

PHPClasses

Description

This package can provide the data to generate graphical charts using the FusionCharts Library.

It provides a base class that can generate JSON for rendering several types of charts supported by the FusionCharts taking XML code that defines the parameters of the charts.

The package comes also with specialized classes that can generate the necessary XML code with the parameters for several types of charts.

Currently it comes with classes for rendering charts of types column, line, plot, pie and pareto.

The chart classes provide a fluent interface to define any of the supported parameters like the chart data values, chart size, colors, labels, fonts, and other chart specific parameters.

Requirement

  • PHP 5.3 >

  • Download the FusionCharts Javascript library in the oficial website

  • Import these two files to your HTML page: fusioncharts.charts.js and fusioncharts.js

Install

composer require deoliveiralucas/fusion-charts-api

Example

  • Columns
use FusionCharts\Chart\ColumnLine;
use FusionCharts\Tag\Categories;
use FusionCharts\Tag\Category;
use FusionCharts\Tag\DataSet as Columns;
use FusionCharts\Tag\Set as Column;

// Data from db
$months = array('Jan', 'Feb', 'Mar', 'Apr');
$values = array(100, 200, 150, 210);

$chart = new ColumnLine('chart-container');

$categories = new Categories();
foreach ($months as $month) {
    $category = new Category($month);
    $categories->addCategory($category);
}

$columns = new Columns();
foreach ($values as $value) {
    $column = new Column($value);
    $columns->addSet($column);
}

$chart
    ->setName('Chart Columns Example')
    ->setWidth(800)
    ->setHeight(400)
    ->setLabelRotate(true)
    ->setXdescription('x values')
    ->setYdescription('y values')
    ->setAttribute('showyaxisvalues', '0')
    ->addCategories($categories)
    ->addColumns($columns);

// render chart in the index.php

Contributing

License

  • GNU General Public License Versions. Please see License File for more information.