Search in sources :

Example 21 with ILineSeries

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;
}
Also used : Color(org.eclipse.swt.graphics.Color) ILineSeries(org.eclipse.swtchart.ILineSeries) Chart(org.eclipse.swtchart.Chart) IAxis(org.eclipse.swtchart.IAxis)

Example 22 with ILineSeries

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;
}
Also used : ILineSeries(org.eclipse.swtchart.ILineSeries) Chart(org.eclipse.swtchart.Chart)

Example 23 with ILineSeries

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;
}
Also used : ILineSeries(org.eclipse.swtchart.ILineSeries) Chart(org.eclipse.swtchart.Chart)

Example 24 with ILineSeries

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;
}
Also used : MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) MouseEvent(org.eclipse.swt.events.MouseEvent) ILineSeries(org.eclipse.swtchart.ILineSeries) Chart(org.eclipse.swtchart.Chart) IAxis(org.eclipse.swtchart.IAxis)

Example 25 with ILineSeries

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();
}
Also used : IBarSeries(org.eclipse.swtchart.IBarSeries) ILineSeries(org.eclipse.swtchart.ILineSeries) FillLayout(org.eclipse.swt.layout.FillLayout) InteractiveChart(org.eclipse.swtchart.extensions.charts.InteractiveChart)

Aggregations

ILineSeries (org.eclipse.swtchart.ILineSeries)29 Chart (org.eclipse.swtchart.Chart)13 Color (org.eclipse.swt.graphics.Color)7 Point (org.eclipse.swt.graphics.Point)5 IAxis (org.eclipse.swtchart.IAxis)5 IBarSeries (org.eclipse.swtchart.IBarSeries)5 ISeries (org.eclipse.swtchart.ISeries)5 MouseEvent (org.eclipse.swt.events.MouseEvent)3 MouseMoveListener (org.eclipse.swt.events.MouseMoveListener)2 ISeriesSet (org.eclipse.swtchart.ISeriesSet)2 InteractiveChart (org.eclipse.swtchart.extensions.charts.InteractiveChart)2 BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)2 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)2 SeriesException (org.eclipse.swtchart.extensions.exceptions.SeriesException)2 Test (org.junit.Test)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)1 IAction (org.eclipse.jface.action.IAction)1 PropertyChangeEvent (org.eclipse.jface.util.PropertyChangeEvent)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1