use of org.eclipse.swtchart.ILineSeries 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.ILineSeries 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.ILineSeries 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;
}
use of org.eclipse.swtchart.ILineSeries in project swtchart by eclipse.
the class PxielToDataConversionExample method createChart.
/**
* create the chart.
*
* @param parent
* The parent composite
* @return The created chart
*/
public static Chart createChart(Composite parent) {
// create a chart
final Chart chart = new Chart(parent, SWT.NONE);
chart.getTitle().setText("Pxiel To Data Conversion");
// get axes
final IAxis xAxis = chart.getAxisSet().getXAxis(0);
final IAxis yAxis = chart.getAxisSet().getYAxis(0);
// create line series
ILineSeries series = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
series.setYSeries(ySeries);
// adjust the axis range
chart.getAxisSet().adjustRange();
// add mouse move listener to show mouse position on tooltip
chart.getPlotArea().addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
double x = xAxis.getDataCoordinate(e.x);
double y = yAxis.getDataCoordinate(e.y);
chart.getPlotArea().setToolTipText("x:" + x + ", y:" + y);
}
});
return chart;
}
use of org.eclipse.swtchart.ILineSeries in project swtchart by eclipse.
the class InteractiveChartExample method createPartControl.
/*
* @see WorkbenchPart#createPartControl(Composite)
*/
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
// create an interactive chart
chart = new InteractiveChart(parent, SWT.NONE);
// set title
chart.getTitle().setText("Sample Interactive Chart");
// set category series
chart.getAxisSet().getXAxis(0).enableCategory(true);
chart.getAxisSet().getXAxis(0).setCategorySeries(categorySeries);
// create line series 1
ILineSeries lineSeries1 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series 1");
lineSeries1.setYSeries(yLineSeries1);
// create line series 2
ILineSeries lineSeries2 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "line series 2");
lineSeries2.setYSeries(yLineSeries2);
lineSeries2.setLineColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
// create bar series 1
IBarSeries barSeries1 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series 1");
barSeries1.setYSeries(yBarSeries1);
// create bar series 2
IBarSeries barSeries2 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series 2");
barSeries2.setYSeries(yBarSeries2);
barSeries2.setBarColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
// adjust the axis range
chart.getAxisSet().adjustRange();
}
Aggregations