Subversion-Projekte lars-tiefland.cienc

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
9 lars 1
<!DOCTYPE html>
2
 
3
<html>
4
<head>
5
 
6
    <title>Hidden Plots</title>
7
 
8
    <link class="include" rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
9
    <link rel="stylesheet" type="text/css" href="examples.min.css" />
10
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shCoreDefault.min.css" />
11
    <link type="text/css" rel="stylesheet" href="syntaxhighlighter/styles/shThemejqPlot.min.css" />
12
 
13
    <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
14
    <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
15
 
16
 
17
</head>
18
<body>
19
    <div id="header">
20
        <div class="nav">
21
            <a class="nav" href="../../../index.php"><span>&gt;</span>Home</a>
22
            <a class="nav"  href="../../../docs/"><span>&gt;</span>Docs</a>
23
            <a class="nav"  href="../../download/"><span>&gt;</span>Download</a>
24
            <a class="nav" href="../../../info.php"><span>&gt;</span>Info</a>
25
            <a class="nav"  href="../../../donate.php"><span>&gt;</span>Donate</a>
26
        </div>
27
    </div>
28
    <div class="colmask leftmenu">
29
      <div class="colleft">
30
        <div class="col1" id="example-content">
31
 
32
 
33
<!-- Example scripts go here -->
34
 
35
  <style type="text/css">
36
    .ui-tabs, .ui-accordion {
37
      width: 690px;
38
      margin: 2em auto;
39
    }
40
    .ui-tabs-nav, .ui-accordion-header {
41
      font-size: 12px;
42
    }
43
 
44
    .ui-tabs-panel, .ui-accordion-content {
45
      font-size: 14px;
46
    }
47
 
48
    .jqplot-target {
49
      font-size: 18px;
50
    }
51
 
52
    ol.description {
53
      list-style-position: inside;
54
      font-size:15px;
55
      margin:1.5em auto;
56
      padding:0 15px;
57
      width:600px;
58
    }
59
  </style>
60
 
61
<p class="description">This page demonstrates placing plots within jQuery UI widgets. Tab 2 and tab 3 contain plots.  Using a combination of alternate sizing specification and the jqplot "replot" method the plots are properly displayed when their containers are shown.</p>
62
 
63
  <p class="description">The alternate sizing specifications for setting plot height and width are needed because a hidden element (or child of a hidden element) has no size.  The first example in tab 2 uses custom "data-height" and "data-width" attributes on the plot target element.  The second example uses "width" and "height" properties specified on the options object passed into the $.jqplot() function.</p>
64
 
65
  <p class="description">The default plot size is 300px wide by 400px high. The default setting can be overridden by specifying different values to the $.jqplot.config.defaultHeight and $.jqplot.config.defaultWidth properties.  Height and width values are taken in this order of precedence:
66
  </p>
67
 
68
      <ol class="description">
69
        <li>The css properties of the plot target if available (not available with display:none;).</li>
70
        <li>Options object passed into the $.jqplot() function.</li>
71
        <li>Custom data-height and data-width attributes on the plot target.</li>
72
        <li>The config defaults.</li>
73
      </ol>
74
 
75
  <div id="tabs">
76
    <ul>
77
      <li><a href="#tabs-1">Tab 1</a></li>
78
      <li><a href="#tabs-2">Tab 2</a></li>
79
      <li><a href="#tabs-3">Tab 3</a></li>
80
    </ul>
81
    <div id="tabs-1">
82
      Tabs 2 and 3 have plots.  Since tabs 2 and 3 are initially inactive, their contents (and the plots) are initially hidden.
83
    </div>
84
 
85
    <div id="tabs-2">
86
      <p>This plot was in an initially hidden container.  Its height and width are set by the "data-height" and "data-width" properties of the plot container.</p>
87
        <div id="chart1" data-height="260px" data-width="480px" style="margin-top:20px; margin-left:20px;"></div>
88
    </div>
89
 
90
    <div id="tabs-3">
91
      <p>This plot is in an initially hidden container.  Its height and width are set by the 'height' and 'width' properties of the options object passed into the plot constructor.</p>
92
        <div id="chart2" style="margin-top:20px; margin-left:20px;"></div>
93
    </div>
94
 
95
  </div>
96
 
97
    <p class="description">In the accordion below, section 2 contains a plot.  Sizing plots in hidden accordion sections is very similar to sizing in a tab widget.  Because of the default animation on accordions, however, the plot will not draw itself until the entire accordion panel is shown.</p>
98
 
99
<div id="accordion" style="margin-top:50px">
100
 
101
  <h3><a href="#">Section 1</a></h3>
102
  <div>
103
    Here is section 1 there is no plot.  Section 2 has a plot that will display once the section is completely shown.
104
  </div>
105
 
106
  <h3><a href="#">Section 2</a></h3>
107
  <div>
108
    <p>
109
    This plot also has its height and width set with the data-height and data-width attributes.  Note, if you want the accordion widget to properly size itself </em>before</em> the plot is shown, you must also specify a css height and width on the plot target.
110
    </p>
111
    <div id="chart3" data-height="200" data-width="400" style="width:400px; height: 200px; margin-top: 20px; margin-left: 20px"></div>
112
  </div>
113
 
114
</div>
115
 
116
<p class="description">Code for generating the plots follows.  It is critical to bind the callback to the UI widgets "show" or "change" method which calls the plots "replot" method.  Without this, the plot won't properly redraw itself when its container becomes visible.</p>
117
 
