00001 package org.swtchart.examples;
00002
00003 import org.eclipse.swt.SWT;
00004 import org.eclipse.swt.layout.FillLayout;
00005 import org.eclipse.swt.widgets.Composite;
00006 import org.eclipse.swt.widgets.Display;
00007 import org.eclipse.swt.widgets.Shell;
00008 import org.swtchart.Chart;
00009 import org.swtchart.IBarSeries;
00010 import org.swtchart.ISeries.SeriesType;
00011
00015 public class OrientationExample {
00016
00017 private static final double[] ySeries = { 0.2, 1.1, 1.9, 2.3, 1.8, 1.5,
00018 1.8, 2.6, 2.9, 3.2 };
00019
00026 public static void main(String[] args) {
00027 Display display = new Display();
00028 Shell shell = new Shell(display);
00029 shell.setText("Orientation");
00030 shell.setSize(500, 400);
00031 shell.setLayout(new FillLayout());
00032
00033 createChart(shell);
00034
00035 shell.open();
00036 while (!shell.isDisposed()) {
00037 if (!display.readAndDispatch()) {
00038 display.sleep();
00039 }
00040 }
00041 display.dispose();
00042 }
00043
00051 static public Chart createChart(Composite parent) {
00052
00053
00054 Chart chart = new Chart(parent, SWT.NONE);
00055
00056
00057 chart.setOrientation(SWT.VERTICAL);
00058
00059
00060 chart.getTitle().setText("Orientation");
00061 chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
00062 chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
00063
00064
00065 IBarSeries barSeries = (IBarSeries) chart.getSeriesSet().createSeries(
00066 SeriesType.BAR, "bar series");
00067 barSeries.setYSeries(ySeries);
00068
00069
00070 chart.getAxisSet().adjustRange();
00071
00072 return chart;
00073 }
00074 }