MPAndroidChart如何绘制y轴限制线并将视点设置为底部

时间:2021-09-09 07:22:40

MPAndroidChart is very awesome library.I am very thankful to. But now, I have 3 problems.

MPAndroidChart是非常棒的库。我非常感谢。但现在,我有3个问题。

The version I used is...

我使用的版本是......

    compile 'com.github.PhilJay:MPAndroidChart:v2.2.5'

And my problem is,...

我的问题是,......

Left: now -> Right: want to be MPAndroidChart如何绘制y轴限制线并将视点设置为底部

左:现在 - >右:想成为

1. How to draw limit a Y value line on line chart or bar chart?

1.如何在折线图或条形图上绘制限制Y值线?

e.g. I want to draw value y=200 line on Image. (e.g. attached image top.shown in red)

例如我想在Image上绘制y = 200行的值。 (例如附件图片top.shown为红色)

2. How to set viewpoint to bottom and get y-axis mint limit to bottom value? (e.g. attached image bottom) I want to set viewpoint to bottom. I tried this code ,But still,there is some padding.

2.如何将视点设置为底部并将y轴薄荷限制到底部值? (例如附加图像底部)我想将视点设置为底部。我尝试了这个代码,但仍然有一些填充。

    XAxis xAxis = mBarChart.getXAxis();
    xAxis.setAxisMinValue(0);

I want to trim this padding.

我想修剪这个填充。

*Edited

*编辑

This works well. Thank you!

这很好用。谢谢!

    mChart.getAxisLeft().setAxisMinValue(0); 

3.How to remove point of graph on line chart?

3.如何在折线图上删除图形点?

A line chart, the bottom image, has lots of marker. So I want to remove these plot point.

折线图,底部图像,有很多标记。所以我想删除这些情节点。

1 个解决方案

#1


5  

1) You need to add a LimitLine

1)您需要添加LimitLine

int maxCapacity = 100;
LimitLine ll = new LimitLine(maxCapacity, "Max Capacity");
chart.getAxisLeft().addLimitLine(ll);

You can also style the line by:

您还可以通过以下方式设置样式:

ll.setLineWidth(4f);
ll.setTextSize(12f);

2) This method may be useful:

2)这种方法可能有用:

chart.setViewPortOffsets(float left, float top, float right, float bottom);

You can read the documentation here.

您可以在此处阅读文档。

3) This method is what you need:

3)这个方法是你需要的:

lineDataSet.setDrawCircles(false);

Once again, its all available in the documentation.

再一次,它在文档中都可用。

#1


5  

1) You need to add a LimitLine

1)您需要添加LimitLine

int maxCapacity = 100;
LimitLine ll = new LimitLine(maxCapacity, "Max Capacity");
chart.getAxisLeft().addLimitLine(ll);

You can also style the line by:

您还可以通过以下方式设置样式:

ll.setLineWidth(4f);
ll.setTextSize(12f);

2) This method may be useful:

2)这种方法可能有用:

chart.setViewPortOffsets(float left, float top, float right, float bottom);

You can read the documentation here.

您可以在此处阅读文档。

3) This method is what you need:

3)这个方法是你需要的:

lineDataSet.setDrawCircles(false);

Once again, its all available in the documentation.

再一次,它在文档中都可用。