Search in sources :

Example 1 with IAxisTick

use of org.swtchart.IAxisTick in project netxms by netxms.

the class LineChart method setTimeRange.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.charts.api.HistoricalDataChart#setTimeRange(java.util.Date, java.util.Date)
	 */
@Override
public void setTimeRange(final Date from, final Date to) {
    timeFrom = from.getTime();
    timeTo = to.getTime();
    getAxisSet().getXAxis(0).setRange(new Range(timeFrom, timeTo));
    int seconds = (int) ((timeTo - timeFrom) / 1000);
    String formatString;
    int angle;
    if (seconds <= 600) {
        formatString = Messages.get().LineChart_MediumTimeFormat;
        angle = 0;
    } else if (seconds <= 86400) {
        formatString = Messages.get().LineChart_ShortTimeFormat;
        angle = 0;
    } else if (seconds <= 86400 * 7) {
        formatString = Messages.get().LineChart_Medium2TimeFormat;
        angle = 0;
    } else {
        formatString = Messages.get().LineChart_LongTimeFormat;
        angle = 45;
    }
    IAxisTick xTick = getAxisSet().getXAxis(0).getTick();
    DateFormat format = new SimpleDateFormat(formatString);
    xTick.setFormat(format);
    xTick.setTickLabelAngle(angle);
}
Also used : IAxisTick(org.swtchart.IAxisTick) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) Range(org.swtchart.Range) SimpleDateFormat(java.text.SimpleDateFormat) Point(org.eclipse.swt.graphics.Point) DataPoint(org.netxms.ui.eclipse.charts.api.DataPoint)

Example 2 with IAxisTick

use of org.swtchart.IAxisTick in project ACS by ACS-Community.

the class AlarmsPerTenMinutesPart method createPartControl.

public void createPartControl(Composite parent) {
    chart = new Chart(parent, SWT.NONE);
    ITitle chartTitle = chart.getTitle();
    chartTitle.setText("Alarms per 10 minutes");
    IAxisSet axisSet = chart.getAxisSet();
    IAxis[] xAxis = axisSet.getXAxes();
    ITitle xTitle = xAxis[0].getTitle();
    xTitle.setText("Time");
    IAxis[] yAxis = axisSet.getYAxes();
    ITitle yTitle = yAxis[0].getTitle();
    yTitle.setText("# alarms");
    ISeriesSet seriesSet = chart.getSeriesSet();
    nAlarmsSerie = (ILineSeries) seriesSet.createSeries(SeriesType.LINE, "nAlarms");
    nAlarmsSerie.enableStep(true);
    nAlarmsSerie.setSymbolType(PlotSymbolType.NONE);
    IAxisTick xTick = axisSet.getXAxis(0).getTick();
    DateFormat format = new SimpleDateFormat("HH:mm");
    xTick.setFormat(format);
    errorSerie = (ILineSeries) seriesSet.createSeries(SeriesType.LINE, "Threshold");
    errorSerie.setSymbolType(PlotSymbolType.NONE);
    errorColor = new Color(Display.getDefault(), 255, 0, 0);
    errorSerie.setLineColor(errorColor);
    TenMinutesContainer.getInstance().setChartViewer(this);
}
Also used : ISeriesSet(org.swtchart.ISeriesSet) IAxisTick(org.swtchart.IAxisTick) IAxisSet(org.swtchart.IAxisSet) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Color(org.eclipse.swt.graphics.Color) ITitle(org.swtchart.ITitle) SimpleDateFormat(java.text.SimpleDateFormat) Chart(org.swtchart.Chart) IAxis(org.swtchart.IAxis)

Aggregations

DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 IAxisTick (org.swtchart.IAxisTick)2 Color (org.eclipse.swt.graphics.Color)1 Point (org.eclipse.swt.graphics.Point)1 DataPoint (org.netxms.ui.eclipse.charts.api.DataPoint)1 Chart (org.swtchart.Chart)1 IAxis (org.swtchart.IAxis)1 IAxisSet (org.swtchart.IAxisSet)1 ISeriesSet (org.swtchart.ISeriesSet)1 ITitle (org.swtchart.ITitle)1 Range (org.swtchart.Range)1