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>Resizable 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
  body {
37
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
38
  }
39
 
40
  p, pre {
41
    margin: 1.5em;
42
  }
43
 
44
  body table {
45
    margin: 2em;
46
  }
47
 
48
    #resizable1, #resizable2, #resizable3 {
49
      width: 440px;
50
      height: 330px;
51
      margin-top: 2em;
52
      margin-bottom: 2em;
53
      padding: 1.2em;
54
    }
55
 
56
 
57
    .jqplot-target {
58
      font-size: 16px;
59
    }
60
 
61
    .ui-resizable-helper {
62
      border: 2px solid gray;
63
    }
64
  </style>
65
 
66
<p>Plot targets can be placed inside of resizable containers for dynamic plot sizing.  The examples here use the jQuery UI package for resizing functionality.</p>
67
 
68
    <table><tr>
69
      <td>
70
<div id="resizable1" class="ui-widget-content">
71
    <div id="chart1" style="height:96%; width:96%;"></div>
72
</div>
73
</td>
74
<td>
75
 
76
<p>The first plot has good resize performance in Firefox, Safari and other canvas enabled browsers.  The plot will resize dynamically with the container.  IE performance will be slow since IE doesn't natively support the canvas element.</p>
77
 
78
<p>Resizing is handled by binding a handler to the 'resize' event. The handler function replots the plot during resize.  Here, the plot targets's height and width must be specified as a percentage of the container and the container must be visible.</p>
79
 
80
<p>The event handler looks like:</p>
81
<pre>
82
    $('#resizable1').bind('resize', function(event, ui) {
83
        plot1.replot( { resetAxes: true } );
84
    });
85
</pre>
86
</td>
87
</tr></table>
88
<table><tr>
89
  <td>
90
 
91
<div id="resizable2" class="ui-widget-content">
92
    <div id="chart2" style="height:96%; width:96%;"></div>
93
</div>
94
</td>
95
<td>
96
<p>The second plot uses an alternative sizing method that is more responsive in all browsers, especially IE.  The difference?  First, the plot target is given a static height and width that will fit inside the resizable container.  Then, instead of resizing dynamically with the container, the plots replot() method is called at the end of the resize.  When resizing is done, the plot targets height and width are set to a percentage of the container's and then the replot method is called.</p>
97
 
98
<p>Also, an options object is passed into the replot method.  It contains a single option, resetAxes, which, if true, resets all axes so the min, max, numberTicks and tickInterval are recalculated.</p>
99
<pre>
100
    $('#resizable2').bind('resizestop', function(event, ui) {
101
        $('#chart2').height($('#resizable2').height()*0.96);
102
        $('#chart2').width($('#resizable2').width()*0.96);
103
        plot2.replot({resetAxes:true});
104
    });
105
</pre>
106
 
107
<p>You can also pass in option objects to reset specific axes like:</p>
108
 
109
<pre>
110
    {resetAxes:['yaxis', 'y2axis']};
111
 
112
    or
113
 
114
    {resetAxes:{yaxis:true, y2axis:true}};
115
</pre>
116
 
117
</td></tr></table>
118
 
119
<table><tr>
120
  <td>
121
 
122
<div id="resizable3" class="ui-widget-content">
123
    <div id="chart3" style="height:96%; width:96%;"></div>
124
</div>
125
</td>
126
<td>
127
<p>The third plot shows resizing with a Meter Gauge plot.  Since a Meter Gauge doesn't have axes, resetAxes: trues doesn't have any effect. Instead, jqPlot will resize the chart if you set pretty much any other option (in this example, the title is set).</p>
128
 
129
</td></tr></table>
130
 
131
<pre class="code brush:js"></pre>
132
 
133
 
134
  <script type="text/javascript" class="code">
135
 
