line-charts.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Line Charts and Options</title>
  5. <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
  6. <link rel="stylesheet" type="text/css" href="examples.min.css" />
  7. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
  8. <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
  9. <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
  10. <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11. </head>
  12. <body>
  13. <div id="header">
  14. <div class="nav">
  15. <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
  16. <a class="nav" href="../../../docs/"><span>&gt;</span>Docs</a>
  17. <a class="nav" href="../../download/"><span>&gt;</span>Download</a>
  18. <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
  19. <a class="nav" href="../../../donate.php"><span>&gt;</span>Donate</a>
  20. </div>
  21. </div>
  22. <div class="colmask leftmenu">
  23. <div class="colleft">
  24. <div class="col1" id="example-content">
  25. <!-- Example scripts go here -->
  26. <p>The most basic jqPlot chart takes a series of data and plots a line. No options need to be supplied. Data is passed in as an array of series. A series can be either an array of y values or an array of [x,y] data pairs. If y values only, x values are assigned like 1, 2, 3, ... Note, for this plot you don't need any plugins.</p>
  27. <div id="chart1" style="height:300px; width:500px;"></div>
  28. <pre class="code prettyprint brush: js"></pre>
  29. <p>The following plot uses a number of options to set the title, add axis labels, and shows how to use the canvasAxisLabelRenderer plugin to provide rotated axis labels.</p>
  30. <div id="chart2" style="height:300px; width:500px;"></div>
  31. <pre class="code prettyprint brush: js"></pre>
  32. <p>There are numerous line style options to control how the lines and markers are displayed.</p>
  33. <div id="chart3" style="height:300px; width:500px;"></div>
  34. <pre class="code prettyprint brush: js"></pre>
  35. <script class="code" type="text/javascript">
  36. $(document).ready(function(){
  37. var plot1 = $.jqplot ('chart1', [[3,7,9,1,5,3,8,2,5]]);
  38. });
  39. </script>
  40. <script class="code" type="text/javascript">
  41. $(document).ready(function(){
  42. var plot2 = $.jqplot ('chart2', [[3,7,9,1,5,3,8,2,5]], {
  43. // Give the plot a title.
  44. title: 'Plot With Options',
  45. // You can specify options for all axes on the plot at once with
  46. // the axesDefaults object. Here, we're using a canvas renderer
  47. // to draw the axis label which allows rotated text.
  48. axesDefaults: {
  49. labelRenderer: $.jqplot.CanvasAxisLabelRenderer
  50. },
  51. // Likewise, seriesDefaults specifies default options for all
  52. // series in a plot. Options specified in seriesDefaults or
  53. // axesDefaults can be overridden by individual series or
  54. // axes options.
  55. // Here we turn on smoothing for the line.
  56. seriesDefaults: {
  57. rendererOptions: {
  58. smooth: true
  59. }
  60. },
  61. // An axes object holds options for all axes.
  62. // Allowable axes are xaxis, x2axis, yaxis, y2axis, y3axis, ...
  63. // Up to 9 y axes are supported.
  64. axes: {
  65. // options for each axis are specified in seperate option objects.
  66. xaxis: {
  67. label: "X Axis",
  68. // Turn off "padding". This will allow data point to lie on the
  69. // edges of the grid. Default padding is 1.2 and will keep all
  70. // points inside the bounds of the grid.
  71. pad: 0
  72. },
  73. yaxis: {
  74. label: "Y Axis"
  75. }
  76. }
  77. });
  78. });
  79. </script>
  80. <script class="code" type="text/javascript">
  81. $(document).ready(function(){
  82. // Some simple loops to build up data arrays.
  83. var cosPoints = [];
  84. for (var i=0; i<2*Math.PI; i+=1){
  85. cosPoints.push([i, Math.cos(i)]);
  86. }
  87. var sinPoints = [];
  88. for (var i=0; i<2*Math.PI; i+=0.4){
  89. sinPoints.push([i, 2*Math.sin(i-.8)]);
  90. }
  91. var powPoints1 = [];
  92. for (var i=0; i<2*Math.PI; i+=1) {
  93. powPoints1.push([i, 2.5 + Math.pow(i/4, 2)]);
  94. }
  95. var powPoints2 = [];
  96. for (var i=0; i<2*Math.PI; i+=1) {
  97. powPoints2.push([i, -2.5 - Math.pow(i/4, 2)]);
  98. }
  99. var plot3 = $.jqplot('chart3', [cosPoints, sinPoints, powPoints1, powPoints2],
  100. {
  101. title:'Line Style Options',
  102. // Set default options on all series, turn on smoothing.
  103. seriesDefaults: {
  104. rendererOptions: {
  105. smooth: true
  106. }
  107. },
  108. // Series options are specified as an array of objects, one object
  109. // for each series.
  110. series:[
  111. {
  112. // Change our line width and use a diamond shaped marker.
  113. lineWidth:2,
  114. markerOptions: { style:'dimaond' }
  115. },
  116. {
  117. // Don't show a line, just show markers.
  118. // Make the markers 7 pixels with an 'x' style
  119. showLine:false,
  120. markerOptions: { size: 7, style:"x" }
  121. },
  122. {
  123. // Use (open) circlular markers.
  124. markerOptions: { style:"circle" }
  125. },
  126. {
  127. // Use a thicker, 5 pixel line and 10 pixel
  128. // filled square markers.
  129. lineWidth:5,
  130. markerOptions: { style:"filledSquare", size:10 }
  131. }
  132. ]
  133. }
  134. );
  135. });
  136. </script>
  137. <!-- End example scripts -->
  138. <!-- Don't touch this! -->
  139. <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
  140. <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
  141. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
  142. <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
  143. <!-- End Don't touch this! -->
  144. <!-- Additional plugins go here -->
  145. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
  146. <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
  147. <!-- End additional plugins -->
  148. </div>
  149. <div class="col2">
  150. <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
  151. <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
  152. <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
  153. <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
  154. <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
  155. <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
  156. <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
  157. <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
  158. <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
  159. <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
  160. <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
  161. <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
  162. <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
  163. <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
  164. <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
  165. <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
  166. <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
  167. <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
  168. <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
  169. <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
  170. <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
  171. <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
  172. <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
  173. <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
  174. <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
  175. <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
  176. <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
  177. <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
  178. <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
  179. <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
  180. <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
  181. <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
  182. <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
  183. <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
  184. <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
  185. <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
  186. <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
  187. <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
  188. <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
  189. <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
  190. <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
  191. <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
  192. <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
  193. <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
  194. <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
  195. <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
  196. <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
  197. <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
  198. <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
  199. <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
  200. <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
  201. <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
  202. <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
  203. <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
  204. <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
  205. <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
  206. </div>
  207. </div>
  208. </div>
  209. <script type="text/javascript" src="example.min.js"></script>
  210. </body>
  211. </html>