I need to hide a linechart when user click a button, and show it when user clicks again. Here is my code:
public void onCheckboxClicked(View view) {
Cursor cursor = getCursor();
id = cursor.getColumnIndexOrThrow(KEY_ID);
ect = cursor.getColumnIndexOrThrow(TEMPER);
battery = cursor.getColumnIndexOrThrow(BATTERY);
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
mRenderer.setApplyBackgroundColor(true);
mRenderer.setBackgroundColor(Color.DKGRAY);
boolean checked = ((CheckBox) view).isChecked();
switch (view.getId()) {
case R.id.check_temp:
XYSeriesRenderer renderer1 = new XYSeriesRenderer();
if (checked) {
TimeSeries series1 = new TimeSeries("Temperature");
while (cursor.moveToNext()) {
series1.add(cursor.getDouble(id), cursor.getDouble(ect));
}
dataset.addSeries(series1);
renderer1.setColor(Color.YELLOW);
mRenderer.addSeriesRenderer(renderer1);
}else{
mRenderer.removeSeriesRenderer(renderer1); //not working
}
break;
case R.id.check_battery: //not working
if(checked) {...}
} //end of switch
GraphicalView viewchart = ChartFactory.getLineChartView(this, dataset, mRenderer);
chartContainer.addView(viewchart);
} //end of onCheckboxClicked fxn
- mRenderer.removeSeriesRenderer(renderer1) not working.
- checkbox only show firest time linechart , even I check another checkbox ,
it's still not show second linechart?
Aucun commentaire:
Enregistrer un commentaire