jaxon-php/jaxon-flot

Javascript charts for Jaxon with the Flot library

v4.0.0 2022-08-08 08:29 UTC

This package is auto-updated.

Last update: 2024-11-28 18:56:19 UTC


README

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

Installation

Install this package with Composer.

"require": {
    "jaxon-php/jaxon-flot": "~1.0"
}

Usage

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.

Set the graph data using an array of points.

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

Or a javascript expression.

    $graph->series()->expr(0, 14, 0.5, 'Math.sqrt(x * 10)');

Optionally, set the xaxis labels.

    $ticks = [];
    for($i = 0; $i < 10; $i++) $ticks[] = [$i, 'Pt' . $i];
    $plot->xaxis()->points($ticks);

Optionally, set the dimensions of the plot. If the dimensions are not set here, make sure they are in HTML or CSS code. The Flot library requires the container to have width and height set.

    $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.

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.