问题
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:
- Not using the latest version of MPAndroidChart. Make sure you are using the latest version which includes all of the bug fixes.
Using a cubic intensity that is not appropriate for the DataSet. Try experimenting with different values for:
lineDataSet.setCubicIntensity():
- 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