use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class OrientationExample 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 the chart orientation
chart.setOrientation(SWT.VERTICAL);
// set titles
chart.getTitle().setText("Orientation");
chart.getAxisSet().getXAxis(0).getTitle().setText("Data Points");
chart.getAxisSet().getYAxis(0).getTitle().setText("Amplitude");
// create bar series
IBarSeries barSeries = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series");
barSeries.setYSeries(ySeries);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class ScatterChartExample 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("Scatter Chart");
chart.getAxisSet().getXAxis(0).getTitle().setText("Score A");
chart.getAxisSet().getYAxis(0).getTitle().setText("Score B");
// create scatter series
ILineSeries scatterSeries = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "scatter series");
scatterSeries.setLineStyle(LineStyle.NONE);
scatterSeries.setXSeries(xSeries);
scatterSeries.setYSeries(ySeries);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class AxisTickBoundsExample 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("Axis Tick Bounds");
// create bar series
IBarSeries series1 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "series");
series1.setYSeries(ySeries);
// adjust the axis range
chart.getAxisSet().adjustRange();
// add mouse move listener to chart
chart.addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
for (IAxis axis : chart.getAxisSet().getAxes()) {
Rectangle r = axis.getTick().getBounds();
// check if mouse cursor is on axis tick
if (r.x < e.x && e.x < r.x + r.width && r.y < e.y && e.y < r.y + r.height) {
// get pixel coordinate on axis tick
int pixelCoord;
if (axis.getDirection() == Direction.X) {
pixelCoord = e.x - r.x;
} else {
pixelCoord = e.y - r.y;
}
// get data coordinate
double dataCoord = axis.getDataCoordinate(pixelCoord);
// show tool-tip
chart.setToolTipText(String.valueOf(dataCoord));
return;
}
}
chart.setToolTipText(null);
}
});
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class CategoryExample 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("Category Axis");
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);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.Chart in project swtchart by eclipse.
the class ErrorBarsExample 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);
chart.getTitle().setText("Error Bars");
// create series
ISeries series = chart.getSeriesSet().createSeries(SeriesType.LINE, "line series");
series.setYSeries(ySeries);
// set error bars
IErrorBar errorBar = series.getYErrorBar();
errorBar.setVisible(true);
errorBar.setError(0.1);
// adjust the axis range
chart.getAxisSet().adjustRange();
return chart;
}
Aggregations