MPAndroidChart:具有三次贝塞尔曲线的LineChart显示错误(尖峰和循环) [英] MPAndroidChart: LineChart with cubic bezier displays wrong (spikes and loops)

查看:534
本文介绍了MPAndroidChart:具有三次贝塞尔曲线的LineChart显示错误(尖峰和循环)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试绘制具有三次方图的LineChart.结果类似于下面的屏幕快照:三次方贝塞尔曲线显示错误并带有尖峰".有人可以帮我使其正确显示吗?

I am trying to make a LineChart with a cubic plot. The result is like in the screenshot below: the cubic bezier displays wrong and has "spikes". Can someone help me make it appear correctly?

这是我的配置:

        LineDataSet lineDataSet = new LineDataSet(entries,nameLabel);
        lineDataSet.setColor(Constants.colors.get(i));
        lineDataSet.setDrawValues(false);
        lineDataSet.setDrawCircles(false);
        lineDataSet.setMode(LineDataSet.Mode.CUBIC_BEZIER);

谢谢

推荐答案

这样的问题可能有多种原因:

Issues like this can have a number of causes:

  1. 不使用最新版本的MPAndroidChart .确保您使用的是最新版本,其中包括所有错误修复.
  2. 使用不适用于数据集的立方强度.尝试对以下项使用不同的值进行试验:

  1. Not using the latest version of MPAndroidChart. Make sure you are using the latest version which includes all of the bug fixes.
  2. Using a cubic intensity that is not appropriate for the DataSet. Try experimenting with different values for:

lineDataSet.setCubicIntensity():

  • 为数据集的xIndices使用了不正确的粒度.在xIndex条目之间的间隙很小且很小的情况下,三次方可以很好地工作.尝试预处理您的DataSet,以便获得适当的粒度.例如,如果输入数据的时间戳具有毫秒级的粒度,但是您只想为每隔几分钟发生的事件绘制一个点,请避免在xIndex设置为毫秒值的情况下进行输入.尝试用几秒钟甚至几分钟来输入数据集.
  • Using an incorrect granularity for the xIndices of the DataSet. Cubics work well with even and small gaps between xIndex entries. Try pre-processing your DataSet so that there is an appropriate granularity. For example, if the input data has timestamps with millisecond granularity but you only want to graph points for events that occur every few minutes, avoid making entries with the xIndex set to a millisecond value. Try instead making the Entry of the DataSet using seconds or even minutes.
  • 如果这两种方法均失败,则您的DataSet可能需要水平三次方,才能解决此问题:

    If both of these approaches fail, your DataSet may require a horizontal cubic which will resolve the issue:

    lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);
    

    这篇关于MPAndroidChart:具有三次贝塞尔曲线的LineChart显示错误(尖峰和循环)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