gpt4 book ai didi

android - MPAndroidChart BarChart 禁用右侧图例

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:49:44 27 4
gpt4 key购买 nike

我需要从 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);

enter image description here

谢谢!

最佳答案

添加这一行

rightAxis.setDrawLabels(false); 

仅隐藏标签

隐藏整个右轴,请调用:

rightAxis.setEnabled(false);

关于android - MPAndroidChart BarChart 禁用右侧图例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29971136/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com