use of org.eclipse.swtchart.extensions.core.ISeriesData 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.core.ISeriesData 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.core.ISeriesData in project swtchart by eclipse.
the class SeriesConverter method getSeriesXY.
public static ISeriesData getSeriesXY(String fileName, String id) {
int size = getNumberOfLines(fileName);
double[] xSeries = new double[size];
double[] ySeries = new double[size];
//
BufferedReader bufferedReader = null;
try {
String line;
int i = 0;
bufferedReader = new BufferedReader(new InputStreamReader(SeriesConverter.class.getResourceAsStream(fileName)));
while ((line = bufferedReader.readLine()) != null) {
if (!line.startsWith("#")) {
String[] values = line.split("\t");
xSeries[i] = Double.parseDouble(values[0].trim());
ySeries[i] = Double.parseDouble(values[1].trim());
i++;
}
}
} catch (Exception e) {
//
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
//
}
}
}
//
ISeriesData seriesData = new SeriesData(xSeries, ySeries, id);
return seriesData;
}
use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.
the class SeriesConverter method getSeriesFromY.
public static ISeriesData getSeriesFromY(String fileName) {
int size = getNumberOfLines(fileName);
double[] ySeries = new double[size];
//
BufferedReader bufferedReader = null;
try {
String line;
int i = 0;
bufferedReader = new BufferedReader(new InputStreamReader(SeriesConverter.class.getResourceAsStream(fileName)));
while ((line = bufferedReader.readLine()) != null) {
ySeries[i++] = Double.parseDouble(line.trim());
}
} catch (Exception e) {
//
} finally {
if (bufferedReader != null) {
try {
bufferedReader.close();
} catch (IOException e) {
//
}
}
}
//
ISeriesData seriesData = new SeriesData(ySeries, fileName);
return seriesData;
}
use of org.eclipse.swtchart.extensions.core.ISeriesData in project swtchart by eclipse.
the class CustomLineChart1 method addDemoSeries.
private void addDemoSeries() {
List<ILineSeriesData> lineSeriesDataList = new ArrayList<ILineSeriesData>();
ISeriesData seriesData = SeriesConverter.getSeriesXY(seriesXY);
//
ILineSeriesData lineSeriesData = new LineSeriesData(seriesData);
ILineSeriesSettings lineSeriesSettings = lineSeriesData.getLineSeriesSettings();
lineSeriesSettings.setEnableArea(true);
ILineSeriesSettings lineSeriesSettingsHighlight = (ILineSeriesSettings) lineSeriesSettings.getSeriesSettingsHighlight();
lineSeriesSettingsHighlight.setLineWidth(2);
lineSeriesDataList.add(lineSeriesData);
/*
* Set series.
*/
addSeriesData(lineSeriesDataList, LENGTH_HINT_DATA_POINTS);
}
Aggregations