【问题标题】:MPAndroidChart BarChart disable right legendsMPAndroidChart BarChart 禁用右图例
【发布时间】:2015-04-30 14:59:46
【问题描述】:

我需要从BarChart 中删除正确的图例。

这是我的代码。

    mChart = (BarChart) rootView.findViewById(R.id.chart1);
    mChart.setOnChartValueSelectedListener(this);
    mChart.setDrawBarShadow(false);
    mChart.setDrawValueAboveBar(true);
    mChart.setDescription("");
    mChart.setMaxVisibleValueCount(60);
    mChart.setPinchZoom(false);
    mChart.setDrawGridBackground(false);
    mTf = Typeface.createFromAsset(getActivity().getAssets(), "OpenSans-Regular.ttf");

    XAxis xAxis = mChart.getXAxis();
    xAxis.setPosition(XAxisPosition.BOTTOM);
    xAxis.setTypeface(mTf);
    xAxis.setDrawGridLines(false);
    xAxis.setSpaceBetweenLabels(2);

    ValueFormatter custom = new MyValueFormatter();

    YAxis leftAxis = mChart.getAxisLeft();
    leftAxis.setTypeface(mTf);
    leftAxis.setLabelCount(8);
    leftAxis.setValueFormatter(custom);
    leftAxis.setPosition(YAxisLabelPosition.OUTSIDE_CHART);
    leftAxis.setSpaceTop(15f);

    Legend l = mChart.getLegend();
    l.setPosition(LegendPosition.BELOW_CHART_LEFT);
    l.setForm(LegendForm.SQUARE);
    l.setFormSize(9f);
    l.setTextSize(11f);
    l.setXEntrySpace(4f);

    mChart.animateXY(3000, 3000);

谢谢!

【问题讨论】:

    标签: android mpandroidchart


    【解决方案1】:

    添加这一行

    rightAxis.setDrawLabels(false); 
    

    仅隐藏标签

    对于隐藏整个右轴,调用:

    rightAxis.setEnabled(false);
    

    【讨论】:

      【解决方案2】:

      一个简单的班轮:

      chart.getAxisRight().setEnabled(false);
      

      【讨论】:

        【解决方案3】:

        对于那些使用 Kotlin 语言的人:

        chart.axisRight.isEnabled = false
        

        希望对你有帮助!

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2023-04-08
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多