Skip to content

Point Graph

Jonas Gehring edited this page Apr 12, 2019 · 2 revisions

Points Graph in detail

To plot a points diagram with GraphView you have to use the PointsGraphSeries class. This has some predefined drawings, and you have to opportunity to use a custom rendering.


  • setShape

    Here you define the drawing that will be used for the data points. You can use Shape.POINT, Shape.TRIANGLE, Shape.RECTANGLE. By default the point is used.

  • setSize

    This defines the size of the shape.

  • setCustomShape

    You can implement a custom rendering method. This will be called for every data point with the x/y coordinates. You have to take care, that you paint your drawing at that point. You have also take care about the color and the size.

Here is an example with the different shapes and a custom shape:

GraphView graph = (GraphView) findViewById(;
PointsGraphSeries<DataPoint> series = new PointsGraphSeries<>(new DataPoint[] {
    new DataPoint(0, -2),
    new DataPoint(1, 5),
    new DataPoint(2, 3),
    new DataPoint(3, 2),
    new DataPoint(4, 6)

PointsGraphSeries<DataPoint> series2 = new PointsGraphSeries<DataPoint>(new DataPoint[] {
    new DataPoint(0, -1),
    new DataPoint(1, 4),
    new DataPoint(2, 2),
    new DataPoint(3, 1),
    new DataPoint(4, 5)

PointsGraphSeries<DataPoint> series3 = new PointsGraphSeries<>(new DataPoint[] {
    new DataPoint(0, 0),
    new DataPoint(1, 3),
    new DataPoint(2, 1),
    new DataPoint(3, 0),
    new DataPoint(4, 4)

PointsGraphSeries<DataPoint> series4 = new PointsGraphSeries<>(new DataPoint[] {
    new DataPoint(0, 1),
    new DataPoint(1, 2),
    new DataPoint(2, 0),
    new DataPoint(3, -1),
    new DataPoint(4, 3)
series4.setCustomShape(new PointsGraphSeries.CustomShape() {
    public void draw(Canvas canvas, Paint paint, float x, float y, DataPointInterface dataPoint) {
    canvas.drawLine(x-20, y-20, x+20, y+20, paint);
    canvas.drawLine(x+20, y-20, x-20, y+20, paint);


You can’t perform that action at this time.