The methods used:
Add a data to the series with a given name. If the name exists the data will be overwritten. Data can be added via array, sql query or javascript function
Parameters:
Set a various options for a serie.
Parameters:
API Tags:
Return: instance
Access: public
The data is added with addSeries method.
Array Data
1. A list of numerical values. In this case, the numberical values will be interpreted and y values, and x values will be automatically calculated, either starting at 0 and incrementing by 1, or from pointStart and pointInterval given in the plotOptions. If the axis is has categories, these will be used. Example:
... $chart = new jqChart(); $chart->addSeries('Tokyo', array(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6)) ...
2. A list of arrays with two values. In this case, the first value is the x value and the second is the y value. If the first value is a string, it is applied as the name of the point, and the x value is incremented following the above rules. Example:
... $chart = new jqChart(); ->addSeries('data', array( arraY(20, 20), array(80, 80) )); ...
3. A list of object with named values. In this case the objects are point configuration objects as seen under options.point. Example:
... $chart = new jqChart(); ->addSeries('data', array( array( "name" =>'Point 1', "color"=> '#00FF00', "y"=> 0 ), array( "name" =>'Point 2', "color"=> '#FF00FF', "y"=> 5 ) )); ...
Data can be added via Javascript function
Example:
... $randdata = << RNDATA (function() { // generate an array of random data var data = [], time = (new Date()).getTime(), i; for (i = -19; i <= 0; i++) { data.push({ x: time + i * 1000, y: Math.random() }); } return data; })() RNDATA; ... $chart = new jqChart(); $chart->addSeries('Random data', 'js:'.$randdata ); ...
Data can be added direct via SQL query.
Example
... require_once ABSPATH."php/jqUtils.php"; require_once ABSPATH."php/jqGridPdo.php"; require_once ABSPATH."php/jqChart.php"; $conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD); // Tell the db that we use utf-8 jqGridDB::query($conn,"SET NAMES utf8"); $chart = new jqChart($conn); $chart->addSeries("MyOrders","SELECT SUM(ordersum) FROM orders GROUP BY order_date"); ...