Search code examples
androidandroid-graphview

draw a chart with GraphView


Anyone having some experience with the GraphView library? I need to draw a chart, the closest approximation is something like that damage/distance chart on Battlelog:

enter image description here

So as assumed here, 0 - 9m the damage would be constant, then falling down and starting with 50m constant again. Example from the developer's page which I want to try just to see what it would look like:

  GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[] {  
                  new GraphViewData(1, 2.0d)  
                  , new GraphViewData(2, 1.5d)  
                  , new GraphViewData(3, 2.5d)  
                  , new GraphViewData(4, 1.0d)  
            });  

            GraphView graphView = new LineGraphView(  
                  getActivity() // context  
                  , "GraphViewDemo" // heading  
            );  
            graphView.addSeries(exampleSeries); // data 

GraphViewData cannot be resolved however. Any suggestions from those who used that library or possible alternatives to achieve what I need (see picture above)?


Solution

  • Oh well, that's by bad. Just looked inside the lib code and found out that I had to import GraphView to get it working, though the ADT didn't suggest to do so.