egroupware/phpgwapi/js/jquery/jqplot/docs/files/usage-txt.html

58 lines
16 KiB
HTML
Raw Normal View History

2011-08-10 01:10:50 +02:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><title>jqPlot Usage</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>
<!-- Generated by Natural Docs, version 1.4 -->
<!-- http://www.naturaldocs.org -->
<!-- saved from url=(0026)http://www.naturaldocs.org -->
<div id=Content><div class="CSection"><div class=CTopic id=MainTopic><div class="CTitle logo"><div class="nav"><a class="nav" href="../../index.php"><span>&gt;</span>Home</a><a class="nav" href="../../tests/"><span>&gt;</span>Examples</a><a class="nav" href="../../docs/"><span>&gt;</span>Docs</a><a class="nav" href="http://bitbucket.org/cleonello/jqplot/downloads/"><span>&gt;</span>Download</a><a class="nav" href="../../info.php"><span>&gt;</span>Info</a><a class="nav" href="../../donate.php"><span>&gt;</span>Donate</a></div><a name="jqPlot_Usage"></a>jqPlot Usage</div><div class=CBody><h4 class=CHeading>Usage Documentation</h4><h4 class=CHeading>Introduction</h4><p>jqPlot is a jQuery plugin to generate pure client-side javascript charts in your web pages.</p><p>The jqPlot home page is at <a href="http://www.jqplot.com/" class=LURL target=_top>http://www.jqplot.com/</a>.</p><p>The project page and downloads are at <a href="http://www.bitbucket.org/cleonello/jqplot/" class=LURL target=_top>http://www.bitbucket.org/cleonello/jqplot/</a>.</p><p>Below are a few examples to demonstrate jqPlot usage.&nbsp; These plots are shown as static images.&nbsp; Many more examples of dynamically rendered plots can be seen on the test and examples pages here: <a href="../../tests/" class=LURL target=_top>../../tests/</a>.</p><h4 class=CHeading>Include the Files</h4><p>jqPlot requires jQuery (1.4+ required for certain features). jQuery is included in the distribution.&nbsp; To use jqPlot include jquery, the jqPlot jQuery plugin, jqPlot css file and optionally the excanvas script for IE support in your web page.&nbsp; Note, excanvas is required only for IE versions below 9.&nbsp; IE 9 includes native support for the canvas element and does not require excanvas:</p><blockquote><pre>&lt;!--[if lt IE 9]&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;excanvas.js&quot;&gt;&lt;/script&gt;&lt;![endif]--&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;jquery.min.js&quot;&gt;&lt;/script&gt;
2011-08-10 01:10:50 +02:00
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;jquery.jqplot.min.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;jquery.jqplot.css&quot; /&gt;</pre></blockquote><h4 class=CHeading>Add a plot container</h4><p>Add a container (target) to your web page where you want your plot to show up.&nbsp; Be sure to give your target a width and a height:</p><blockquote><pre>&lt;div id=&quot;chartdiv&quot; style=&quot;height:400px;width:300px; &quot;&gt;&lt;/div&gt;</pre></blockquote><h4 class=CHeading>Create a plot</h4><p>Then, create the actual plot by calling the $.jqplot plugin with the id of your target and some data:</p><blockquote><pre>$.jqplot('chartdiv', [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);</pre></blockquote><p>Which will produce a chart like:</p><img src="images/basicline.png" width="416" height="317"><h4 class=CHeading>Plot Options</h4><p>You can customize the plot by passing options to the $.jqplot function.&nbsp; Options are described in <a href="jqPlotOptions-txt.html#jqPlot_Options" class=LSection id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">jqPlot Options</a> in the jqPlotOptions.txt file.&nbsp; An example of options usage:</p><blockquote><pre>$.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'}]
});</pre></blockquote><p>Which will produce a plot like:</p><img src="images/basicoptions.png" width="417" height="315"><h4 class=CHeading>Using Plugins</h4><p>You can use jqPlot plugins (that is, plugins to the jqPlot plugin) by including them in your html after you include the jqPlot plugin.&nbsp; Here is how to include the log axis plugin:</p><blockquote><pre>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;jquery.jqplot.css&quot; /&gt;
&lt;!--[if IE]&gt;&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;excanvas.js&quot;&gt;&lt;/script&gt;&lt;![endif]--&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;jquery.min.js&quot;&gt;&lt;/script&gt;
2011-08-10 01:10:50 +02:00
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;jquery.jqplot.min.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;jqplot.logAxisRenderer.js&quot;&gt;&lt;/script&gt;</pre></blockquote><p>Important note: For jqplot builds r529 and above (0.9.7r529 and higher), you must explicitly enable plugins via either the { show: true } plugin option to the plot or by using the $.jqplot.config.enablePlugins = true; config options set on the page before plot creation.&nbsp; Only plugins that can be immediately active upon loading are affected.&nbsp; This includes non-renderer plugins like cursor, dragable, highlighter, and trendline.</p><p>Here is a the same $.jqplot call but with a log y axis:</p><blockquote><pre>$.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'}]
});</pre></blockquote><p>Which produces a plot like:</p><img src="images/basiclogaxis.png" width="416" height="312"><p>You can further customize with options specific to the log axis plugin:</p><blockquote><pre>$.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'}]
});</pre></blockquote><p>Which makes a plot like:</p><img src="images/basiclogoptions.png" width="416" height="310"><p>For a full list of options, see <a href="jqPlotOptions-txt.html#jqPlot_Options" class=LSection id=link2 onMouseOver="ShowTip(event, 'tt1', 'link2')" onMouseOut="HideTip('tt1')">jqPlot Options</a> in the jqPlotOptions.txt file.</p><p>You can add as many plugins as you wish.&nbsp; Order is generally not important.&nbsp; Some plugins, like the highlighter plugin which highlights data points near the mouse, don&rsquo;t need any extra options or setup to function.&nbsp; Highlighter does have additional options which the user can set.</p><p>Other plugins, the barRenderer for example, provide functionality the must be specified in the chart options object.&nbsp; To render a series as a bar graph with the bar renderer, you would first include the plugin after jqPlot:</p><blockquote><pre>&lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot; src=&quot;plugins/jqplot.barRenderer.min.js&quot;&gt;&lt;/script&gt;</pre></blockquote><p>Then you would create a chart like:</p><blockquote><pre>$.jqplot('chartdiv', [[34.53, 56.32, 25.1, 18.6]], {series:[{renderer:$.jqplot.BarRenderer}]});</pre></blockquote><p>Here the default LineRenderer is replaced by a BarRenderer to generate a bar graph for the first (an only) series.</p></div></div></div>
</div><!--Content-->
<div id=Footer>Copyright &copy; 2009 - 2010 Chris Leonello&nbsp; &middot;&nbsp; Updated October 13th, 2011&nbsp; &middot;&nbsp; <a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->
2011-08-10 01:10:50 +02:00
<div id=Menu><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Usage and Options</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MFile id=MSelected>Usage</div></div><div class=MEntry><div class=MFile><a href="jqPlotOptions-txt.html">jqPlot Options</a></div></div><div class=MEntry><div class=MFile><a href="optionsTutorial-txt.html">Options Tutorial</a></div></div><div class=MEntry><div class=MFile><a href="jqPlotCssStyling-txt.html">jqPlot CSS Customization</a></div></div><div class=MEntry><div class=MFile><a href="changes-txt.html">Change Log</a></div></div><div class=MEntry><div class=MLink><a href="../../tests/">Examples</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent4')">API Documentation</a><div class=MGroupContent id=MGroupContent4><div class=MEntry><div class=MFile><a href="jqplot-core-js.html">jqPlot Charts</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent2')">Core Renderers</a><div class=MGroupContent id=MGroupContent2><div class=MEntry><div class=MFile><a href="jqplot-axisTickRenderer-js.html">Axis Tick Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-canvasGridRenderer-js.html">Canvas Grid Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-divTitleRenderer-js.html">Div Title Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-linearAxisRenderer-js.html">Linear Axis Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-markerRenderer-js.html">Marker Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-shapeRenderer-js.html">Shape Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-shadowRenderer-js.html">Shadow Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-lineRenderer-js.html">Line Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-axisLabelRenderer-js.html">Axis Label Renderer</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-themeEngine-js.html">Theme Engine</a></div></div><div class=MEntry><div class=MFile><a href="jqplot-toImage-js.html">fn</a></div></div></div></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent3')">Plugins</a><div class=MGroupContent id=MGroupContent3><div class=MEntry><div class=MFile><a href="plugins/jqplot-barRenderer-js.html">jqplot.<wbr>BarRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-BezierCurveRenderer-js.html">jqplot.<wbr>BezierCurveRenderer.js</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-blockRenderer-js.html">jqplot.<wbr>BlockRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-bubbleRenderer-js.html">jqplot.<wbr>BubbleRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-canvasAxisLabelRenderer-js.html">jqplot.<wbr>CanvasAxisLabelRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-canvasAxisTickRenderer-js.html">jqplot.<wbr>CanvasAxisTickRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-pyramidGridRenderer-js.html">jqplot.<wbr>CanvasGridRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-canvasOverlay-js.html">jqplot.<wbr>CanvasOverlay</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-categoryAxisRenderer-js.html">jqplot.<wbr>CategoryAxisRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-ciParser-js.html">jqplot.<wbr>ciParser</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-cursor-js.html">jqplot.<wbr>Cursor</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-dateAxisRenderer-js.html">jqplot.<wbr>DateAxisRenderer</a></div></div><div class=MEntry><div class=MFile><a href="plugins/jqplot-donutRenderer-js.html">jqplot.<wbr>DonutRenderer</a></div
2011-08-10 01:10:50 +02:00
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Files">Files</option><option value="Functions">Functions</option><option value="Hooks">Hooks</option><option value="Properties">Properties</option></select></div><script language=JavaScript><!--
HideAllBut([1, 4, 5], 6);// --></script></div><!--Menu-->
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CSection><b>This document is out of date. </div></div><!--END_ND_TOOLTIPS-->
<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>
<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>