136
  $(document).ready(function(){
137
 
138
    $.jqplot._noToImageButton = true;
139
 
140
    var l1 = [18, 36, 41, 93, 100, 115, 133, 129, 119, 107, 91, 146, 169];
141
    var l2 = [[8, 66], [13, 46], [22,14]];
142
    var l3 = [[3.3, 7], [9.5, 22], [12.1, 37], [18.6, 95], [24, 102]];
143
    var s1 = [1];
144
 
145
    var options = {
146
      title: "Lines",
147
      legend:{show:true, location:'se'},
148
      seriesDefaults:{trendline:{show:true, type:"exp"}},
149
      axes:{
150
        yaxis:{
151
          renderer:$.jqplot.LogAxisRenderer
152
        }
153
      }
154
    };
155
 
156
    $("#resizable1").resizable({delay:20});
157
    $("#resizable2").resizable({delay:20, helper:'ui-resizable-helper'});
158
    $("#resizable3").resizable({delay:20, helper:'ui-resizable-helper'});
159
 
160
    $('#resizable1').bind('resize', function(event, ui) {
161
        // pass in resetAxes: true option to get rid of old ticks and axis properties
162
        // which should be recomputed based on new plot size.
163
        plot1.replot( { resetAxes: true } );
164
    });
165
 
166
    $('#resizable2').bind('resizestop', function(event, ui) {
167
        $('#chart2').height($('#resizable2').height()*0.96);
168
        $('#chart2').width($('#resizable2').width()*0.96);
169
        // pass in resetAxes: true option to get rid of old ticks and axis properties
170
        // which should be recomputed based on new plot size.
171
        plot2.replot( { resetAxes:true } );
172
    });
173
 
174
    $('#resizable3').bind('resizestop', function(event, ui) {
175
        $('#chart3').height($('#resizable3').height()*0.96);
176
        $('#chart3').width($('#resizable3').width()*0.96);
177
        plot3.replot( { resetAxes:true, title: 'Resize' } );
178
    });
179
 
180
    var plot1 = $.jqplot('chart1', [l1, l3],  options);
181
    var plot2 = $.jqplot('chart2', [l1, l3],  options);
182
 
183
    var plot3 = $.jqplot('chart3',[s1],{
184
        title: 'Network Speed',
185
        seriesDefaults: {
186
            renderer: $.jqplot.MeterGaugeRenderer,
187
            rendererOptions: {
188
                label: 'MB/s'
189
            }
190
        }
191
    });
192
 
193
  });
194
 
195
  </script>
196
 
197
<!-- End example scripts -->
198
 
199
<!-- Don't touch this! -->
200
 
201
 
202
    <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
203
    <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
204
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
205
    <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
206
<!-- End Don't touch this! -->
207
 
208
<!-- Additional plugins go here -->
209
 
210
  <script class="include" type="text/javascript" src="../plugins/jqplot.logAxisRenderer.min.js"></script>
211
  <script class="include" type="text/javascript" src="../plugins/jqplot.trendline.min.js"></script>
212
  <script class="include" type="text/javascript" src="../plugins/jqplot.meterGaugeRenderer.min.js"></script>
213
 
214
  <link class="include" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/themes/smoothness/jquery-ui.css" rel="Stylesheet" />
215
  <script class="include" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
216
 
217
<!-- End additional plugins -->
218
 
219
        </div>
220
         <div class="col2">
221
 
222
           <div class="example-link"><a class="example-link" href="data-renderers.html">AJAX and JSON Data Loading via Data Renderers</a></div>
223
           <div class="example-link"><a class="example-link" href="barLineAnimated.html">Animated Charts</a></div>
224
           <div class="example-link"><a class="example-link" href="dashboardWidget.html">Animated Dashboard Sample - Filled Line with Log Axis</a></div>
225
           <div class="example-link"><a class="example-link" href="kcp_area.html">Area Chart</a></div>
226
           <div class="example-link"><a class="example-link" href="kcp_area2.html">Area Chart 2</a></div>
227
           <div class="example-link"><a class="example-link" href="axisLabelTests.html">Axis Labels</a></div>
228
           <div class="example-link"><a class="example-link" href="axisLabelsRotatedText.html">Axis Labels and Rotated Text</a></div>
229
           <div class="example-link"><a class="example-link" href="barTest.html">Bar Charts</a></div>
230
           <div class="example-link"><a class="example-link" href="multipleBarColors.html">Bar Colors Example</a></div>
231
           <div class="example-link"><a class="example-link" href="bezierCurve.html">Bezier Curve Plots</a></div>
232
           <div class="example-link"><a class="example-link" href="blockPlot.html">Block Plots</a></div>
233
           <div class="example-link"><a class="example-link" href="bubbleChart.html">Bubble Charts</a></div>
234
           <div class="example-link"><a class="example-link" href="bubble-plots.html">Bubble Plots</a></div>
235
           <div class="example-link"><a class="example-link" href="candlestick.html">Candlestick and Open Hi Low Close Charts</a></div>
236
           <div class="example-link"><a class="example-link" href="theming.html">Chart Theming</a></div>
237
           <div class="example-link"><a class="example-link" href="fillBetweenLines.html">Charts with Fill Between Lines</a></div>
238
           <div class="example-link"><a class="example-link" href="kcp_cdf.html">Cumulative Density Function Chart</a></div>
239
           <div class="example-link"><a class="example-link" href="dashedLines.html">Dashed Lines with Smoothing</a></div>
240
           <div class="example-link"><a class="example-link" href="cursor-highlighter.html">Data Point Highlighting, Tooltips and Cursor Tracking</a></div>
