Search in sources :

Example 51 with Range

use of org.eclipse.swtchart.Range in project swtchart by eclipse.

the class Series method getYRange.

/**
 * Gets the Y range of series.
 *
 * @return the Y range of series
 */
public Range getYRange() {
    double min = minY;
    double max = maxY;
    Axis xAxis = (Axis) chart.getAxisSet().getXAxis(xAxisId);
    if (isValidStackSeries() && xAxis.isValidCategoryAxis()) {
        for (int i = 0; i < stackSeries.length; i++) {
            if (max < stackSeries[i]) {
                max = stackSeries[i];
            }
        }
    }
    return new Range(min, max);
}
Also used : Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis) Axis(org.eclipse.swtchart.internal.axis.Axis) Point(org.eclipse.swt.graphics.Point)

Example 52 with Range

use of org.eclipse.swtchart.Range in project swtchart by eclipse.

the class BarSeries method getAdjustedRange.

/*
	 * @see Series#getAdjustedRange(Axis, int)
	 */
@Override
public Range getAdjustedRange(Axis axis, int length) {
    // calculate a range which has margin
    Range range;
    int lowerPlotMargin;
    int upperPlotMargin;
    if (axis.getDirection() == Direction.X) {
        double lowerRiserWidth = getRiserWidth(xSeries, 0, axis, minX, maxX);
        double upperRiserWidth = getRiserWidth(xSeries, xSeries.length - 1, axis, minX, maxX);
        lowerPlotMargin = (int) (lowerRiserWidth / 2d + MARGIN_AT_MIN_MAX_PLOT);
        upperPlotMargin = (int) (upperRiserWidth / 2d + MARGIN_AT_MIN_MAX_PLOT);
        range = getXRange();
    } else {
        range = getYRange();
        if (range.upper < 0) {
            range.upper = 0;
        }
        if (range.lower > 0) {
            range.lower = axis.isLogScaleEnabled() ? minY : 0;
        }
        lowerPlotMargin = (range.lower == 0) ? 0 : MARGIN_AT_MIN_MAX_PLOT;
        upperPlotMargin = (range.upper == 0) ? 0 : MARGIN_AT_MIN_MAX_PLOT;
    }
    return getRangeWithMargin(lowerPlotMargin, upperPlotMargin, length, axis, range);
}
Also used : Range(org.eclipse.swtchart.Range) Point(org.eclipse.swt.graphics.Point)

Example 53 with Range

use of org.eclipse.swtchart.Range in project olca-app by GreenDelta.

the class ContributionChart method setYRange.

private void setYRange(List<Contribution<?>> top, double rest) {
    double min = rest < 0 ? rest : 0;
    double max = rest > 0 ? rest : 0;
    for (Contribution<?> item : top) {
        min = Math.min(min, item.amount);
        max = Math.max(max, item.amount);
    }
    double[] range = yrange(min, max);
    IAxis y = chart.getAxisSet().getYAxis(0);
    y.setRange(new Range(range[0], range[1]));
    y.getTick().setTickMarkStepHint(10);
}
Also used : Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Aggregations

Range (org.eclipse.swtchart.Range)53 IAxis (org.eclipse.swtchart.IAxis)20 Point (org.eclipse.swt.graphics.Point)13 ISeries (org.eclipse.swtchart.ISeries)9 GridData (org.eclipse.swt.layout.GridData)5 IAxisSet (org.eclipse.swtchart.IAxisSet)5 DecimalFormat (java.text.DecimalFormat)4 StyleRange (org.eclipse.swt.custom.StyleRange)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 Event (org.eclipse.swt.widgets.Event)4 MouseEvent (org.eclipse.swt.events.MouseEvent)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 Chart (org.eclipse.swtchart.Chart)3 ISeriesSet (org.eclipse.swtchart.ISeriesSet)3 AxisRange (org.eclipse.tracecompass.tmf.ui.viewers.xychart.AxisRange)3 ParseException (java.text.ParseException)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 PaintListener (org.eclipse.swt.events.PaintListener)2 Color (org.eclipse.swt.graphics.Color)2