use of org.eclipse.swtchart.extensions.exceptions.SeriesException in project swtchart by eclipse.
the class AbstractExtendedChart method createSeries.
@Override
public ISeries createSeries(ISeriesData seriesData, ISeriesSettings seriesSettings) throws SeriesException {
SeriesType seriesType = getSeriesType(seriesSettings);
double[] xSeries = seriesData.getXSeries();
double[] ySeries = seriesData.getYSeries();
//
if (xSeries.length == ySeries.length) {
/*
* Put the settings to the map.
*/
String id = seriesData.getId();
seriesSettingsMap.put(id, seriesSettings);
//
ISeriesSet seriesSet = getSeriesSet();
ISeries series = seriesSet.createSeries(seriesType, id);
series.setXSeries(xSeries);
series.setYSeries(ySeries);
calculateCoordinates(series);
return series;
} else {
throw new SeriesException("The length of x and y series differs.");
}
}
use of org.eclipse.swtchart.extensions.exceptions.SeriesException in project swtchart by eclipse.
the class LineChart method addSeriesData.
/**
* The data is compressed to the given length.
* If you're unsure which length to set, then use one of the following variables:
*
* HIGH_COMPRESSION
* MEDIUM_COMPRESSION
* LOW_COMPRESSION
* NO_COMPRESSION
*
* @param lineSeriesDataList
* @param compressToLength
*/
public void addSeriesData(List<ILineSeriesData> lineSeriesDataList, int compressToLength) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (lineSeriesDataList != null && lineSeriesDataList.size() > 0) {
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (ILineSeriesData lineSeriesData : lineSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = lineSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
// Initialize
lineSeriesSettings.getSeriesSettingsHighlight();
ILineSeries lineSeries = (ILineSeries) createSeries(optimizedSeriesData, lineSeriesSettings);
baseChart.applyLineSeriesSettings(lineSeries, lineSeriesSettings);
} catch (SeriesException e) {
//
}
}
baseChart.suspendUpdate(false);
adjustRange(true);
baseChart.redraw();
}
}
use of org.eclipse.swtchart.extensions.exceptions.SeriesException in project swtchart by eclipse.
the class ScatterChart method addSeriesData.
public void addSeriesData(List<IScatterSeriesData> scatterSeriesDataList) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (scatterSeriesDataList != null && scatterSeriesDataList.size() > 0) {
/*
* Set the data.
*/
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (IScatterSeriesData scatterSeriesData : scatterSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = scatterSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, ScrollableChart.NO_COMPRESS_TO_LENGTH);
IScatterSeriesSettings scatterSeriesSettings = scatterSeriesData.getScatterSeriesSettings();
// Initialize
scatterSeriesSettings.getSeriesSettingsHighlight();
ILineSeries scatterSeries = (ILineSeries) createSeries(optimizedSeriesData, scatterSeriesSettings);
baseChart.applyScatterSeriesSettings(scatterSeries, scatterSeriesSettings);
} catch (SeriesException e) {
//
}
}
baseChart.suspendUpdate(false);
adjustRange(true);
baseChart.redraw();
}
}
use of org.eclipse.swtchart.extensions.exceptions.SeriesException in project swtchart by eclipse.
the class BarChart method addSeriesData.
/**
* BarWidthStyle.STRETCHED will be used automatically instead of BarWidthStyle.FIXED
* if the series data is too large. This leads to a better performance.
*
* @param barSeriesDataList
*/
public void addSeriesData(List<IBarSeriesData> barSeriesDataList, int compressToLength) {
/*
* Suspend the update when adding new data to improve the performance.
*/
if (barSeriesDataList != null && barSeriesDataList.size() > 0) {
BaseChart baseChart = getBaseChart();
baseChart.suspendUpdate(true);
for (IBarSeriesData barSeriesData : barSeriesDataList) {
/*
* Get the series data and apply the settings.
*/
try {
ISeriesData seriesData = barSeriesData.getSeriesData();
ISeriesData optimizedSeriesData = calculateSeries(seriesData, compressToLength);
IBarSeriesSettings barSeriesSettings = barSeriesData.getBarSeriesSettings();
// Initialize
barSeriesSettings.getSeriesSettingsHighlight();
IBarSeries barSeries = (IBarSeries) createSeries(optimizedSeriesData, barSeriesSettings);
baseChart.applyBarSeriesSettings(barSeries, barSeriesSettings);
/*
* Automatically use stretched if it is a large data set.
*/
if (isLargeDataSet(optimizedSeriesData.getXSeries(), optimizedSeriesData.getYSeries(), LENGTH_HINT_DATA_POINTS)) {
barSeries.setBarWidthStyle(BarWidthStyle.STRETCHED);
} else {
barSeries.setBarWidthStyle(barSeriesSettings.getBarWidthStyle());
}
} catch (SeriesException e) {
//
}
}
baseChart.suspendUpdate(false);
adjustRange(true);
baseChart.redraw();
}
}
Aggregations