Source

jqplot / usage.txt

Title: jqPlot Usage

jqPlot is a jquery extension to render completely client-side javascript charts in your web pages. The project home page and downloads can be found at <http://code.google.com/p/jqplot/>.  It is currently under heavy development but fully functional.  To use jqPlot, in your html, include jquery, the jqPlot plugin, and optionally the excanvas script for IE 
support in your web page:

> <script language="javascript" type="text/javascript" src="../jquery-1.3.2.js"></script>
> <script language="javascript" type="text/javascript" src="jquery.jqplot.js"></script>
> <!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
    
Add a container (target) to your web page where you want your plot to show up.
Be sure to give your target a width and a height:

> <div id="chartdiv" style="height:400px;width:300px; "></div> 

Then, create the actual plot by calling the 
$.jqplot plugin with the id of your target and some data:

> $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);

Which will produce a 
chart like:

(see samples/basicline.png)

You can customize the plot by passing options to the 
$.jqplot function:

> $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
> { title:'Exponential Line', 
>   axes:{yaxis:{min:-10, max:240}}, 
>   series:[{color:'#5FAB78'}]
> });

Which will produce 
a plot like:

(see samples/basicoptions.png)

You can use jqPlot plugins (that is, plugins to the jqPlot plugin) by including them in your html 
after you include the jqPlot plugin.  Here is how to include the log axis plugin:

: <script language="javascript" type="text/javascript" src="jqplot.LogAxisRenderer.js"></script>

Here is a the same $.jqplot call 
but with a log y axis:

: $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
: { title:'Exponential Line', 
:   axes:{yaxis:{renderer: $.jqplot.LogAxisRenderer}}, 
:   series:[{color:'#5FAB78'}]
: });

Which produces 
a plot like:

(see samples/basiclogaxis.png)

You can further customize with options specific 
to the log axis plugin:

: $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
: { title:'Exponential Line', 
:   axes:{yaxis:{renderer: $.jqplot.LogAxisRenderer, tickDistribution:'power'}}, 
:   series:[{color:'#5FAB78'}]
: });

Which makes a 
plot like:

(see samples/basiclogoptions.png)

Propeties that can be set through the options object are documented in the rest of this site.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.