我是JFreeChart的新手。
附上我的图表。如您所见,标签被截断。如何指定标签的宽度以避免截断(我有足够的空间来容纳它们)?
我目前的代码如下:
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.setValue(24, "Major", "Mathematics");
dataset.setValue(20, "Major", "Philosophy");
dataset.setValue(18, "Major", "Chemical Engineering");
dataset.setValue(15, "Major", "Sociology");
dataset.setValue(14, "Major", "Stuff");
dataset.setValue(13, "Major", "A Program");
dataset.setValue(13, "Major", "Bleg");
JFreeChart chart = ChartFactory.createBarChart(" ", "Major", "Score", dataset, PlotOrientation.HORIZONTAL,
false, true, false);
CategoryPlot plot = chart.getCategoryPlot();
Font font1 = new Font("Dialog", Font.PLAIN, 25);
Font font2 = new Font("Dialog", Font.PLAIN, 15);
Font font3 = new Font("Dialog", Font.PLAIN, 25);
plot.getDomainAxis().setLabelFont(font3);
plot.getRangeAxis().setLabelFont(font3);
CategoryAxis axisDomain = plot.getDomainAxis();
ValueAxis axisRange = plot.getRangeAxis();
axisDomain.setTickLabelFont(font1);
axisRange.setTickLabelFont(font2);
chart.setAntiAlias(true);
答案 0 :(得分:3)
在建议的here方法中,以下示例会覆盖if ( (x-c0|c0-x) & (x-c1|c1-x) & ... & (x-cn|cn-x) & 0x80) {
// x is not equal to any ci
。
getPreferredSize()