Achartengine: redibujar el gráfico sobre el gráfico normal

In my app I switch the view of two different graphs. The first time is the graph is drawn looks perfect, but when I go to the other one and come back looks like it draws two times the same graph but in different sizes and as soon as you click the graph it changes and looks perfect.

The screen when it looks wired is:

The screen when it looks wired is:

The code that draws the graph is always the same. This function is:

private void downloadInfo(String app, String object) {
    // Display flow graph
    String query = "Select name from relation where obj_app = '" + app
            + "' and obj_name = '" + object
            + "' and obj_type = 1 and type= 22";
    String data = "name";
    String comparateur = new DataBaseAccess().execute(query, data);
    String compAux[] = comparateur.split("&");
    query = "Select * from data_1h where app = '" + app
            + "' and obj_name = '" + compAux[0] + "' and obj_type= 22";
    String file = new DataBaseAccess().execute(query, "file-date");
    String[] fileAux = file.split("&");
    date = fileAux[1];
    GraphicalView mChartView = new DebitGraph().execute(ShowGraph.this,
            fileAux[0], fileAux[1], compAux[0], object);
    RelativeLayout layout = (RelativeLayout) findViewById(;
    Display display = getWindowManager().getDefaultDisplay();
    RelativeLayout.LayoutParams paramsForChart1 = new RelativeLayout.LayoutParams(
//  paramsForChart1.bottomMargin = 25;
    layout.addView(mChartView, paramsForChart1);
    // Display Meteo graph
    query = "Select name from relation where obj_app = '" + app
            + "' and obj_name = '" + object
            + "' and obj_type = 1 and type= 20";
    data = "name";
    String station = new DataBaseAccess().execute(query, data);
    String stationAux[] = station.split("&");
    query = "Select * from data_1h where app = '" + app
            + "' and obj_name = '" + stationAux[0] + "' and obj_type= 20";
    data = "file-date";
    file = new DataBaseAccess().execute(query, data);
    fileAux = file.split("&");
    GraphicalView mChartView2 = new Meteo().execute(ShowGraph.this,
            fileAux[0], fileAux[1], stationAux[0], prec, temp);
    RelativeLayout.LayoutParams paramsForChart2 = new RelativeLayout.LayoutParams(
    layout = (RelativeLayout) findViewById(;
//  paramsForChart2.bottomMargin = 25;
    layout.addView(mChartView2, paramsForChart2);

    // Display check boxes for temperature and precipitation
    RelativeLayout check = (RelativeLayout) findViewById(;
    check = (RelativeLayout) findViewById(;
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout checkbox = (LinearLayout) inflater.inflate(
            R.layout.checkboxes, null);

    // Update text bar text with meteo info
     * TextView meteo = (TextView) findViewById(;
     * meteo.setText("Méteo " + stationAux[0] + " " + fileAux[1]);
     * meteo.setTextColor(Color.BLACK); meteo.setTextSize(14);
    if (MyDialog.isShowing()) {

I have alse changed the achartengine library as to change the zoom buttons but nothing else!

In my logCat I get this warning each time the screen goes crazy:

03-13 12:01:16.767: W/InputManagerService(229): Window already focused, ignoring focus gain of:$Stub$Proxy@2b1fb958

I've been looking this error in the forum but any of the answers I've found are usefull!

For more info, looks like I have the same problem as this post:

Achartengine: redibujar el gráfico sobre el gráfico normal

But when I comment my onResume() the problem don't disappear!

¿Algunas ideas? ¡Gracias!

preguntado el 09 de marzo de 12 a las 15:03

we have any example for this one... -

1 Respuestas

When you return to the chart view, you may need to call a repaint() on it.

Another way to avoid such screen artifacts would be to call renderer.setInScroll(true);


respondido 13 mar '12, 15:03

oK, it didn't worked"looked like at the begining but the error just moved to another place! I will edit the question with more info I have! - Lucía

I can't thank you enouth!! It was driving me crazy just a few days away of delivering the app!!Thank you so so much!! - Lucía

i know this question is a bit old, but are there consequences of using setInScroll(true)? - paul

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.