JetChart implements zooming of certain types of series, most of them are those handled by the Graph class, like line series, bar series, area
series, etc. ScatterGraph and PieGraph do not support zooming.
The application below displays an area series. To zoom into a smaller sequence of points, click the left or right mouse button at a point within
the chart area and drag cursor.
After selecting the area to be zoomed, release mouse button and the selected area is expanded. To return a zoomed chart to normal view, right
click mouse button at any point of the chart area.
Chart zooming is not possible if dragging is enabled.
import javax.swing.*; import java.awt.*; import com.jinsight.jetchart.*; public class Main extends JFrame { public Main() { Graph graph=new Graph(); graph.setZoomEnabled(true); graph.setTitle(new String[]{"The JetChart Library","Zooming charts"}); double[] values={131.90,132.80,130.50,131.00,136.75,135.00,131.50,130.50, 132.40,133.30,130.90,123.40,122.25,118.00,120.00,116.10, 115.00,103.45,107.50,103.80,99.00,96.75,94.00,95.90,97.50, 98.40,100.20,102.00,110.40,104.50,108.70,107.75,107.45, 103.00,100.90,99.25,93.80,99.25,103.00,100.25,102.70, 107.15,106.00,107.15,109.00,104.00,96.50,97.95,99.70, 97.70,91.00,87.45,86.80,88.60,85.40,85.90,84.85, 76.55, 68.00,67.45,61.90,60.90,60.75,53.60,58.50, 57.20,51.25,48.50,45.75,46.90,52.55,51.40,54.00, 51.70,41.20,38.75,34.00,33.50,33.25,34.25,33.90, 30.00,33.50,34.95,31.45,26.95,28.40,30.90,28.90, 29.90,29.80,33.25,34.50,34.00,36.90,37.00,36.40, 34.70,37.50,38.30,39.40,43.50,45.80,48.70,46.45}; AreaSerie as=new AreaSerie(values,"Area series"); as.setColor(Color.green); // Disables the area series vertical lines. as.setAreaLinesEnabled(false); graph.addSerie(as); GraphSet graphSet=graph.getGraphSet(0); // Disables labels marks on the x axis. graphSet.setLabelsMarksEnabled(false); // Sets the properties of the primary GraphSet scale and grid. Scale scale=graphSet.getScale(); Grid grid=graphSet.getGrid(); scale.setAutoScaleEnabled(false); scale.setMaxValue(140); scale.setIncrement(30); grid.setEnabled(true); grid.setStyle(Grid.DASHED); Container ct=getContentPane(); ct.add(graph); setSize(550,450); setVisible(true); } public static void main(String[] args) { new Main(); } }