嗨,请帮我删除图表和设置栏之间的空格 酒吧非常接近。尝试了很多方法。有人有解决方案, 请建议我。谢谢。以下是我的代码。
void drawChart(String[] items, float[] amount){
XYMultipleSeriesRenderer mRenderer = new XYMultipleSeriesRenderer();
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
XYSeries[] qtySeries = new XYSeries[amount.length];
XYSeriesRenderer[] qtyRenderer = new XYSeriesRenderer[amount.length];
for(int i=0;i<amount.length ;i++){
qtySeries[i] = new XYSeries("");
qtySeries[i].add(i,amount[i]);
dataset.addSeries(qtySeries[i]);
qtyRenderer[i] = new XYSeriesRenderer();
qtyRenderer[i].setColor(color[i]);
qtyRenderer[i].setDisplayChartValues(true);
qtyRenderer[i].setChartValuesTextSize(15);
qtyRenderer[i].setChartValuesSpacing(22);
mRenderer.addSeriesRenderer(qtyRenderer[i]);
mRenderer.addXTextLabel(i+1, items[i]);
}
float max=amount[0];
for (int i = 0; i < amount.length; i++) {
if (amount[i] > max) {
max = amount[i];
}
}
mRenderer.setYAxisMax(max + 20);
mRenderer.setOrientation(XYMultipleSeriesRenderer.Orientation.VERTICAL);
mRenderer.setBarWidth(40f);
mRenderer.setMarginsColor(Color.WHITE);
mRenderer.setAxesColor(Color.BLACK);
mRenderer.setBarSpacing(0.5);
mRenderer.setShowLegend(false);
mRenderer.setPanEnabled(true, false);
mRenderer.setZoomEnabled(false,false);
mRenderer.setXLabelsColor(Color.WHITE);
mRenderer.setYLabelsColor(0,Color.WHITE);
mRenderer.setXLabelsPadding(0.0f);
mRenderer.setYAxisMin(0);
mRenderer.setBarSpacing(0.0f);
lLytHourlyChart.removeAllViews();
lLytHourlyChart.addView(ChartFactory.getBarChartView(getActivity(), dataset, mRenderer, BarChart.Type.DEFAULT));
}
答案 0 :(得分:0)
添加条间距
mRenderer.setBarSpacing(-1);