Files changed (1)
+<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>
+ <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>
+ <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:
+ Tabs 2 and 3 have plots. Since tabs 2 and 3 are initially inactive, their contents (and the plots) are initially hidden.
+ <p>This plot was in an initially hidden container. It's hieght and width are set by the "data-height" and "data-width" properties of the plot container.</p>
+ <div id="chart1" data-height="260px" data-width="480px" style="margin-top:20px; margin-left:20px;"></div>
+ <p>This plot is in an initially hidden container. It's height and width are set by the 'height' and 'width' properties of the options object passed into the plot constructor.</p>
+ <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>
+ Here is section 1 there is no plot. Section 2 has a plot that will display once the section is completely shown.
+ This plot also has it's 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.
+ <div id="chart3" data-height="200" data-width="400" style="width:400px; height: 200px; margin-top: 20px; margin-left: 20px"></div>
+<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 it's container becomes visible.</p>
+ 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.
+ <link class="include" type="text/css" href="jquery-ui/css/ui-lightness/jquery-ui.min.css" rel="Stylesheet" />