118
<p class="description">
119
  Note in the ui.index and plot._drawCount properties in the tabsshow callback.  ui.index gives the index of the activated tab.  plot._drawCount keeps track of how many times the plot was visibly drawn (or redrawn/replotted).  Generally, replot only needs to be called the first time the plot is visibly drawn, hence the check for plot._drawCount === 0.
120
  </p>
121
 
122
<pre class="code brush:js"></pre>
123
 
124
<script class="code" type="text/javascript">
125
    $(document).ready(function() {
126
        $.jqplot.config.enablePlugins = false;
127
 
128
        var l1 = [18, 36, 14, 11];
129
        var l2 = [[2, 14], [7, 2], [8,5]];
130
        var l3 = [4, 7, 9, 2, 11, 5, 9, 13, 8, 7];
131
        var l4 = [['peech',3], ['cabbage', 2], ['bean', 4], ['orange', 5]];
132
 
133
        $("#tabs").tabs();
134
        $("#accordion").accordion();
135
 
136
        var plot1 = $.jqplot('chart1', [l1, l2, l3],  {
137
          title: "I was hidden",
138
          lengend:{show:true},
139
          series:[{},{yaxis:'y2axis'}, {yaxis:'y3axis'}],
140
          cursor:{show:true, zoom:true},
141
          axesDefaults:{useSeriesColor:true, rendererOptions: { alignTicks: true}}
142
        });
143
 
144
        var plot2 = $.jqplot('chart2', [l4], {
145
          height: 200,
146
          width: 300,
147
          series:[{renderer:$.jqplot.PieRenderer}],
148
          legend:{show:true}
149
        });
150
 
151
        var catOHLC = [[1, 138.7, 139.68, 135.18, 135.4],
152
        [2, 143.46, 144.66, 139.79, 140.02],
153
        [3, 140.67, 143.56, 132.88, 142.44],
154
        [4, 136.01, 139.5, 134.53, 139.48],
155
        [5, 143.82, 144.56, 136.04, 136.97],
156
        [6, 136.47, 146.4, 136, 144.67],
157
        [7, 124.76, 135.9, 124.55, 135.81],
158
        [8, 123.73, 129.31, 121.57, 122.5]];
159
 
160
        var ticks = ['Tue', 'Wed', 'Thu', 'Fri', 'Mon', 'Tue', 'Wed', 'Thr'];
161
 
162
        var plot3 = $.jqplot('chart3',[catOHLC],{
163
          grid:{ drawGridlines:true},
164
          title: 'A CandleStick Chart',
165
          axes: {
166
              xaxis: {
167
                  renderer:$.jqplot.CategoryAxisRenderer,
168
                  ticks:ticks
169
              },
170
              yaxis: {
171
                  tickOptions:{formatString:'$%.2f'}
172
              }
173
          },
174
          series: [{renderer:$.jqplot.OHLCRenderer, rendererOptions:{candleStick:true}}]
175
        });
176
 
177
        $('#tabs').bind('tabsactivate', function(event, ui) {
178
          if (ui.newTab.index() === 1 && plot1._drawCount === 0) {
179
            plot1.replot();
180
          }
181
          else if (ui.newTab.index() === 2 && plot2._drawCount === 0) {
182
            plot2.replot();
183
          }
184
        });
185
 
186
        $('#accordion').bind('accordionactivate', function(event, ui) {
187
          var index = $(this).find("h3").index ( ui.newHeader[0] );
188
          if (index === 1) {
189
            plot3.replot();
190
          }
191
        });
192
 
193
    });
194
</script>
195
 
196
<!-- End example scripts -->
197
 
198
<!-- Don't touch this! -->
199
 
200
 
201
    <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
202
    <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
203
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
204
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
205
<!-- End Don't touch this! -->
206
 
207
<!-- Additional plugins go here -->
208
  <script class="include" type="text/javascript" src="../plugins/jqplot.cursor.min.js"></script>
209
  <script class="include" type="text/javascript" src="../plugins/jqplot.pieRenderer.min.js"></script>
210
  <script class="include" type="text/javascript" src="../plugins/jqplot.ohlcRenderer.min.js"></script>
211
  <script class="include" type="text/javascript" src="../plugins/jqplot.categoryAxisRenderer.min.js"></script>
212
  <link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
213
  <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
214
 
215
<!-- End additional plugins -->
216
 
217
        </div>
218
         <div class="col2">
219
 
220
           <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
221
           <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
222
           <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
223
           <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
224
           <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
225
           <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
226
           <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
227
           <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
228
           <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
229
           <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
230
           <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
231
           <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
232
           <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
233
           <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
234
           <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
235
           <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
236
           <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
237
           <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
238
           <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
239
           <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
240
           <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
241
           <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
242
           <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
243
           <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
244
           <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
245
           <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
246
           <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
247
           <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
248
           <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
249
           <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
250
           <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
251
           <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
252
           <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
253
           <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
254
           <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
255
           <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
256
           <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
257
           <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
258
           <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
259
           <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
260
           <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
261
           <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
262
           <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
263
           <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
264
           <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
265
           <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
266
           <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
267
           <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
268
           <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
269
           <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
270
           <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
271
           <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
272
           <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
273
           <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
274
           <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
275
           <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
276
 
277
         </div>
278
               </div>
279
    </div>
280
    <script type="text/javascript" src="example.min.js"></script>
281
 
282
</body>
283
 
284
 
285
</html>