2015-04-30 5 views
9

Ho bisogno di rimuovere le legende di destra da BarChart.MPAndroidChart BarChart disabilita le legende di destra

Questo è il mio codice.

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

Grazie!

risposta

25

Aggiungi questa linea

rightAxis.setDrawLabels(false); 

Per nascondere solo le etichette.

Per nasconde tutta la destra dell'asse, chiamare:

rightAxis.setEnabled(false); 
+0

è una buona risposta. basta segnarlo già – msecilmis

+0

Fatto. È segnato – benoffi7