241
           <div class="example-link"><a class="example-link" href="point-labels.html">Data Point labels</a></div>
242
           <div class="example-link"><a class="example-link" href="date-axes.html">Date Axes</a></div>
243
           <div class="example-link"><a class="example-link" href="dateAxisRenderer.html">Date Axes 2</a></div>
244
           <div class="example-link"><a class="example-link" href="rotatedTickLabelsZoom.html">Date Axes, Rotated Labels and Zooming</a></div>
245
           <div class="example-link"><a class="example-link" href="canvas-overlay.html">Draw Lines on Plots - Canvas Overlay</a></div>
246
           <div class="example-link"><a class="example-link" href="draw-rectangles.html">Draw Rectangles on Plots</a></div>
247
           <div class="example-link"><a class="example-link" href="kcp_engel.html">Engel Curves</a></div>
248
           <div class="example-link"><a class="example-link" href="bandedLine.html">Error Bands and Confidence Intervals</a></div>
249
           <div class="example-link"><a class="example-link" href="area.html">Filled (Area) Charts</a></div>
250
           <div class="example-link"><a class="example-link" href="axisScalingForceTickAt.html">Force Plot to Have Tick at 0 or 100</a></div>
251
           <div class="example-link"><a class="example-link" href="hiddenPlotsInTabs.html">Hidden Plots</a></div>
252
           <div class="example-link"><a class="example-link" href="customHighlighterCursorTrendline.html">Highlighting, Dragging Points, Cursor and Trend Lines</a></div>
253
           <div class="example-link"><a class="example-link" href="line-charts.html">Line Charts and Options</a></div>
254
           <div class="example-link"><a class="example-link" href="kcp_lorenz.html">Lorenz Curves</a></div>
255
           <div class="example-link"><a class="example-link" href="mekkoCharts.html">Mekko Charts</a></div>
256
           <div class="example-link"><a class="example-link" href="meterGauge.html">Meter Gauge</a></div>
257
           <div class="example-link"><a class="example-link" href="candlestick-charts.html">Open Hi Low Close and Candlestick Charts</a></div>
258
           <div class="example-link"><a class="example-link" href="pieTest.html">Pie Charts and Options</a></div>
259
           <div class="example-link"><a class="example-link" href="pieTest4.html">Pie Charts and Options 2</a></div>
260
           <div class="example-link"><a class="example-link" href="pie-donut-charts.html">Pie and Donut Charts</a></div>
261
           <div class="example-link"><a class="example-link" href="selectorSyntax.html">Plot Creation with jQuery Selectors</a></div>
262
           <div class="example-link"><a class="example-link" href="zooming.html">Plot Zooming and Cursor Control</a></div>
263
           <div class="example-link"><a class="example-link" href="kcp_pdf.html">Probability Density Function Chart</a></div>
264
           <div class="example-link"><a class="example-link" href="kcp_pyramid_by_age.html">Pyramid Chart By Age</a></div>
265
           <div class="example-link"><a class="example-link" href="kcp_pyramid.html">Pyramid Charts</a></div>
266
           <div class="example-link"><a class="example-link" href="kcp_pyramid2.html">Pyramid Charts 2</a></div>
267
           <div class="example-link"><a class="example-link" href="kcp_quintiles.html">Quintile Pyramid Charts</a></div>
268
           <div class="example-link"><a class="example-link" href="resizablePlot.html">Resizable Plots</a></div>
269
           <div class="example-link"><a class="example-link" href="rotated-tick-labels.html">Rotated Labels and Font Styling</a></div>
270
           <div class="example-link"><a class="example-link" href="smoothedLine.html">Smoothed Lines</a></div>
271
           <div class="example-link"><a class="example-link" href="bar-charts.html">Vertical and Horizontal Bar Charts</a></div>
272
           <div class="example-link"><a class="example-link" href="waterfall.html">Waterfall Charts</a></div>
273
           <div class="example-link"><a class="example-link" href="waterfall2.html">Waterfall Charts 2</a></div>
274
           <div class="example-link"><a class="example-link" href="zoomOptions.html">Zoom Options</a></div>
275
           <div class="example-link"><a class="example-link" href="zoomProxy.html">Zoom Proxy - Control one plot from another</a></div>
276
           <div class="example-link"><a class="example-link" href="zoom1.html">Zooming</a></div>
277
           <div class="example-link"><a class="example-link" href="dateAxisLogAxisZooming.html">Zooming with Date and Log Axes</a></div>
278
 
279
         </div>
280
               </div>
281
    </div>
282
    <script type="text/javascript" src="example.min.js"></script>
283
 
284
</body>
285
 
286
 
287
</html>