jjoe64 / GraphView

Android Graph Library for creating zoomable and scrollable line and bar graphs.
https://github.com/jjoe64/GraphView/wiki
Other
2.76k stars 811 forks source link

Following documentation doesnt work #645

Open cassiorodrigo opened 5 years ago

cassiorodrigo commented 5 years ago

Graphview is not plotting the line in the graph. Background (grid) still shows up, but I have no lines in the graph, even when I copied and paste the code from the documentation.

code as follows:

    import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle; import android.provider.ContactsContract; import android.view.View; import android.widget.LinearLayout;

import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.Viewport; import com.jjoe64.graphview.helper.GraphViewXML; import com.jjoe64.graphview.series.DataPoint; import com.jjoe64.graphview.series.LineGraphSeries;

public class graphview extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_graphview);

    GraphView graph = findViewById(R.id.graphView1);

    LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[]{
            new DataPoint(0, 0),
            new DataPoint(0.1, 0.1),
            new DataPoint(0.2, 0.33),
            new DataPoint(0.33, 0.42),
            new DataPoint(0.44, 0.6)
    });
    graph.addSeries(series);
}

public void onClick(View view){

}

}

and XML:

<com.jjoe64.graphview.GraphView
    android:id="@+id/graphView1"
    android:layout_width="match_parent"
    android:layout_height="100dp"
    android:layout_marginTop="8dp"
    android:layout_marginBottom="8dp"
    app:layout_constraintBottom_toTopOf="@+id/btn_main2"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/graphView" />

weird thing:

GraphViewXML is working, but I don't know how to update the values on the required "app:dataSeries" of the document.

any help would be awesome.

thanks