jaxon-php/jaxon-flot

Javascript charts for Jaxon with the Flot library

Maintainers

Package info

github.com/jaxon-php/jaxon-flot

pkg:composer/jaxon-php/jaxon-flot

Statistics

Installs: 224

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v5.2.0 2026-03-19 04:19 UTC

This package is auto-updated.

Last update: 2026-03-19 04:22:30 UTC


README

Javascript charts for Jaxon with the Flot library. https://www.flotcharts.org

See the plugin in action with sample code.

Installation

Install this package with Composer.

"require": {
    "jaxon-php/jaxon-flot": "^5.1"
}

Draw graphs

Create a new plot to be displayed in a div with a given id, eg. "flot-container".

    $plot = $response->flot->plot('flot-container');

Add a graph in the plot, and set its parameters.

    $graph = $plot->graph(['label' => 'Plot example', 'lines' => ['show' => true]]);

The options are defined in the API docs.

Multiple data series can be added to a graph.

Each series can be defined using an array of points.

    $graph->series()->points([[0, 3], [4, 8], [8, 5], [9, 13]]);

Or a javascript loop expression. The loop goes from a start to an end value, with the specified step. The last parameter is a Javascript function defined in the app, which takes a point as parameter and returns the corresponding value.

    $graph->series()->loop(0, 14, 0.5, 'Math.sqrt');

The X axis and Y axis options can also be set. Multiple X axis and Y axis can be added. For each axis, the labels can be optionally set either with an array of points, or with a loop expression.

    $plot->xaxis()->options([
        // First X axis options.
    ])->points($ticks);
    $plot->xaxis()->options([
        // Second X axis options.
    ])->loop(0, 16, 1, 'plot.xaxis.label');

Set the dimensions of the plot.

    $plot->width('600px')->height('300px');

Finally, draw the graph.

    $response->flot->draw($plot);

You can add as many graphs as you need in a single plot, and you can draw many plots in a single page.

Draw a pie

Drawing a pie chart requires the pie plugin for Flot to be loaded. Call this PHP code before loading the page, or add the Flot pie plugin manually.

jaxon()->di()->g(FlotPlugin::class)->usePie(true);

Create a new plot to be displayed in a div with a given id, eg. "flot-container".

    $plot = $response->flot->plot('flot-container');

Set the plot options.

    $plot->options([
        'series' => [
            'pie' => [
                'show' => true,
            ],
        ],
    ]);

Add the pie to the plot

    $plot->pie()->slices([
        [3, 'Pt 1'],
        [8, 'Pt 2'],
        [5, 'Pt 3'],
        [13, 'Pt 4'],
    ]);

Finally, draw the graph.

    $response->flot->draw($plot);

Only one pie can be added to a plot.

Contribute

  • Issue Tracker: github.com/jaxon-php/jaxon-flot/issues
  • Source Code: github.com/jaxon-php/jaxon-flot

License

The project is licensed under the BSD license.