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();
}
}
}
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;
}
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();
}
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();
}
});
}
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"));
}
}
Aggregations