Search in sources :

Example 1 with ChartDciConfig

use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.

the class PieChartElement method buildDataset.

/**
 * @return
 */
private CategorySeries buildDataset() {
    CategorySeries series = new CategorySeries(config.getTitle());
    ChartDciConfig[] items = config.getDciList();
    for (int i = 0; i < items.length; i++) {
        series.add(items[i].getName(), 0);
    }
    return series;
}
Also used : CategorySeries(org.achartengine.model.CategorySeries) ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig)

Example 2 with ChartDciConfig

use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.

the class PieChartElement method buildRenderer.

/**
 * @return
 */
private DefaultRenderer buildRenderer() {
    DefaultRenderer renderer = new DefaultRenderer();
    renderer.setLabelsTextSize(15);
    renderer.setLegendTextSize(15);
    renderer.setShowLegend(config.isShowLegend());
    renderer.setMargins(new int[] { 20, 30, 15, 0 });
    renderer.setPanEnabled(false);
    renderer.setZoomEnabled(false);
    renderer.setAntialiasing(true);
    renderer.setChartTitle(config.getTitle());
    renderer.setApplyBackgroundColor(true);
    renderer.setBackgroundColor(Colors.BACKGROUND_COLOR);
    renderer.setAxesColor(Colors.LABEL_COLOR);
    renderer.setLabelsColor(Colors.LABEL_COLOR);
    ChartDciConfig[] items = config.getDciList();
    for (int i = 0; i < items.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
        XYSeriesRenderer r = new XYSeriesRenderer();
        int color = items[i].getColorAsInt();
        if (color == -1)
            color = Colors.DEFAULT_ITEM_COLORS[i];
        else
            color = swapRGB(color);
        r.setColor(color | 0xFF000000);
        renderer.addSeriesRenderer(r);
    // r.setDisplayChartValues(true);
    }
    return renderer;
}
Also used : ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig) DefaultRenderer(org.achartengine.renderer.DefaultRenderer) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer)

Example 3 with ChartDciConfig

use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.

the class PieChartElement method refresh.

/* (non-Javadoc)
	 * @see org.netxms.ui.android.main.dashboards.elements.AbstractDashboardElement#refresh()
	 */
@Override
public void refresh() {
    final ChartDciConfig[] items = config.getDciList();
    if (items.length == 0)
        return;
    try {
        final DciData[] dciData = new DciData[items.length];
        for (int i = 0; i < dciData.length; i++) {
            dciData[i] = new DciData(0, 0);
            dciData[i] = service.getSession().getCollectedData(items[i].nodeId, items[i].dciId, null, null, 1);
        }
        post(new Runnable() {

            @Override
            public void run() {
                for (int i = 0; i < dciData.length; i++) {
                    dataset.set(i, items[i].getName(), dciData[i].getLastValue().getValueAsDouble());
                }
                chartView.repaint();
            }
        });
    } catch (Exception e) {
        Log.e(TAG, "Exception while reading data from server", e);
    }
}
Also used : ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig) DciData(org.netxms.client.datacollection.DciData)

Example 4 with ChartDciConfig

use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.

the class BarChartElement method refresh.

/* (non-Javadoc)
	 * @see org.netxms.ui.android.main.dashboards.elements.AbstractDashboardElement#refresh()
	 */
@Override
public void refresh() {
    final ChartDciConfig[] items = config.getDciList();
    if (items.length == 0)
        return;
    try {
        final DciData[] dciData = new DciData[items.length];
        for (int i = 0; i < dciData.length; i++) {
            dciData[i] = new DciData(0, 0);
            dciData[i] = service.getSession().getCollectedData(items[i].nodeId, items[i].dciId, null, null, 1);
        }
        post(new Runnable() {

            @Override
            public void run() {
                XYMultipleSeriesDataset dataset = chart.getDataset();
                for (int i = 0; i < dciData.length; i++) {
                    dataset.removeSeries(i);
                    XYSeries series = new XYSeries(items[i].getName());
                    for (int j = 0; j < items.length; j++) {
                        series.add(j + 1, (i == j) ? dciData[i].getLastValue().getValueAsDouble() : 0);
                    }
                    dataset.addSeries(i, series);
                }
                chartView.repaint();
            }
        });
    } catch (Exception e) {
        Log.e(TAG, "Exception while reading data from server", e);
    }
}
Also used : XYSeries(org.achartengine.model.XYSeries) ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig) DciData(org.netxms.client.datacollection.DciData) XYMultipleSeriesDataset(org.achartengine.model.XYMultipleSeriesDataset)

Example 5 with ChartDciConfig

use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.

the class BarChartElement method buildDataset.

/**
 * @return
 */
private XYMultipleSeriesDataset buildDataset() {
    XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
    ChartDciConfig[] items = config.getDciList();
    for (int i = 0; i < items.length; i++) {
        XYSeries series = new XYSeries(items[i].getName());
        for (int j = 0; j < items.length; j++) {
            series.add(j + 1, 0);
        }
        dataset.addSeries(series);
    }
    return dataset;
}
Also used : XYSeries(org.achartengine.model.XYSeries) ChartDciConfig(org.netxms.ui.android.main.activities.helpers.ChartDciConfig) XYMultipleSeriesDataset(org.achartengine.model.XYMultipleSeriesDataset)

Aggregations

ChartDciConfig (org.netxms.ui.android.main.activities.helpers.ChartDciConfig)8 DciData (org.netxms.client.datacollection.DciData)3 XYMultipleSeriesDataset (org.achartengine.model.XYMultipleSeriesDataset)2 XYSeries (org.achartengine.model.XYSeries)2 XYSeriesRenderer (org.achartengine.renderer.XYSeriesRenderer)2 Intent (android.content.Intent)1 GraphViewData (com.jjoe64.graphview.GraphView.GraphViewData)1 GraphViewSeries (com.jjoe64.graphview.GraphViewSeries)1 GraphViewSeriesStyle (com.jjoe64.graphview.GraphViewSeries.GraphViewSeriesStyle)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 CategorySeries (org.achartengine.model.CategorySeries)1 DefaultRenderer (org.achartengine.renderer.DefaultRenderer)1 XYMultipleSeriesRenderer (org.achartengine.renderer.XYMultipleSeriesRenderer)1 NXCException (org.netxms.client.NXCException)1 CustomLabel (org.netxms.ui.android.helpers.CustomLabel)1 ChartConfig (org.netxms.ui.android.main.activities.helpers.ChartConfig)1