MPAndroidChart - Why BarData constructor not work?

前端 未结 4 1256
攒了一身酷
攒了一身酷 2021-01-20 01:40

My code:

 public BarData getBarData(String fieldName) {
        ArrayList entries = new ArrayList<>();
        entries.add(new BarEntry         


        
4条回答
  •  佛祖请我去吃肉
    2021-01-20 02:10

    For version 3 you must use like this

    // the labels that should be drawn on the XAxis
    final String[] quarters = new String[] { "Q1", "Q2", "Q3", "Q4" };
    
    IAxisValueFormatter formatter = new IAxisValueFormatter() {
    
        @Override
        public String getFormattedValue(float value, AxisBase axis) {
            return quarters[(int) value];
        }
    
        // we don't draw numbers, so no decimal digits needed
        @Override
        public int getDecimalDigits() {  return 0; }
    };
    
    XAxis xAxis = mLineChart.getXAxis();
    xAxis.setGranularity(1f); // minimum axis-step (interval) is 1
    xAxis.setValueFormatter(formatter);
    

提交回复
热议问题