简体   繁体   English

GraphView Android,如何更改原始x轴和y轴的厚度?

[英]GraphView Android, How to change thickness of original x-axis and y-axis?

I am using the GraphView library for drawing graphs in an Android app and I am very pleased with the library so far. 我正在使用GraphView库在Android应用程序中绘制图形,到目前为止我对该库非常满意。 I am using it in a fixed frame realtime scenario and have noticed that the x-axis and y-axis grid lines are thicker thatn the other unit grid lines. 我在一个固定的帧实时场景中使用它,并注意到x轴和y轴网格线比其他单位网格线更粗。 Is there any way I can make them similar to the other lines? 有什么方法可以让它们与其他线条相似吗?

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

// Set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0);
graph.getViewport().setMaxX(40);

// Set manual Y bounds
graph.getViewport().setYAxisBoundsManual(true);
graph.getViewport().setMinY(-40);
graph.getViewport().setMaxY(60);

// Draw a border between between labels and viewport
graph.getViewport().setDrawBorder(false);

graph.getGridLabelRenderer().setHumanRounding(false);
graph.getGridLabelRenderer().setNumHorizontalLabels(11);
graph.getGridLabelRenderer().setNumVerticalLabels(6);

Basically I would like to change this: 基本上我想改变这个:

在此输入图像描述

to this: 对此:

在此输入图像描述

Thanks in advance! 提前致谢!

There is a setHighlightZeroLines method for the GridLabelRenderer class that is true by default. GridLabelRenderer类有一个setHighlightZeroLines方法,默​​认情况下为true Code something like: 代码类似于:

graphView.getGridLabelRenderer().setHighlightZeroLines(false);

should do what you want. 应该做你想做的事。

Please find Line Graph Series in detail: 请详细查找Line Graph Series:

Line Graph Series in detail 线图系列详细

// styling series //造型系列

series.setTitle("Random Curve 1");
series.setColor(Color.GREEN);
series.setDrawDataPoints(true);
series.setDataPointsRadius(10);
series.setThickness(8);

// custom paint to make a dotted line //自定义绘画以制作虚线

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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