【问题标题】:X-Axis label in mpandroidchart [duplicate]mpandroidchart 中的 X 轴标签 [重复]
【发布时间】:2016-10-13 03:04:02
【问题描述】:

之前,我们可以使用 LineData 的构造函数为 X 轴设置标签。

            LineData lineData = new LineData(labels,dataSet);

但是3.0以后就不行了。这是被删除还是我遗漏了什么?

【问题讨论】:

    标签: android mpandroidchart


    【解决方案1】:

    您可以使用值格式化程序。 xAxis.setValueFormatter(new AxisFormatter)

    【讨论】:

      【解决方案2】:
      xAxis.setValueFormatter(new AxisValueFormatter() {
                  @Override
                  public String getFormattedValue(float value, AxisBase axis) {
      // here you can return whatever you want,
      // for example you can return values from array, and use value argument as index
                      return labels[value]);
                  }
      
                  @Override
                  public int getDecimalDigits() {
                      return 0;
                  }
              });
      

      【讨论】:

      • 这里的labels 变量是什么?它是如何创建的?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-29
      相关资源
      最近更新 更多