https://github.com/jaxon-php/jaxon-flot
Javascript charts for Jaxon with Flot
https://github.com/jaxon-php/jaxon-flot
Last synced: about 2 months ago
JSON representation
Javascript charts for Jaxon with Flot
- Host: GitHub
- URL: https://github.com/jaxon-php/jaxon-flot
- Owner: jaxon-php
- License: bsd-2-clause
- Created: 2016-06-04T21:49:41.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2024-09-28T18:41:42.000Z (9 months ago)
- Last Synced: 2024-10-04T12:05:53.153Z (9 months ago)
- Language: PHP
- Homepage: https://www.jaxon-php.org
- Size: 43 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Javascript charts for Jaxon with Flot
=====================================Javascript charts for Jaxon with the Flot library.
http://www.flotcharts.orgInstallation
------------Install this package with Composer.
```json
"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".
```php
$plot = $response->flot->plot('#flot-container');
```Add a graph in the plot, and set its parameters.
```php
$graph = $plot->graph(['label' => 'Plot example', 'lines' => ['show' => true]]);
```
The options are defined in [the API docs](https://github.com/flot/flot/blob/master/API.md#plot-options).Set the graph data using an array of points.
```php
$graph->series()->points([[0, 3], [4, 8], [8, 5], [9, 13]]);
```Or a javascript expression.
```php
$graph->series()->expr(0, 14, 0.5, 'Math.sqrt(x * 10)');
```Optionally, set the xaxis labels.
```php
$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.```php
$plot->width('600px')->height('300px');
```Finally, draw the graph.
```php
$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-flotLicense
-------The project is licensed under the BSD license.