user2537915
user2537915

Reputation: 11

Graph/Plots on ANDROID

I am new to android and trying to learn creation or plotting of graphs in android. I've come across 2 libraries:

  1. GraphView
  2. AndroidPlot.

My intent would be to receive some sound file and plot it on a graph. So, for this purpose which library would be better. Also I wanna know, where I can see the complete implementation or definitions of these libraries i.e. the structure and code for the API's used in the above libraries.

Also I have tried some sample codes available on net. But I'm looking for a more sophiticated code which I could develop on eclipse ADT and hence can learn something out of it.

Upvotes: 0

Views: 6466

Answers (4)

Charles Martin
Charles Martin

Reputation: 63

Use AndroidPlot. This code draw the content of Vector(in this case filled of zeros). You only have to pass the info of the wav file to the vector. And you can check this thread for the reading issue. Android: Reading wav file and displaying its values

    plot = (XYPlot) findViewById(R.id.Grafica);
    plot.setDomainStep(XYStepMode.INCREMENT_BY_VAL, 0.5);
    plot.setRangeStep(XYStepMode.INCREMENT_BY_VAL, 1);

    plot.getGraphWidget().getGridBackgroundPaint().setColor(Color.rgb(255, 255, 255));
    plot.getGraphWidget().getDomainGridLinePaint().setColor(Color.rgb(255, 255, 255));
    plot.getGraphWidget().getRangeGridLinePaint().setColor(Color.rgb(255, 255, 255));

    plot.getGraphWidget().setDomainLabelPaint(null);
    plot.getGraphWidget().setRangeLabelPaint(null);
    plot.getGraphWidget().setDomainOriginLabelPaint(null);
    plot.getGraphWidget().setRangeOriginLabelPaint(null);
    plot.setBorderStyle(BorderStyle.NONE, null, null);

    plot.getLayoutManager().remove(plot.getLegendWidget());
    plot.getLayoutManager().remove(plot.getDomainLabelWidget());
    plot.getLayoutManager().remove(plot.getRangeLabelWidget());
    plot.getLayoutManager().remove(plot.getTitleWidget());


    //plot.getBackgroundPaint().setColor(Color.WHITE);
    //plot.getGraphWidget().getBackgroundPaint().setColor(Color.WHITE);

    plot.setRangeBoundaries(-25, 25, BoundaryMode.FIXED);// check that, these //boundaries wasn't for audio files 
    InicializarLasVariables();
    for(int i=0; i<min/11;i++){

        DatoY=0;
        Vector.add(DatoY);
        }
        XYSeries series = new SimpleXYSeries(Vector, SimpleXYSeries.ArrayFormat.Y_VALS_ONLY,"");
        LineAndPointFormatter seriesFormat = new LineAndPointFormatter(Color.rgb(0, 0, 0), 0x000000, 0x000000, null);
        plot.clear();
        plot.addSeries(series, seriesFormat);

Upvotes: 0

Brais Gabin
Brais Gabin

Reputation: 5935

I have used Achartengine some times and it works great. I modified it without difficulties.

Upvotes: 1

Anup Cowkur
Anup Cowkur

Reputation: 20563

My intent would be to receive some sound file and plot it on a graph

Neither library does this by default. The libraries are used to plot a graph given a set of data points. Getting the data points from the sound file is up to you.

So, for this purpose which library would be better.

Either library should be fine once you get the data points.

Also I wanna know, where I can see the complete implementation or definitions of these libraries i.e. the structure and code for the API's used in the above libraries.

Check out the sources for GraphView and AndroidPlot.

Upvotes: 1

nilesh patel
nilesh patel

Reputation: 832

If You are drawing simple Line Graph using canvas to draw the graph.

Upvotes: 0

Related Questions