Search in sources :

Example 1 with GraphItem

use of org.netxms.client.datacollection.GraphItem in project netxms by netxms.

the class LineChart method updateParameter.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.charts.api.HistoricalDataChart#updateParameter(int, org.netxms.client.datacollection.DciData, boolean)
	 */
@Override
public void updateParameter(int index, DciData data, boolean updateChart) {
    if ((index < 0) || (index >= items.size()))
        return;
    final GraphItem item = items.get(index);
    final DciDataRow[] values = data.getValues();
    // Create series
    Date[] xSeries = new Date[values.length];
    double[] ySeries = new double[values.length];
    for (int i = 0; i < values.length; i++) {
        xSeries[i] = values[i].getTimestamp();
        ySeries[i] = values[i].getValueAsDouble();
    }
    ILineSeries series = addLineSeries(index, item.getDescription(), xSeries, ySeries, updateChart);
    applyItemStyle(index, series);
    if (updateChart) {
        if (adjustYAxis) {
            adjustYAxis(true);
        } else {
            redraw();
        }
    }
}
Also used : DciDataRow(org.netxms.client.datacollection.DciDataRow) ILineSeries(org.swtchart.ILineSeries) GraphItem(org.netxms.client.datacollection.GraphItem) Date(java.util.Date) Point(org.eclipse.swt.graphics.Point) DataPoint(org.netxms.ui.eclipse.charts.api.DataPoint)

Example 2 with GraphItem

use of org.netxms.client.datacollection.GraphItem in project netxms by netxms.

the class AvailabilityChart method createChart.

/**
 * @param parent
 * @param title
 * @return
 */
private DataComparisonChart createChart(Composite parent, String title) {
    DataComparisonChart chart = ChartFactory.createPieChart(parent, SWT.NONE);
    chart.setTitleVisible(true);
    chart.set3DModeEnabled(true);
    chart.setChartTitle(title);
    chart.setLegendVisible(false);
    chart.setLabelsVisible(false);
    chart.setRotation(225.0);
    // $NON-NLS-1$
    chart.addParameter(new GraphItem(0, 0, 0, DataType.FLOAT, Messages.get().AvailabilityChart_Up, Messages.get().AvailabilityChart_Up, "%s"), 100);
    // $NON-NLS-1$
    chart.addParameter(new GraphItem(0, 0, 0, DataType.FLOAT, Messages.get().AvailabilityChart_Down, Messages.get().AvailabilityChart_Down, "%s"), 0);
    chart.setPaletteEntry(0, new ChartColor(127, 154, 72));
    chart.setPaletteEntry(1, new ChartColor(158, 65, 62));
    chart.initializationComplete();
    GridData gd = new GridData();
    gd.widthHint = 250;
    gd.heightHint = 190;
    ((Control) chart).setLayoutData(gd);
    return chart;
}
Also used : ChartColor(org.netxms.ui.eclipse.charts.api.ChartColor) Control(org.eclipse.swt.widgets.Control) DataComparisonChart(org.netxms.ui.eclipse.charts.api.DataComparisonChart) GridData(org.eclipse.swt.layout.GridData) GraphItem(org.netxms.client.datacollection.GraphItem)

Example 3 with GraphItem

use of org.netxms.client.datacollection.GraphItem in project netxms by netxms.

the class DataComparisonView method updateChart.

/**
 * Get DCI data from server
 */
