我使用 swtchart ( http://www.swtchart.org/ ) 并尝试在对话框中显示它,但它总是失败。
SWT Dialog 不支持 swtchart,是吗?
public final class TestDialog extends
Dialog {
private Chart chart;
private static double[] ySeries1 = {1,2,3,4,5,6,7,8,9,0};
public TestDialog(Shell shell) {
super(shell);
}
protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent);
createChart(composite);
return composite;
}
static public Chart createChart(Composite parent) {
// create a chart
Chart chart = new Chart(parent, SWT.NONE);
// set titles
chart.getTitle().setText("Large Series");
chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
// create line series
ILineSeries lineSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE,
"line series");
lineSeries.setYSeries(ySeries1);
lineSeries.setSymbolSize(2);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
}