MPAndroidChart: LineChart with cubic bezier displays wrong (spikes and loops)

不想你离开。 提交于 2019-12-06 05:54:11

问题


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?

This is my config :

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

Thank you


回答1:


Issues like this can have a number of causes:

  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():
    
  3. 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.

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

lineDataSet.setMode(LineDataSet.Mode.HORIZONTAL_BEZIER);


来源:https://stackoverflow.com/questions/41329341/mpandroidchart-linechart-with-cubic-bezier-displays-wrong-spikes-and-loops

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!