private void updateChart() {
    if (updateInProgress)
        return;
    updateInProgress = true;
    ConsoleJob job = new ConsoleJob(Messages.get().DataComparisonView_JobName, this, Activator.PLUGIN_ID, Activator.PLUGIN_ID) {

        @Override
        protected String getErrorMessage() {
            return Messages.get().DataComparisonView_JobError;
        }

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final double[] values = new double[items.size()];
            for (int i = 0; i < items.size(); i++) {
                GraphItem item = items.get(i);
                DciData data = (item.getType() == DataCollectionObject.DCO_TYPE_ITEM) ? session.getCollectedData(item.getNodeId(), item.getDciId(), null, null, 1, false) : session.getCollectedTableData(item.getNodeId(), item.getDciId(), item.getInstance(), item.getDataColumn(), null, null, 1);
                DciDataRow value = data.getLastValue();
                values[i] = (value != null) ? value.getValueAsDouble() : 0.0;
            }
            final Threshold[][] thresholds = new Threshold[items.size()][];
            if (chartType == DataComparisonChart.GAUGE_CHART) {
                for (int i = 0; i < items.size(); i++) {
                    GraphItem item = items.get(i);
                    thresholds[i] = session.getThresholds(item.getNodeId(), item.getDciId());
                }
            }
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    if (chartType == DataComparisonChart.GAUGE_CHART)
                        for (int i = 0; i < thresholds.length; i++) chart.updateParameterThresholds(i, thresholds[i]);
                    setChartData(values);
                    chart.clearErrors();
                    updateInProgress = false;
                }
            });
        }

        @Override
        protected IStatus createFailureStatus(final Exception e) {
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    // $NON-NLS-1$ //$NON-NLS-2$
                    chart.addError(getErrorMessage() + " (" + e.getLocalizedMessage() + ")");
                }
            });
            return Status.OK_STATUS;
        }
    };
    job.setUser(false);
    job.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DciDataRow(org.netxms.client.datacollection.DciDataRow) GraphItem(org.netxms.client.datacollection.GraphItem) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) DciData(org.netxms.client.datacollection.DciData) PartInitException(org.eclipse.ui.PartInitException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Threshold(org.netxms.client.datacollection.Threshold)

Example 4 with GraphItem

use of org.netxms.client.datacollection.GraphItem in project netxms by netxms.

the class DataComparisonView method createPartControl.

/* (non-Javadoc)
	 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
@Override
public void createPartControl(Composite parent) {
    switch(chartType) {
        case DataComparisonChart.BAR_CHART:
            chart = ChartFactory.createBarChart(parent, SWT.NONE);
            break;
        case DataComparisonChart.TUBE_CHART:
            chart = ChartFactory.createTubeChart(parent, SWT.NONE);
            break;
        case DataComparisonChart.PIE_CHART:
            chart = ChartFactory.createPieChart(parent, SWT.NONE);
            break;
    }
    chart.setLegendPosition(legendPosition);
    chart.setLegendVisible(showLegend);
    chart.set3DModeEnabled(showIn3D);
    chart.setTransposed(transposed);
    chart.setTranslucent(translucent);
    for (GraphItem item : items) chart.addParameter(item, 0);
    chart.initializationComplete();
    createActions();
    contributeToActionBars();
    createPopupMenu();
    updateChart();
    refreshController = new ViewRefreshController(this, autoRefreshEnabled ? autoRefreshInterval : -1, new Runnable() {

        @Override
        public void run() {
            if (((Widget) chart).isDisposed())
                return;
            updateChart();
        }
    });
}
Also used : Widget(org.eclipse.swt.widgets.Widget) GraphItem(org.netxms.client.datacollection.GraphItem) ViewRefreshController(org.netxms.ui.eclipse.tools.ViewRefreshController)

Example 5 with GraphItem

use of org.netxms.client.datacollection.GraphItem in project netxms by netxms.

the class PerfTabGraph method addItem.

/**
 * Add another item to graph
 *
 * @param dci
 * @param settings
 */
public void addItem(PerfTabDci dci, PerfTabGraphSettings settings) {
    chart.setLegendVisible(true);
    if (settings.isExtendedLegend())
        chart.setExtendedLegend(true);
    synchronized (items) {
        items.add(dci);
        GraphItemStyle style = new GraphItemStyle(settings.getType(), settings.getColorAsInt(), 2, settings.isInvertedValues() ? GraphItemStyle.INVERTED : 0);
        List<GraphItemStyle> styles = new ArrayList<GraphItemStyle>(chart.getItemStyles());
        if (styles.size() < items.size())
            styles.add(style);
        else
            styles.set(items.size() - 1, style);
        chart.setItemStyles(styles);
        // $NON-NLS-1$ //$NON-NLS-2$
        chart.addParameter(new GraphItem(nodeId, dci.getId(), 0, DataType.INT32, "", settings.getRuntimeName(), "%s"));
    }
}
Also used : ArrayList(java.util.ArrayList) GraphItemStyle(org.netxms.client.datacollection.GraphItemStyle) GraphItem(org.netxms.client.datacollection.GraphItem)

Aggregations

GraphItem (org.netxms.client.datacollection.GraphItem)11 GraphItemStyle (org.netxms.client.datacollection.GraphItemStyle)3 ChartColor (org.netxms.ui.eclipse.charts.api.ChartColor)3 ProgressDialog (android.app.ProgressDialog)2 TextView (android.widget.TextView)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 Point (org.eclipse.swt.graphics.Point)2 GridData (org.eclipse.swt.layout.GridData)2 Control (org.eclipse.swt.widgets.Control)2 DciDataRow (org.netxms.client.datacollection.DciDataRow)2 DataComparisonChart (org.netxms.ui.eclipse.charts.api.DataComparisonChart)2 LineGraphView (com.jjoe64.graphview.LineGraphView)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 GridData (org.eclipse.draw2d.GridData)1 LineBorder (org.eclipse.draw2d.LineBorder)1 Widget (org.eclipse.swt.widgets.Widget)1 PartInitException (org.eclipse.ui.PartInitException)1 TableCell (org.netxms.client.TableCell)1