Search in sources :

Example 26 with IAxis

use of org.eclipse.swtchart.IAxis in project org.eclipse.linuxtools by eclipse-linuxtools.

the class AbstractChartWithAxisBuilder method applyRangeY.

/**
 * Updates the visible range of the chart's y-axis.
 * @param min The smallest y-value that should be in range.
 * @param max The largest y-value that should be in range.
 * @since 3.0
 */
protected void applyRangeY(double min, double max) {
    IAxis axis = chart.getAxisSet().getYAxis(0);
    double actualRange = max - min;
    double scaledRange = actualRange * scaleY;
    double marginL = scaledRange > 0 ? scaledRange * getChartMarginYL() : 1;
    double marginU = scaledRange > 0 ? scaledRange * getChartMarginYU() : 1;
    double lower = (actualRange - scaledRange) * scrollY + min;
    axis.setRange(new Range(lower - marginL, lower + scaledRange + marginU));
}
Also used : Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Example 27 with IAxis

use of org.eclipse.swtchart.IAxis in project org.eclipse.linuxtools by eclipse-linuxtools.

the class AbstractChartWithAxisBuilder method applyRangeX.

/**
 * Updates the visible range of the chart's x-axis.
 * @param min The smallest x-value that should be in range.
 * @param max The largest x-value that should be in range.
 */
private void applyRangeX(double min, double max) {
    IAxis axis = chart.getAxisSet().getXAxis(0);
    double actualRange = max - min;
    double scaledRange = actualRange * scale;
    double marginL = scaledRange > 0 ? scaledRange * getChartMarginXL() : 1;
    double marginU = scaledRange > 0 ? scaledRange * getChartMarginXU() : 1;
    double lower = (actualRange - scaledRange) * scroll + min;
    axis.setRange(new Range(lower - marginL, lower + scaledRange + marginU));
}
Also used : Range(org.eclipse.swtchart.Range) IAxis(org.eclipse.swtchart.IAxis)

Example 28 with IAxis

use of org.eclipse.swtchart.IAxis in project org.eclipse.linuxtools by eclipse-linuxtools.

the class AbstractChartWithAxisBuilder method buildYAxis.

/**
 * Builds Y axis.
 */
@Override
protected void buildYAxis() {
    IAxis yAxis = this.chart.getAxisSet().getYAxis(0);
    // $NON-NLS-1$
    yAxis.getTitle().setText("");
    if (yLineGrid) {
        yAxis.getGrid().setStyle(LineStyle.SOLID);
    } else {
        yAxis.getGrid().setStyle(LineStyle.NONE);
    }
    yAxis.getTick().setForeground(BLACK);
    yAxis.getTick().setTickMarkStepHint(ySeriesTicks);
}
Also used : IAxis(org.eclipse.swtchart.IAxis)

Example 29 with IAxis

use of org.eclipse.swtchart.IAxis in project org.eclipse.linuxtools by eclipse-linuxtools.

the class BarChartMouseMoveListener method mouseMove.

@Override
public void mouseMove(MouseEvent e) {
    super.mouseMove(e);
    ISeries[] allSeries = chart.getSeriesSet().getSeries();
    if (allSeries.length == 0) {
        return;
    }
    IAxis xAxis = chart.getAxisSet().getXAxis(0);
    String[] categorySeries = ((BarChart) chart).getCategorySeries();
    int barIndex = (int) xAxis.getDataCoordinate(e.x);
    if (0 <= barIndex && barIndex < categorySeries.length) {
        // $NON-NLS-1$
        String textTip = "";
        for (int i = 0; i < allSeries.length; i++) {
            textTip = textTip.concat((i > 0 ? "\n" : "") + // $NON-NLS-1$ //$NON-NLS-2$
            MessageFormat.format(// $NON-NLS-1$ //$NON-NLS-2$
            Messages.BarChartBuilder_ToolTipCoords, allSeries[i].getId(), ((BarChart) chart).getBarValue(i, barIndex)));
        }
        setTextTip(textTip);
    } else {
        tipShell.setVisible(false);
    }
    chart.redraw();
}
Also used : BarChart(org.eclipse.linuxtools.internal.systemtap.graphing.ui.charts.BarChart) ISeries(org.eclipse.swtchart.ISeries) IAxis(org.eclipse.swtchart.IAxis)

Example 30 with IAxis

use of org.eclipse.swtchart.IAxis in project tracecompass by tracecompass.

the class TmfXYChartViewer method clearContent.

// ------------------------------------------------------------------------
// Helper Methods
// ------------------------------------------------------------------------
/**
 * Clears the view content.
 */
protected void clearContent() {
    if (!fSwtChart.isDisposed()) {
        ISeriesSet set = fSwtChart.getSeriesSet();
        ISeries<?>[] series = set.getSeries();
        for (int i = 0; i < series.length; i++) {
            set.deleteSeries(series[i].getId());
        }
        for (IAxis axis : fSwtChart.getAxisSet().getAxes()) {
            axis.setRange(new Range(0, 1));
        }
        fSwtChart.redraw();
    }
}
Also used : ISeriesSet(org.eclipse.swtchart.ISeriesSet) Range(org.eclipse.swtchart.Range) ISeries(org.eclipse.swtchart.ISeries) Point(org.eclipse.swt.graphics.Point) IAxis(org.eclipse.swtchart.IAxis)

Aggregations

IAxis (org.eclipse.swtchart.IAxis)64 Point (org.eclipse.swt.graphics.Point)27 Range (org.eclipse.swtchart.Range)19 IAxisSet (org.eclipse.swtchart.IAxisSet)10 Chart (org.eclipse.swtchart.Chart)7 ISeries (org.eclipse.swtchart.ISeries)7 MouseEvent (org.eclipse.swt.events.MouseEvent)5 ILineSeries (org.eclipse.swtchart.ILineSeries)5 Color (org.eclipse.swt.graphics.Color)4 GridData (org.eclipse.swt.layout.GridData)4 DecimalFormat (java.text.DecimalFormat)3 PaintEvent (org.eclipse.swt.events.PaintEvent)3 PaintListener (org.eclipse.swt.events.PaintListener)3 GC (org.eclipse.swt.graphics.GC)3 Rectangle (org.eclipse.swt.graphics.Rectangle)3 Composite (org.eclipse.swt.widgets.Composite)3 IBarSeries (org.eclipse.swtchart.IBarSeries)3 ITitle (org.eclipse.swtchart.ITitle)3 Axis (org.eclipse.swtchart.internal.axis.Axis)3 StyleRange (org.eclipse.swt.custom.StyleRange)2