use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.
the class BarChartElement method buildRenderer.
/**
* @return
*/
private XYMultipleSeriesRenderer buildRenderer() {
XYMultipleSeriesRenderer renderer = new XYMultipleSeriesRenderer();
renderer.setAxisTitleTextSize(16);
renderer.setChartTitleTextSize(20);
renderer.setLabelsTextSize(15);
renderer.setLegendTextSize(15);
renderer.setFitLegend(true);
renderer.setShowLegend(config.isShowLegend());
renderer.setChartTitle(config.getTitle());
renderer.setBarSpacing(0.4f);
renderer.setShowGrid(false);
renderer.setPanEnabled(false, false);
renderer.setZoomEnabled(false, false);
renderer.setAntialiasing(true);
renderer.setApplyBackgroundColor(true);
renderer.setMarginsColor(Colors.BACKGROUND_COLOR);
renderer.setBackgroundColor(Colors.BACKGROUND_COLOR);
renderer.setAxesColor(Colors.LABEL_COLOR);
renderer.setGridColor(Colors.GRID_COLOR);
renderer.setLabelsColor(Colors.LABEL_COLOR);
renderer.setXLabelsColor(Colors.LABEL_COLOR);
renderer.setYLabelsColor(0, 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(false);
}
renderer.setXAxisMin(0.5);
renderer.setXAxisMax(items.length + 0.5);
renderer.setXLabelsColor(Colors.BACKGROUND_COLOR);
renderer.setYLabelsAlign(Align.RIGHT);
return renderer;
}
use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.
the class GraphBrowser method drawGraph.
/**
* Draw graph based on stored settings
*/
public void drawGraph(GraphSettings gs) {
if (gs != null) {
ChartConfig config;
try {
config = ChartConfig.createFromXml(gs.createXml());
} catch (Exception e) {
Log.e(TAG, "ChartConfig.createFromXml", e);
config = new ChartConfig();
}
Intent newIntent = new Intent(this, DrawGraph.class);
ArrayList<Integer> nodeIdList = new ArrayList<Integer>();
ArrayList<Integer> dciIdList = new ArrayList<Integer>();
ArrayList<Integer> colorList = new ArrayList<Integer>();
ArrayList<Integer> lineWidthList = new ArrayList<Integer>();
ArrayList<String> nameList = new ArrayList<String>();
// Set values
ChartDciConfig[] items = config.getDciList();
for (int i = 0; i < items.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
nodeIdList.add((int) items[i].nodeId);
dciIdList.add((int) items[i].dciId);
int color = items[i].getColorAsInt();
colorList.add(color == -1 ? Colors.DEFAULT_ITEM_COLORS[i] : swapRGB(color));
lineWidthList.add(items[i].lineWidth);
nameList.add(items[i].name);
}
// Pass them to activity
newIntent.putExtra("numGraphs", items.length);
newIntent.putIntegerArrayListExtra("nodeIdList", nodeIdList);
newIntent.putIntegerArrayListExtra("dciIdList", dciIdList);
newIntent.putIntegerArrayListExtra("colorList", colorList);
newIntent.putIntegerArrayListExtra("lineWidthList", lineWidthList);
newIntent.putStringArrayListExtra("nameList", nameList);
newIntent.putExtra("graphTitle", adapter.TrimGroup(gs.getName()));
if (config.getTimeFrameType() == GraphSettings.TIME_FRAME_FIXED) {
newIntent.putExtra("timeFrom", config.getTimeFrom().getTime());
newIntent.putExtra("timeTo", config.getTimeTo().getTime());
} else {
// Back from now
newIntent.putExtra("timeFrom", System.currentTimeMillis() - config.getTimeRangeMillis());
newIntent.putExtra("timeTo", System.currentTimeMillis());
}
startActivity(newIntent);
}
}
use of org.netxms.ui.android.main.activities.helpers.ChartDciConfig in project netxms by netxms.
the class LineChartElement method refresh.
/* (non-Javadoc)
* @see org.netxms.ui.android.main.dashboards.elements.AbstractDashboardElement#refresh()
*/
@Override
public void refresh() {
final ChartDciConfig[] items = config.getDciList();
Log.v(TAG, "refresh(): " + items.length + " items to load");
if (items.length == 0)
return;
final long endTime = System.currentTimeMillis();
final long startTime = endTime - config.getTimeRangeMillis();
graphView.setCustomLabelFormatter(new CustomLabel(Integer.parseInt(sp.getString("global.multipliers", "1")), (endTime - startTime) > 86400 * 1000));
try {
final DciData[] dciData = new DciData[items.length];
for (int i = 0; i < dciData.length; i++) {
dciData[i] = service.getSession().getCollectedData(items[i].nodeId, items[i].dciId, new Date(startTime), new Date(endTime), 0);
}
Log.v(TAG, "refresh(): data retrieved from server");
post(new Runnable() {
@Override
public void run() {
graphView.removeAllSeries();
for (int i = 0; i < dciData.length && i < Colors.DEFAULT_ITEM_COLORS.length; i++) {
DciDataRow[] dciDataRow = dciData[i].getValues();
GraphViewData[] gvData = new GraphViewData[dciDataRow.length];
for (int j = dciDataRow.length - 1, k = 0; j >= 0; j--, k++) // dciData are reversed!
gvData[k] = new GraphViewData(dciDataRow[j].getTimestamp().getTime(), dciDataRow[j].getValueAsDouble());
int color = items[i].getColorAsInt();
color = color == -1 ? Colors.DEFAULT_ITEM_COLORS[i] : swapRGB(color);
GraphViewSeries series = new GraphViewSeries(items[i].getName(), new GraphViewSeriesStyle(color | 0xFF000000, 3), gvData);
graphView.addSeries(series);
}
graphView.setViewPort(startTime, endTime - startTime + 1);
Log.v(TAG, "refresh(): " + dciData.length + " series added; viewport set to " + startTime + "/" + (endTime - startTime + 1));
if (getChildCount() == 0)
addView(graphView);
else
graphView.redrawAll();
}
});
} catch (Exception e) {
Log.e(TAG, "Exception while reading data from server", e);
}
}
Aggregations