Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
692 views
in Technique[技术] by (71.8m points)

android - How to hide legends and axis in MPAndroidChart?

Is their any possibility to hide all rounded items from this picture.

enter image description here

I have used the following code,

public void setDataList(List<HorizontalBarChartData> dataList, Resources resources) {

    ArrayList<String> categories = new ArrayList<String>();
    ArrayList<BarEntry> values = new ArrayList<BarEntry>();
    ArrayList<BarDataSet> dataSets = new ArrayList<BarDataSet>();
    BarDataSet set1;
    for (int i = 0; i < dataList.size(); i++) {
        categories.add(dataList.get(i).getName());
        values.add(new BarEntry(dataList.get(i).getValue(), i));
    }

    /*set1 = new BarDataSet(values, "Income, Expense, Disposable Income");*/
    set1 = new BarDataSet(values, "Category 1, Category 2, Category 3");
    set1.setBarSpacePercent(35f);
    set1.setColors(new int[]{resources.getColor(R.color.cyan_blue), resources.getColor(R.color.vermilion_tint), resources.getColor(R.color.sea_green)});
    dataSets.add(set1);

    BarData data = new BarData(categories, dataSets);
    data.setValueTextSize(10f);

    horizontalBarChart.setData(data);
}

Update

How to hide rounded part from this image?

enter image description here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, is possible, just using following code:

mChart.setDescription("");    // Hide the description
mChart.getAxisLeft().setDrawLabels(false);
mChart.getAxisRight().setDrawLabels(false);
mChart.getXAxis().setDrawLabels(false);

mChart.getLegend().setEnabled(false);   // Hide the legend 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...