use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class BarBoundsExample 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("Bar Bounds");
// create bar series
IBarSeries series1 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "series 1");
series1.setYSeries(ySeries1);
IBarSeries series2 = (IBarSeries) chart.getSeriesSet().createSeries(SeriesType.BAR, "series 2");
series2.setYSeries(ySeries2);
series2.setBarColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
// adjust the axis range
chart.getAxisSet().adjustRange();
// add mouse move listener to open tooltip on data point
chart.getPlotArea().addMouseMoveListener(new MouseMoveListener() {
public void mouseMove(MouseEvent e) {
for (ISeries series : chart.getSeriesSet().getSeries()) {
Rectangle[] rs = ((IBarSeries) series).getBounds();
for (int i = 0; i < rs.length; i++) {
if (rs[i] != null) {
if (rs[i].x < e.x && e.x < rs[i].x + rs[i].width && rs[i].y < e.y && e.y < rs[i].y + rs[i].height) {
setToolTipText(series, i);
return;
}
}
}
}
chart.getPlotArea().setToolTipText(null);
}
private void setToolTipText(ISeries series, int index) {
chart.getPlotArea().setToolTipText("Series: " + series.getId() + "\nValue: " + series.getYSeries()[index]);
}
});
return chart;
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class AngledAxisTickLabelsExample 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("Angled Axis Tick Labels");
// set category
chart.getAxisSet().getXAxis(0).enableCategory(true);
chart.getAxisSet().getXAxis(0).setCategorySeries(cagetorySeries);
chart.getAxisSet().getXAxis(0).getTick().setTickLabelAngle(45);
// add bar series
ISeries barSeries = chart.getSeriesSet().createSeries(SeriesType.BAR, "bar series");
barSeries.setYSeries(ySeries);
chart.getAxisSet().adjustRange();
return chart;
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class ScrollableChart method deleteSeries.
@Override
public void deleteSeries() {
baseChart.suspendUpdate(true);
for (ISeries series : baseChart.getSeriesSet().getSeries()) {
baseChart.deleteSeries(series.getId());
}
baseChart.suspendUpdate(false);
redraw();
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class MassSpectrumChart method getBarSeriesIonList.
private List<BarSeriesIon> getBarSeriesIonList() {
List<BarSeriesIon> barSeriesIons = new ArrayList<BarSeriesIon>();
//
int widthPlotArea = getBaseChart().getPlotArea().getBounds().width;
ISeries[] series = getBaseChart().getSeriesSet().getSeries();
for (ISeries barSeries : series) {
if (barSeries != null) {
//
double[] xSeries = barSeries.getXSeries();
double[] ySeries = barSeries.getYSeries();
int size = barSeries.getXSeries().length;
//
for (int i = 0; i < size; i++) {
Point point = barSeries.getPixelCoordinates(i);
if (point.x >= 0 && point.x <= widthPlotArea) {
barSeriesIons.add(new BarSeriesIon(xSeries[i], ySeries[i], point));
}
}
}
}
return barSeriesIons;
}
use of org.eclipse.swtchart.ISeries in project swtchart by eclipse.
the class AbstractExtendedChart method deleteSeries.
@Override
public void deleteSeries(String id) {
ISeriesSet seriesSet = getSeriesSet();
if (seriesSet.getSeries(id) != null) {
resetCoordinates();
seriesSet.deleteSeries(id);
seriesSettingsMap.remove(id);
for (ISeries series : seriesSet.getSeries()) {
calculateCoordinates(series);
}
}
}
Aggregations