简体   繁体   中英

GraphView library x and y axis

I am using a GraphView library and i want to use the method GraphViewData to show the LineGraph . To be honest I don't know how to generate the LineGraph with this library. So I removed the sample mock data that shows the LineGraph and replaced it with my own x data and y data.

But I am doing something wrong, it does not shows the line it self, only it fills the x axis and y axis:

Bundle extras = getIntent().getExtras(); 
if(extras != null) {
    valueX = extras.getDouble("xValue");
    valueY = extras.getDouble("yValue");
    Log.d("X = " + valueX, " Y = " + valueY);
}

GraphViewSeries exampleSeries = new GraphViewSeries(
    new GraphViewData[] {
        new GraphViewData(valueX, valueY)
    });

// graph with dynamically genereated horizontal and vertical labels
GraphView graphView;
graphView = new LineGraphView(
    this,                         // context
    "Incomming Bluetooth Data");  // heading
graphView.addSeries(exampleSeries); // data

LinearLayout layout = (LinearLayout) findViewById(R.id.graph1);
layout.addView(graphView);

You only define the coordinates for one point. To draw your line, you need to define the coordonates for 2 different points.

Add another GraphViewData in the array with different X and Y values.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM