use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class BaseChart method setSelectionXY.
private void setSelectionXY(int xStart, int xStop, int yStart, int yStop) {
IAxis xAxis = getAxisSet().getXAxis(ID_PRIMARY_X_AXIS);
IAxis yAxis = getAxisSet().getYAxis(ID_PRIMARY_Y_AXIS);
//
if ((getOrientation() == SWT.HORIZONTAL)) {
setHorizontalRange(xAxis, yAxis, xStart, xStop, yStart, yStop);
} else {
setVerticalRange(xAxis, yAxis, xStart, xStop, yStart, yStop);
}
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class RangeSelector method adjustRanges.
public void adjustRanges(boolean redraw) {
BaseChart baseChart = scrollableChart.getBaseChart();
//
int indexX = (comboScaleX.getSelectionIndex() >= 0) ? comboScaleX.getSelectionIndex() : BaseChart.ID_PRIMARY_X_AXIS;
int indexY = (comboScaleY.getSelectionIndex() >= 0) ? comboScaleY.getSelectionIndex() : BaseChart.ID_PRIMARY_Y_AXIS;
IAxis xAxis = baseChart.getAxisSet().getXAxis(indexX);
IAxis yAxis = baseChart.getAxisSet().getYAxis(indexY);
Range rangeX = xAxis.getRange();
Range rangeY = yAxis.getRange();
//
DecimalFormat decimalFormatX = baseChart.getDecimalFormat(IExtendedChart.X_AXIS, indexX);
DecimalFormat decimalFormatY = baseChart.getDecimalFormat(IExtendedChart.Y_AXIS, indexY);
//
if (rangeX != null && rangeY != null) {
/*
* Update the text boxes.
*/
textStartX.setText(decimalFormatX.format(rangeX.lower));
textStopX.setText(decimalFormatX.format(rangeX.upper));
textStartY.setText(decimalFormatY.format(rangeY.lower));
textStopY.setText(decimalFormatY.format(rangeY.upper));
/*
* Redraw the base chart.
*/
if (redraw) {
baseChart.redraw();
}
}
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class ZoomEvent method handleEvent.
@Override
public void handleEvent(BaseChart baseChart, Event event) {
IAxisSet axisSet = baseChart.getAxisSet();
IAxis xAxis = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
IAxis yAxis = axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
//
RangeRestriction rangeRestriction = baseChart.getRangeRestriction();
if (baseChart.isZoomXAndY(rangeRestriction)) {
/*
* X and Y zoom.
*/
baseChart.zoomX(xAxis, event);
baseChart.zoomY(yAxis, event);
} else {
/*
* X or Y zoom.
*/
if (rangeRestriction.isXZoomOnly()) {
baseChart.zoomX(xAxis, event);
} else if (rangeRestriction.isYZoomOnly()) {
baseChart.zoomY(yAxis, event);
}
}
/*
* Adjust the range if it shall not exceed the initial
* min and max values.
*/
if (rangeRestriction.isRestrictZoom()) {
/*
* Adjust the primary axes.
* The secondary axes are adjusted by setting the range.
*/
Range rangeX = xAxis.getRange();
Range rangeY = yAxis.getRange();
baseChart.setRange(xAxis, rangeX.lower, rangeX.upper, true);
baseChart.setRange(yAxis, rangeY.lower, rangeY.upper, true);
} else {
/*
* Update the secondary axes.
*/
baseChart.adjustSecondaryXAxes();
baseChart.adjustSecondaryYAxes();
}
//
baseChart.fireUpdateCustomRangeSelectionHandlers(event);
baseChart.redraw();
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class Series method setXAxisId.
/*
* @see ISeries#setXAxisId(int)
*/
public void setXAxisId(int id) {
if (xAxisId == id) {
return;
}
IAxis axis = chart.getAxisSet().getXAxis(xAxisId);
if (minX <= 0 && axis != null && axis.isLogScaleEnabled()) {
chart.getAxisSet().getXAxis(xAxisId).enableLogScale(false);
}
xAxisId = id;
((SeriesSet) chart.getSeriesSet()).updateStackAndRiserData();
}
use of org.eclipse.swtchart.IAxis in project swtchart by eclipse.
the class Series method setXSeries.
/*
* @see ISeries#setXSeries(double[])
*/
public void setXSeries(double[] series) {
if (series == null) {
SWT.error(SWT.ERROR_NULL_ARGUMENT);
// to suppress warning...
return;
}
xSeries = new double[series.length];
System.arraycopy(series, 0, xSeries, 0, series.length);
isDateSeries = false;
if (xSeries.length == 0) {
return;
}
// find the min and max value of x series
minX = xSeries[0];
maxX = xSeries[0];
for (int i = 1; i < xSeries.length; i++) {
if (minX > xSeries[i]) {
minX = xSeries[i];
}
if (maxX < xSeries[i]) {
maxX = xSeries[i];
}
if (xSeries[i - 1] > xSeries[i]) {
isXMonotoneIncreasing = false;
}
}
setCompressor();
compressor.setXSeries(xSeries);
compressor.setYSeries(ySeries);
if (minX <= 0) {
IAxis axis = chart.getAxisSet().getXAxis(xAxisId);
if (axis != null) {
axis.enableLogScale(false);
}
}
}
Aggregations