GraphView中的虚线

Jim*_*nts 3 java android paint android-custom-view android-graphview

我想要一条虚线,如官方文档中所述

    futureSeries.setDrawDataPoints(true);

    Paint paint = new Paint();
    paint.setStyle(Paint.Style.STROKE);
    paint.setStrokeWidth(10);
    paint.setPathEffect(new DashPathEffect(new float[]{8, 5}, 0));
    futureSeries.setCustomPaint(paint);

    graph.addSeries(futureSeries);
Run Code Online (Sandbox Code Playgroud)

build.gradle:

   compile 'com.jjoe64:graphview:4.2.1'
Run Code Online (Sandbox Code Playgroud)

结果不是虚线:

在此处输入图片说明

这样的事情就可以了:

在此处输入图片说明

azi*_*ian 5

只需申请LineGraphSeries#setDrawAsPath(true)

Paint paint = new Paint();
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(10);
paint.setPathEffect(new DashPathEffect(new float[]{8, 5}, 0));

LineGraphSeries<DataPoint> series = ... // init

series.setDrawAsPath(true);
series.setCustomPaint(paint);

graphView.addSeries(series);
Run Code Online (Sandbox Code Playgroud)

结果:

在此处输入图片说明