I'm using MPAndroidChart to make graphics.
The problem is this, when I have too many items in the caption, it expands leaving the graphic small. Can you create a scroll in the legend instead of expanding it and consequently decreasing the graph?
-----Edit-----
@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_grafico_supervisor);setUpToolbar();if(getIntent().getExtras()!=null){idSupervisor=getIntent().getExtras().getInt("idSupervisor");
nomeSupervisor = getIntent().getExtras().getString("nomeSupervisor");
mes = getIntent().getExtras().getInt("mes");
ano = getIntent().getExtras().getString("ano");
} else{
// Pegar de Singleton carregado em Login
}
configurarCampos();
configurarGrafico();
}
private void configurarCampos(){
mainLayout = (LinearLayout) findViewById(R.id.linearGraficos);
mChart = (PieChart) findViewById(R.id.chart1);
}
private void configurarGrafico(){
List<VendedorMOD> vendedores = new VendedorDAO(getContext()).pesquisarPorData(idSupervisor, MascaraData.fromStringNormal(getDatas()[0]), MascaraData.fromStringNormal(getDatas()[1]));
for(VendedorMOD v : vendedores){
yData.add(v.getValor().doubleValue());
xData.add(v.getNome());
}
// add pie chart to main layout
//mainLayout.setBackgroundColor(Color.GRAY);
// configure pie chart
mChart.setUsePercentValues(true);
mChart.setDescription("");
// enable hole and configure
mChart.setDrawHoleEnabled(true);
mChart.setHoleColorTransparent(true);
mChart.setHoleRadius(7);
mChart.setTransparentCircleRadius(10);
// enable rotation of the chart by touch
mChart.setRotationAngle(0);
mChart.setRotationEnabled(true);
// add data
addData();
// customize legends
Legend l = mChart.getLegend();
l.setPosition(Legend.LegendPosition.BELOW_CHART_CENTER);
l.setXEntrySpace(7);
l.setYEntrySpace(5);
l.setTextSize(10f);
l.setTextColor(Color.BLACK);
l.setFormSize(10f);
// legenda nao cortar na tela
mChart.getLegend().setWordWrapEnabled(true);
mChart.getLegend().setEnabled(false);
}