Resizable Plots

Plot targets can be placed inside of resizable containers for dynamic plot sizing. The examples here use the jQuery UI package for resizing functionality.

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.

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.

The event handler looks like:

        $('#resizable1').bind('resize', function(event, ui) {
            plot1.replot( { resetAxes: true } );
        });

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.

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.

        $('#resizable2').bind('resizestop', function(event, ui) {
            $('#chart2').height($('#resizable2').height()*0.96);
            $('#chart2').width($('#resizable2').width()*0.96);
            plot2.replot({resetAxes:true});
        });

You can also pass in option objects to reset specific axes like:

        {resetAxes:['yaxis', 'y2axis']};

        or

        {resetAxes:{yaxis:true, y2axis:true}};

| 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).

AJAX and JSON Data Loading via Data Renderers
Animated Charts
Animated Dashboard Sample - Filled Line with Log Axis
Area Chart
Area Chart 2
Axis Labels
Axis Labels and Rotated Text
Bar Charts
Bar Colors Example
Bezier Curve Plots
Block Plots
Bubble Charts
Bubble Plots
Candlestick and Open Hi Low Close Charts
Chart Theming
Charts with Fill Between Lines
Cumulative Density Function Chart
Dashed Lines with Smoothing
Data Point Highlighting, Tooltips and Cursor Tracking
Data Point labels
Date Axes
Date Axes 2
Date Axes, Rotated Labels and Zooming
Draw Lines on Plots - Canvas Overlay
Draw Rectangles on Plots
Engel Curves
Error Bands and Confidence Intervals
Filled (Area) Charts
Force Plot to Have Tick at 0 or 100
Hidden Plots
Highlighting, Dragging Points, Cursor and Trend Lines
Line Charts and Options
Lorenz Curves
Mekko Charts
Meter Gauge
Open Hi Low Close and Candlestick Charts
Pie Charts and Options
Pie Charts and Options 2
Pie and Donut Charts
Plot Creation with jQuery Selectors
Plot Zooming and Cursor Control
Probability Density Function Chart
Pyramid Chart By Age
Pyramid Charts
Pyramid Charts 2
Quintile Pyramid Charts
Resizable Plots
Rotated Labels and Font Styling
Smoothed Lines
Vertical and Horizontal Bar Charts
Waterfall Charts
Waterfall Charts 2
Zoom Options
Zoom Proxy - Control one plot from another
Zooming
Zooming with Date and Log Axes