Check that there is at least one point in a chart to avoid AOOB
Change-Id: Id56153b4548a5ef713b1b0caf89976f3b0e348d6
Signed-off-by: France Lapointe Nguyen <francelap@gmail.com>
Reviewed-on: https://git.eclipse.org/r/49924
Reviewed-by: Hudson CI
Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
@Override
public void run() {
if (!getSwtChart().isDisposed()) {
@Override
public void run() {
if (!getSwtChart().isDisposed()) {
+ double[] xValues = fXValues;
+ if (xValues.length < 1) {
+ return;
+ }
double maxy = DEFAULT_MAXY;
double miny = DEFAULT_MINY;
for (Entry<String, double[]> entry : fSeriesValues.entrySet()) {
double maxy = DEFAULT_MAXY;
double miny = DEFAULT_MINY;
for (Entry<String, double[]> entry : fSeriesValues.entrySet()) {
if (series == null) {
series = addSeries(entry.getKey());
}
if (series == null) {
series = addSeries(entry.getKey());
}
- series.setXSeries(fXValues);
+ series.setXSeries(xValues);
/* Find the minimal and maximum values in this series */
for (double value : entry.getValue()) {
maxy = Math.max(maxy, value);
/* Find the minimal and maximum values in this series */
for (double value : entry.getValue()) {
maxy = Math.max(maxy, value);
IAxisTick xTick = getSwtChart().getAxisSet().getXAxis(0).getTick();
xTick.setFormat(tmfChartTimeStampFormat);
IAxisTick xTick = getSwtChart().getAxisSet().getXAxis(0).getTick();
xTick.setFormat(tmfChartTimeStampFormat);
- final double start = fXValues[0];
- int lastX = fXValues.length - 1;
- double end = (start == fXValues[lastX]) ? start + 1 : fXValues[lastX];
+ final double start = xValues[0];
+ int lastX = xValues.length - 1;
+ double end = (start == xValues[lastX]) ? start + 1 : xValues[lastX];
getSwtChart().getAxisSet().getXAxis(0).setRange(new Range(start, end));
getSwtChart().getAxisSet().getXAxis(0).adjustRange();
if (maxy > miny) {
getSwtChart().getAxisSet().getXAxis(0).setRange(new Range(start, end));
getSwtChart().getAxisSet().getXAxis(0).adjustRange();
if (maxy > miny) {