GraphView 中的虚线
Dotted dash line in GraphView
我要虚线,如the official documentation:
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);
build.gradle:
compile 'com.jjoe64:graphview:4.2.1'
结果不是虚线:
像这样就可以了:
只需申请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);
结果:
我要虚线,如the official documentation:
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);
build.gradle:
compile 'com.jjoe64:graphview:4.2.1'
结果不是虚线:
像这样就可以了:
只需申请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);
结果: