use of org.eclipse.swtchart.IAxisSet in project swtchart by eclipse.
the class ScrollableChart method addPrimaryAxisY.
private void addPrimaryAxisY(IChartSettings chartSettings) {
IAxisSet axisSet = baseChart.getAxisSet();
IAxis yAxisPrimary = axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
IPrimaryAxisSettings primaryAxisSettings = chartSettings.getPrimaryAxisSettingsY();
setAxisSettings(yAxisPrimary, primaryAxisSettings);
baseChart.putYAxisSettings(BaseChart.ID_PRIMARY_Y_AXIS, primaryAxisSettings);
}
use of org.eclipse.swtchart.IAxisSet in project swtchart by eclipse.
the class ScrollableChart method addSecondaryAxesY.
private void addSecondaryAxesY(IChartSettings chartSettings) {
IAxisSet axisSet = baseChart.getAxisSet();
for (int id : axisSet.getYAxisIds()) {
if (id != BaseChart.ID_PRIMARY_Y_AXIS) {
axisSet.deleteYAxis(id);
}
}
/*
* Remove all items except the primary axis settings.
*/
baseChart.removeYAxisSettings();
/*
* Add the axis settings.
*/
for (ISecondaryAxisSettings secondaryAxisSettings : chartSettings.getSecondaryAxisSettingsListY()) {
int yAxisId = axisSet.createYAxis();
IAxis yAxisSecondary = axisSet.getYAxis(yAxisId);
setAxisSettings(yAxisSecondary, secondaryAxisSettings);
baseChart.putYAxisSettings(yAxisId, secondaryAxisSettings);
}
}
use of org.eclipse.swtchart.IAxisSet in project swtchart by eclipse.
the class AbstractExtendedChart method setRange.
@Override
public void setRange(String axis, double start, double stop) {
IAxisSet axisSet = getAxisSet();
IAxis selectedAxis = (axis.equals(IExtendedChart.X_AXIS)) ? axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS) : axisSet.getYAxis(BaseChart.ID_PRIMARY_Y_AXIS);
setRange(selectedAxis, start, stop, true);
}
use of org.eclipse.swtchart.IAxisSet in project swtchart by eclipse.
the class AbstractExtendedChart method adjustSecondaryXAxes.
@Override
public void adjustSecondaryXAxes() {
IAxisSet axisSet = getAxisSet();
IAxis xAxis = axisSet.getXAxis(BaseChart.ID_PRIMARY_X_AXIS);
Range range = xAxis.getRange();
for (int id : axisSet.getXAxisIds()) {
if (id != BaseChart.ID_PRIMARY_X_AXIS) {
IAxis axis = axisSet.getXAxis(id);
IAxisSettings axisSettings = xAxisSettingsMap.get(id);
if (axis != null && axisSettings instanceof ISecondaryAxisSettings) {
IAxisScaleConverter axisScaleConverter = ((ISecondaryAxisSettings) axisSettings).getAxisScaleConverter();
axisScaleConverter.setChartDataCoordinates(this);
double start = axisScaleConverter.convertToSecondaryUnit(range.lower);
double end = axisScaleConverter.convertToSecondaryUnit(range.upper);
if (end > start) {
Range adjustedRange = new Range(start, end);
axis.setRange(adjustedRange);
} else {
System.out.println("Can't set secondary x axes range: " + start + "\t" + end);
}
}
}
}
}
use of org.eclipse.swtchart.IAxisSet 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();
}
Aggregations