Search in sources :

Example 11 with Axis

use of org.eclipse.swtchart.internal.axis.Axis in project swtchart by eclipse.

the class SeriesSet method updateStackAndRiserData.

/**
 * Updates the stack and riser data for given axes.
 *
 * @param xAxis
 *            the X axis
 * @param yAxis
 *            the Y axis
 */
private void updateStackAndRiserData(IAxis xAxis, IAxis yAxis) {
    int riserCnt = 0;
    int stackRiserPosition = -1;
    double[] stackBarSeries = null;
    double[] stackLineSeries = null;
    if (((Axis) xAxis).isValidCategoryAxis()) {
        String[] categorySeries = xAxis.getCategorySeries();
        if (categorySeries != null) {
            int size = categorySeries.length;
            stackBarSeries = new double[size];
            stackLineSeries = new double[size];
        }
    }
    for (ISeries series : getSeries()) {
        if (series.getXAxisId() != xAxis.getId() || series.getYAxisId() != yAxis.getId() || !series.isVisible()) {
            continue;
        }
        if (series.isStackEnabled() && !chart.getAxisSet().getYAxis(series.getYAxisId()).isLogScaleEnabled() && ((Axis) xAxis).isValidCategoryAxis()) {
            if (series.getType() == SeriesType.BAR) {
                if (stackRiserPosition == -1) {
                    stackRiserPosition = riserCnt;
                    riserCnt++;
                }
                ((BarSeries) series).setRiserIndex(((Axis) xAxis).getNumRisers() + stackRiserPosition);
                setStackSeries(stackBarSeries, series);
            } else if (series.getType() == SeriesType.LINE) {
                setStackSeries(stackLineSeries, series);
            }
        } else {
            if (series.getType() == SeriesType.BAR) {
                ((BarSeries) series).setRiserIndex(((Axis) xAxis).getNumRisers() + riserCnt++);
            }
        }
    }
    ((Axis) xAxis).setNumRisers(((Axis) xAxis).getNumRisers() + riserCnt);
}
Also used : ISeries(org.eclipse.swtchart.ISeries) Point(org.eclipse.swt.graphics.Point) IAxis(org.eclipse.swtchart.IAxis) Axis(org.eclipse.swtchart.internal.axis.Axis)

Aggregations

Axis (org.eclipse.swtchart.internal.axis.Axis)11 IAxis (org.eclipse.swtchart.IAxis)9 Point (org.eclipse.swt.graphics.Point)6 Rectangle (org.eclipse.swt.graphics.Rectangle)2 Position (org.eclipse.swtchart.IAxis.Position)2 ISeries (org.eclipse.swtchart.ISeries)2 Range (org.eclipse.swtchart.Range)2 Control (org.eclipse.swt.widgets.Control)1 Chart (org.eclipse.swtchart.Chart)1 IAxisSet (org.eclipse.swtchart.IAxisSet)1