use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class MultipleAxesExample method createChart.
/**
* create the chart.
*
* @param parent
* The parent composite
* @return The created chart
*/
public static Chart createChart(Composite parent) {
// create a chart
Chart chart = new Chart(parent, SWT.NONE);
// set titles
chart.getTitle().setText("Multiple Axes");
chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude 1");
// create second Y axis
int axisId = chart.getAxisSet().createYAxis();
// set the properties of second Y axis
IAxis yAxis2 = chart.getAxisSet().getYAxis(axisId);
yAxis2.setPosition(Position.Secondary);
final Color RED = Display.getDefault().getSystemColor(SWT.COLOR_RED);
yAxis2.getTick().setForeground(RED);
yAxis2.getTitle().setForeground(RED);
yAxis2.getTitle().setText("Amplitude 2");
// create line series
ILineSeries lineSeries1 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series 1");
lineSeries1.setYSeries(ySeries1);
ILineSeries lineSeries2 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series 2");
lineSeries2.setYSeries(ySeries2);
lineSeries2.setLineColor(RED);
// assign series to second Y axis
lineSeries2.setYAxisId(axisId);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class RunAllExamples method createList.
private static void createList(String tabName, final Vector<Chart> charts, TabFolder tabFolder, final StackLayout layout, final Composite composite) {
final List list = new List(tabFolder, SWT.H_SCROLL | SWT.V_SCROLL);
TabItem basicTabItem = new TabItem(tabFolder, SWT.NONE);
basicTabItem.setText(tabName);
basicTabItem.setControl(list);
for (Chart chart : charts) {
list.add(chart.getTitle().getText());
}
list.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
Chart chart = charts.get(list.getSelectionIndex());
chart.getAxisSet().adjustRange();
layout.topControl = chart;
composite.layout();
}
});
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class SeriesLabelExample method createChart.
/**
* create the chart.
*
* @param parent
* The parent composite
* @return The created chart
*/
public static Chart createChart(Composite parent) {
// create a chart
Chart chart = new Chart(parent, SWT.NONE);
// set titles
chart.getTitle().setText("Series Label");
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(ySeries);
// set label visible
lineSeries.getLabel().setVisible(true);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class StackSeriesExample method createChart.
/**
* create the chart.
*
* @param parent
* The parent composite
* @return The created chart
*/
public static Chart createChart(Composite parent) {
// create a chart
Chart chart = new Chart(parent, SWT.NONE);
// set titles
chart.getTitle().setText("Stack Series");
chart.getAxisSet().getXAxis(0).getTitle().setText("Month");
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
// set category
chart.getAxisSet().getXAxis(0).enableCategory(true);
chart.getAxisSet().getXAxis(0).setCategorySeries(new String[] { "Jan", "Feb", "Mar", "Apr", "May" });
// create bar series
IBarSeries barSeries1 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series 1");
barSeries1.setYSeries(ySeries1);
barSeries1.setBarColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
IBarSeries barSeries2 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series 2");
barSeries2.setYSeries(ySeries2);
// enable stack series
barSeries1.enableStack(true);
barSeries2.enableStack(true);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class StepChartExample method createChart.
/**
* create the chart.
*
* @param parent
* The parent composite
* @return The created chart
*/
public static Chart createChart(Composite parent) {
// create a chart
Chart chart = new Chart(parent, SWT.NONE);
// set titles
chart.getTitle().setText("Step Chart");
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(ySeries);
lineSeries.setSymbolType(PlotSymbolType.NONE);
lineSeries.enableStep(true);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
Aggregations