use of org.achartengine.model.CategorySeries 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;
}
use of org.achartengine.model.CategorySeries in project AndrOBD by fr3ts0n.
the class ObdGaugeAdapter method add.
/* (non-Javadoc)
* @see android.widget.ArrayAdapter#add(java.lang.Object)
*/
@Override
public void add(EcuDataPv currPv) {
CategorySeries category = (CategorySeries) currPv.get(FID_GAUGE_SERIES);
if (category == null) {
category = new CategorySeries(String.valueOf(currPv.get(EcuDataPv.FID_DESCRIPT)));
category.add(String.valueOf(currPv.get(EcuDataPv.FID_UNITS)), ((Number) currPv.get(EcuDataPv.FID_VALUE)).doubleValue());
currPv.put(FID_GAUGE_SERIES, category);
currPv.setRenderingComponent(null);
}
// make this adapter to listen for PV data updates
currPv.addPvChangeListener(this, PvChangeEvent.PV_MODIFIED);
super.add(currPv);
}
use of org.achartengine.model.CategorySeries in project AndrOBD by fr3ts0n.
the class ObdGaugeAdapter method pvChanged.
@Override
public void pvChanged(PvChangeEvent event) {
ProcessVar currPv = (ProcessVar) event.getSource();
CategorySeries series = (CategorySeries) currPv.get(FID_GAUGE_SERIES);
series.set(0, String.valueOf(currPv.get(EcuDataPv.FID_UNITS)), ((Number) event.getValue()).doubleValue());
}
use of org.achartengine.model.CategorySeries in project AndrOBD by fr3ts0n.
the class ObdGaugeAdapter method getView.
/* (non-Javadoc)
* @see android.widget.ArrayAdapter#getView(int, android.view.View, android.view.ViewGroup)
*/
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
EcuDataPv currPv = getItem(position);
int pid = currPv.getAsInt(EcuDataPv.FID_PID);
// if no recycled convertView delivered, then create a new one
if (convertView == null) {
convertView = mInflater.inflate(resourceId, parent, false);
holder = new ViewHolder();
// get all views into view holder
holder.gauge = (FrameLayout) convertView.findViewById(R.id.gauge);
holder.tvDescr = (TextView) convertView.findViewById(R.id.label);
// remember this view holder
convertView.setTag(holder);
} else {
// recall previous holder
holder = (ViewHolder) convertView.getTag();
}
convertView.getLayoutParams().width = minWidth;
convertView.getLayoutParams().height = minHeight;
// if no rendering component is registered with PV, then create and register new one
DialChart chartView = (DialChart) currPv.getRenderingComponent();
if (chartView == null) {
CategorySeries category = (CategorySeries) currPv.get(FID_GAUGE_SERIES);
Number minValue = (Number) currPv.get(EcuDataPv.FID_MIN);
Number maxValue = (Number) currPv.get(EcuDataPv.FID_MAX);
if (minValue == null)
minValue = 0f;
if (maxValue == null)
maxValue = 255f;
DialRenderer renderer = new DialRenderer();
renderer.setScale(1.25f);
// dial background
renderer.setPanEnabled(false);
renderer.setShowLegend(false);
renderer.setShowLabels(true);
renderer.setLabelsTextSize(mDisplayMetrics.densityDpi / 10);
renderer.setLabelsColor(Color.WHITE);
renderer.setShowLabels(true);
renderer.setVisualTypes(new DialRenderer.Type[] { DialRenderer.Type.NEEDLE });
renderer.setMinValue(minValue.doubleValue());
renderer.setMaxValue(maxValue.doubleValue());
renderer.setChartTitle(currPv.getUnits());
renderer.setChartTitleTextSize(mDisplayMetrics.densityDpi / 10);
SimpleSeriesRenderer r = new SimpleSeriesRenderer();
r.setColor(ChartActivity.getItemColor(pid));
try {
r.setChartValuesFormat(labelFormat);
} catch (Exception e) {
// ignore
}
renderer.addSeriesRenderer(0, r);
// create chart view and register with PV
chartView = new DialChart(category, renderer);
currPv.setRenderingComponent(chartView);
}
convertView.setBackgroundColor(ChartActivity.getItemColor(pid) & 0x08FFFFFF);
// set new values for display
holder.tvDescr.setTextColor(ChartActivity.getItemColor(pid));
holder.tvDescr.setText(String.valueOf(currPv.get(EcuDataPv.FID_DESCRIPT)));
// replace DialChart if needed
holder.gauge.removeViewAt(0);
holder.gauge.addView(new GraphicalView(getContext(), chartView), 0);
return convertView;
}
Aggregations