【问题标题】:How to set Y axis values to the left only and not on both left and right side using MPAndroidChart BarChart如何使用 MPAndroidChart BarChart 仅将 Y 轴值设置在左侧而不是左侧和右侧
【发布时间】:2017-02-02 12:44:14
【问题描述】:

我已经弄清楚如何使用下面的方法将 X 轴值设置为显示在底部而不是顶部。我现在遇到的问题是我的 Y 轴值显示在左侧和右侧,我只希望它们显示在图表的左侧。

if (response.isSuccessful()) {
   // Reload data source
   Items = new ArrayList<>();
   Items.clear();
   Items.addAll(response.body());
   //currentReportingGroup = Items.get(0).ReportingGroup;
   //ItemsAdapter.notifyDataSetChanged();
   Log.i(TAG, "onResponse: ");
   //load(view);
   BarChart chart = (BarChart) aq.id(R.id.chart).getView();
   XAxis xAxisChart = chart.getXAxis();
   YAxis yAxisChart = chart.getAxisLeft();
   //yAxisChart.setValueFormatter(new MyAxisValueFormatter());
  // yAxisChart.setPosition(YAxis.YAxisLabelPosition.);
   xAxisChart.setPosition(XAxis.XAxisPosition.BOTTOM);
   BarData data = new BarData(getXAxisValues(), getDataSet());
   chart.setData(data);
   chart.setDescription("");
   chart.animateXY(2000, 2000);
   chart.invalidate();

}

【问题讨论】:

    标签: java android android-studio mpandroidchart


    【解决方案1】:

    您可以使用以下方法禁用右轴:

    chart.getAxisRight().setEnabled(false);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-11
      • 1970-01-01
      • 2012-02-04
      • 1970-01-01
      • 1970-01-01
      • 2016-09-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多