Use the data obtained in the parse of my Web Service to turn into a chart on Android

Asked

Viewed 92 times

1

I have a web service that returns me some values, for example now is this way the answer of my parse:

inserir a descrição da imagem aqui

The parse I did to get the filtered values was this:

    String valFormaOutros = doc.getElementsByTagName("VALOR").item(0).getTextContent();

    String descForma = doc.getElementsByTagName("DESCRICAO").item(0).getTextContent();
    String valForma = doc.getElementsByTagName("VALOR").item(1).getTextContent();
    String descForma1 = doc.getElementsByTagName("DESCRICAO").item(1).getTextContent();
    String valForma1 = doc.getElementsByTagName("VALOR").item(2).getTextContent();
    String descForma2 = doc.getElementsByTagName("DESCRICAO").item(2).getTextContent();
    String valForma2 = doc.getElementsByTagName("VALOR").item(3).getTextContent();
    String descForma3 = doc.getElementsByTagName("DESCRICAO").item(3).getTextContent();
    String valForma3 = doc.getElementsByTagName("VALOR").item(4).getTextContent();
    String descForma4 = doc.getElementsByTagName("DESCRICAO").item(4).getTextContent();
    String valForma4 = doc.getElementsByTagName("VALOR").item(5).getTextContent();
    String descForma5 = doc.getElementsByTagName("DESCRICAO").item(5).getTextContent();
    String valForma5 = doc.getElementsByTagName("VALOR").item(6).getTextContent();


    FormasDePagamento.tvFormas.setText("Outros: "+ valFormaOutros+ "\n"+ descForma + ": " + valForma + "\n" + descForma1 + ": " + valForma1 + "\n" + descForma2 + ": " + valForma2 + "\n" + descForma3 + ": " + valForma3 + "\n" + descForma4 + ": " + valForma4 + "\n" + descForma5 + ": " + valForma5);

So it returns me these print values above..

Now, I would like to repurpose this data to form a chart (pizza), so my customers can see the indicators more accurately.. Does anyone have any idea what can be done, or even remade?

1 answer

1


You can use Holographlibrary. I never used it but it seems to be simple https://github.com/Androguide/HoloGraphLibrary

On github you have this example:

PieGraph pg = (PieGraph)findViewById(R.id.graph);
PieSlice slice = new PieSlice();
slice.setColor(Color.parseColor("#99CC00"));
slice.setValue(2);
pg.addSlice(slice);
slice = new PieSlice();
slice.setColor(Color.parseColor("#FFBB33"));
slice.setValue(3);
pg.addSlice(slice);
slice = new PieSlice();
slice.setColor(Color.parseColor("#AA66CC"));
slice.setValue(8);
pg.addSlice(slice);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.