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.ISeries;
00010 import org.swtchart.ISeries.SeriesType;
00011
00015 public class AngledAxisTickLabelsExample {
00016
00017 private static final double[] ySeries = { 1.3, 2.4, 3.9, 2.6, 1.1 };
00018
00019 private static final String[] cagetorySeries = { "aaaaaaaaaa", "bb",
00020 "ccccccccccc", "dddddddddd", "eeeeeeeee" };
00021
00028 public static void main(String[] args) {
00029 Display display = new Display();
00030 Shell shell = new Shell(display);
00031 shell.setText("Angled Axis Tick Labels");
00032 shell.setSize(500, 400);
00033 shell.setLayout(new FillLayout());
00034
00035 createChart(shell);
00036
00037 shell.open();
00038 while (!shell.isDisposed()) {
00039 if (!display.readAndDispatch()) {
00040 display.sleep();
00041 }
00042 }
00043 display.dispose();
00044 }
00045
00053 static public Chart createChart(Composite parent) {
00054
00055
00056 Chart chart = new Chart(parent, SWT.NONE);
00057 chart.getTitle().setText("Angled Axis Tick Labels");
00058
00059
00060 chart.getAxisSet().getXAxis(0).enableCategory(true);
00061 chart.getAxisSet().getXAxis(0).setCategorySeries(cagetorySeries);
00062 chart.getAxisSet().getXAxis(0).getTick().setTickLabelAngle(45);
00063
00064
00065 ISeries barSeries = chart.getSeriesSet().createSeries(SeriesType.BAR,
00066 "bar series");
00067 barSeries.setYSeries(ySeries);
00068
00069 chart.getAxisSet().adjustRange();
00070
00071 return chart;
00072 }
00073 }