Search in sources :

Example 1 with SeriesException

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.");
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) SeriesType(org.eclipse.swtchart.ISeries.SeriesType) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException) ISeries(org.eclipse.swtchart.ISeries)

Example 2 with SeriesException

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();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 3 with SeriesException

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();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) ILineSeries(org.eclipse.swtchart.ILineSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Example 4 with SeriesException

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();
    }
}
Also used : BaseChart(org.eclipse.swtchart.extensions.core.BaseChart) ISeriesData(org.eclipse.swtchart.extensions.core.ISeriesData) IBarSeries(org.eclipse.swtchart.IBarSeries) SeriesException(org.eclipse.swtchart.extensions.exceptions.SeriesException)

Aggregations

SeriesException (org.eclipse.swtchart.extensions.exceptions.SeriesException)4 BaseChart (org.eclipse.swtchart.extensions.core.BaseChart)3 ISeriesData (org.eclipse.swtchart.extensions.core.ISeriesData)3 ILineSeries (org.eclipse.swtchart.ILineSeries)2 IBarSeries (org.eclipse.swtchart.IBarSeries)1 ISeries (org.eclipse.swtchart.ISeries)1 SeriesType (org.eclipse.swtchart.ISeries.SeriesType)1 ISeriesSet (org.eclipse.swtchart.ISeriesSet)1