mpandroidchart - How can I avoid the repeated values in Y-Axis?

前端 未结 6 519
情话喂你
情话喂你 2020-12-10 01:31

I want to avoid the repeated values and the -0 values in Y-Axis, avoiding the image situation.

I have these ideas to solve this, but any solution:

6条回答
  •  伪装坚强ぢ
    2020-12-10 02:00

    I have never used MPAndroidCharts before, but just a little search here and there got me this method which I think would be useful.

    public void setLabelCount(int count, boolean force) {
    
            if (count > 25)
                count = 25;
            if (count < 2)
                count = 2;
    
            mLabelCount = count;
            mForceLabels = force;
        }
    

    The description says that "exact specified count of labels will be drawn and evenly distributed alongside the axis". If you can make it work in your favor, you might be able to limit the zoom.

    Also, there is another method-

    public int getLabelCount() {
            return mLabelCount;
        }
    

    This returns the number of labels on the axis. Hope this helps.

    https://github.com/PhilJay/MPAndroidChart/blob/5a15715b25991e3d61d27d552f9eba45975d65e7/MPChartLib/src/com/github/mikephil/charting/components/YAxis.java

提交回复
热议问题