我使用以下代码生成带垂直模式的条形图。我已附上截图。标签显示不清楚,如何清晰显示?
Tabs chartTabs = new Tabs();
chartTabs.setPreferredH(screenHeight/2);
chartTabs.addTab("", icon1, new BarChartGenerator().getBarChart(dealersNames, dealersValues));
public Component getBarChart(ArrayList<ArrayList<String>> nameList, ArrayList<ArrayList<Double>> valueList) {
String[] titles = new String[]{"2017"};
XYMultipleSeriesRenderer renderer = buildBarRenderer(colors);
renderer.setOrientation(Orientation.VERTICAL);
double largeValue = getMax(valueList.get(0)) * 1.1;
System.out.println(" large " + largeValue);
int nameSize = 0;
for (ArrayList<String> nameArray : nameList) {
int index = 0;
nameSize = nameArray.size();
for (String name : nameArray) {
// if ((index / 2) != 0) {
renderer.addXTextLabel(index + 1, name);
index++;
// }
}
}
// nameSize =
int endXValue = (int) (nameSize + 1);
setChartSettings(renderer, "", "", "", 0,
endXValue, 0, largeValue, ColorUtil.GREEN, ColorUtil.GREEN);
renderer.setXLabels(1);
renderer.setYLabels(8);
initRendererer(renderer);
int length = renderer.getSeriesRendererCount();
for (int i = 0; i < length; i++) {
XYSeriesRenderer seriesRenderer = (XYSeriesRenderer) renderer.getSeriesRendererAt(i);
seriesRenderer.setDisplayChartValues(true);
}
// renderer.setYLabelsAlign(Component.LEFT);
renderer.setXLabelsAlign(Component.RIGHT);
renderer.setXLabelsAngle(0);
// renderer.setXAxisMax(10);
renderer.setShowTickMarks(true);
// renderer.setBarWidth(50);
// renderer.setYAxisAlign(Component.CENTER);
BarChart chart = new BarChart(buildBarDataset2(titles, valueList), renderer,
Type.DEFAULT) {
@Override
public void draw(Canvas canvas, int x, int y, int width, int height, Paint paint) {
super.draw(canvas, width / 4, y, width, height, paint); //To change body of generated methods, choose Tools | Templates.
}
};
return newChart(chart);
}