[ Index ]

PHP Cross Reference of vtigercrm-6.1.0

title

Body

[close]

/libraries/jquery/jqplot/ -> usage.txt (source)

   1  Title: jqPlot Usage
   2  
   3  Usage Documentation:
   4  
   5  Introduction:
   6  
   7  jqPlot is a jQuery plugin to generate pure client-side javascript charts in your web pages. 
   8  
   9  The jqPlot home page is at <http://www.jqplot.com/>.  
  10  
  11  The project page and downloads are at <http://www.bitbucket.org/cleonello/jqplot/>.
  12  
  13  Below are a few examples to demonstrate jqPlot usage.  These plots are shown as static images.  
  14  Many more examples of dynamically rendered plots can be seen on the test and examples pages here: <../../tests/>.
  15  
  16  Include the Files:
  17  
  18  jqPlot requires jQuery (1.4+ required for certain features). jQuery is included in the distribution.  
  19  To use jqPlot include jquery, the jqPlot jQuery plugin, jqPlot css file and optionally the excanvas 
  20  script for IE support in your web page.  Note, excanvas is required only for IE versions below 9.  IE 9 includes
  21  native support for the canvas element and does not require excanvas:
  22  
  23  > <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
  24  > <script language="javascript" type="text/javascript" src="jquery.min.js"></script>
  25  > <script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
  26  > <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
  27  
  28  Add a plot container:
  29  
  30  Add a container (target) to your web page where you want your plot to show up.
  31  Be sure to give your target a width and a height:
  32  
  33  > <div id="chartdiv" style="height:400px;width:300px; "></div> 
  34  
  35  Create a plot:
  36  
  37  Then, create the actual plot by calling the 
  38  $.jqplot plugin with the id of your target and some data:
  39  
  40  > $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);
  41  
  42  Which will produce a 
  43  chart like:
  44  
  45  (see images/basicline.png)
  46  
  47  Plot Options:
  48  
  49  You can customize the plot by passing options to the $.jqplot function.  Options are described in 
  50  <jqPlot Options> in the jqPlotOptions.txt file.  An example of options usage:
  51  
  52  > $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
  53  > { title:'Exponential Line', 
  54  >   axes:{yaxis:{min:-10, max:240}}, 
  55  >   series:[{color:'#5FAB78'}]
  56  > });
  57  
  58  Which will produce 
  59  a plot like:
  60  
  61  (see images/basicoptions.png)
  62  
  63  Using Plugins:
  64  
  65  You can use jqPlot plugins (that is, plugins to the jqPlot plugin) by including them in your html 
  66  after you include the jqPlot plugin.  Here is how to include the log axis plugin:
  67  
  68  > <link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
  69  > <!--[if IE]><script language="javascript" type="text/javascript" src="excanvas.js"></script><![endif]-->
  70  > <script language="javascript" type="text/javascript" src="jquery.min.js"></script>
  71  > <script language="javascript" type="text/javascript" src="jquery.jqplot.min.js"></script>
  72  > <script language="javascript" type="text/javascript" src="jqplot.logAxisRenderer.js"></script>
  73  
  74  Important note:  For jqplot builds r529 and above (0.9.7r529 and higher), you must explicitly 
  75  enable plugins via either the { show: true } plugin option to the plot or by using 
  76  the $.jqplot.config.enablePlugins = true; config options set on the page before plot creation.
  77  Only plugins that can be immediately active upon loading are affected.  This includes 
  78  non-renderer plugins like cursor, dragable, highlighter, and trendline.
  79  
  80  Here is a the same $.jqplot call 
  81  but with a log y axis:
  82  
  83  > $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
  84  > { title:'Exponential Line', 
  85  >   axes:{yaxis:{renderer: $.jqplot.LogAxisRenderer}}, 
  86  >   series:[{color:'#5FAB78'}]
  87  > });
  88  
  89  Which produces 
  90  a plot like:
  91  
  92  (see images/basiclogaxis.png)
  93  
  94  You can further customize with options specific 
  95  to the log axis plugin:
  96  
  97  > $.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]], 
  98  > { title:'Exponential Line', 
  99  >   axes:{yaxis:{renderer: $.jqplot.LogAxisRenderer, tickDistribution:'power'}}, 
 100  >   series:[{color:'#5FAB78'}]
 101  > });
 102  
 103  Which makes a 
 104  plot like:
 105  
 106  (see images/basiclogoptions.png)
 107  
 108  For a full list of options, see <jqPlot Options> in the jqPlotOptions.txt file.
 109  
 110  You can add as many plugins as you wish.  Order is generally not important.  
 111  Some plugins, like the highlighter plugin which highlights data points near the 
 112  mouse,  don't need any extra options or setup to function.  Highlighter does have 
 113  additional options which the user can set.
 114  
 115  Other plugins, the barRenderer for example, provide functionality the must be specified 
 116  in the chart options object.  To render a series as a bar graph with the bar renderer, 
 117  you would first include the plugin after jqPlot:
 118  
 119  > <script language="javascript" type="text/javascript" src="plugins/jqplot.barRenderer.min.js"></script>
 120  
 121  Then you would create 
 122  a chart like:
 123  
 124  > $.jqplot('chartdiv',  [[34.53, 56.32, 25.1, 18.6]], {series:[{renderer:$.jqplot.BarRenderer}]});
 125  
 126  Here the default LineRenderer is replaced by a BarRenderer to generate a bar graph for the first (an only) series.


Generated: Fri Nov 28 20:08:37 2014 Cross-referenced by PHPXref 0.7.1