0

I am trying to add a graph to my project for that purpose I am using GraphView library.

My issue here is in one of the methods drawseries expecting an interface (GraphViewDataInterface) which I am confused on how to provide as a input.

draw series method input parameters:

The method drawSeries(Canvas, GraphViewDataInterface[], float, float, float, double, double, double, double, float, GraphViewSeries.GraphViewSeriesStyle)

I have provided all parameters but struck at GraphViewDataInterface.

How can I provide an interface as a parameter to the method?

Code:

public class graph extends Activity{

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.graph);

        BarGraphView bgv=new BarGraphView(getApplicationContext(), "firstgraph");
        Bitmap b = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(b);
        bgv.drawSeries(c,
                 GraphViewDataInterface[] {10.0,10.0}, (float) 1.0,
                (float) 1.0,
                (float) 1.0,
                1.0,
                1.0,
                1.0,
                1.0,
                (float) 1.0,
                new GraphViewSeries.GraphViewSeriesStyle(1, 1));

            LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout1);
            layout.addView(bgv);
    }
halfer
  • 19,824
  • 17
  • 99
  • 186
Siva
  • 9,043
  • 12
  • 40
  • 63

1 Answers1

1

I'm not sure what exactly you want to do. drawSeries is an intern method. normally you never call it explicit. Take a look at the examples and the documentation.

Anyway, the GraphViewDataInterface is used to return just the x and y values. You could provide your own class and methods to do so. But normally you use the class GraphViewData that already implements that interface.

import com.jjoe64.graphview.GraphView.GraphViewData;
//...
// create data array
GraphViewDataInterface[] data = new GraphViewDataInterface[] {
  new GraphViewData(0, 1),
  new GraphViewData(1, 5),
  new GraphViewData(2, 3)
};
appsthatmatter
  • 6,347
  • 3
  • 36
  • 40
  • Thanks for your response... I am trying to implement Bar Graph with `drawseries`... am I going in wrong direction? if yes can you guide me in correct path also I need documentation of all methods how they are used which I am unable to get from anywhere... can you guide me on this. thanks – Siva Nov 26 '14 at 07:24
  • then, take a look at the GraphView-Demos project. There are many working examples: https://github.com/jjoe64/GraphView-Demos – appsthatmatter Nov 28 '14 at 14:32