为什么JFreeChart中没有文本? [英] Why is there no text in JFreeChart?
问题描述
JFreeChart似乎可以正常工作,但所有文本除外.它根本不显示,我也不知道为什么.我附上了一个窗口的图片和一个饼图,该饼图是从一个教程站点获得的.如您所见,该文本不可见. (对不起,我的Twitter提要很长)
JFreeChart seems to be working, except for all the text. It just doesn't show up at all, and I've no idea why. I attached a picture of a window with a pie graph that I got from a tutorial site. As you can see, the text isn't visible. (sorry my twitter feed was really long)
感谢
以下是生成以上图形的代码:
Here is the code that generates the above graph:
package analyzer_main;
import java.awt.Font;
public class FloatChart extends Composite implements Screen {
JFreeChart floatChart;
public FloatChart(Composite parent, int style){
super(parent,style);
createContents();
}
private void createContents(){
this.setLayout(new FormLayout());
floatChart = createChart(createDataset());
ChartComposite chartComposite = new ChartComposite(this,SWT.NONE,floatChart, true);
FormData fd_chartComposite = new FormData();
fd_chartComposite.left = new FormAttachment(0);
fd_chartComposite.right = new FormAttachment(100,0);
fd_chartComposite.top = new FormAttachment(0);
fd_chartComposite.bottom= new FormAttachment(100,0);
chartComposite.setLayoutData(fd_chartComposite);
}
/** * Creates the Dataset for the Pie chart */
private PieDataset createDataset() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("One", new Double(43.2));
dataset.setValue("Two", new Double(10.0));
dataset.setValue("Three", new Double(27.5));
dataset.setValue("Four", new Double(17.5));
dataset.setValue("Five", new Double(11.0));
dataset.setValue("Six", new Double(19.4));
return dataset;
}
private JFreeChart createChart(PieDataset dataset) {
JFreeChart chart = ChartFactory.createPieChart("Pie Chart Demo 1", // chart
// title
dataset, // data
true, // include legend
true, false);
PiePlot plot = (PiePlot) chart.getPlot();
plot.setSectionOutlinesVisible(false);
plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
plot.setNoDataMessage("No data available");
plot.setCircular(false);
plot.setLabelGap(0.02);
return chart;
}
@Override
public void Load() {
}
}
如您所见,它与本教程中的内容几乎相同.
As you can see, it's pretty much the same as from the tutorial.
推荐答案
我在使用Linux Mint 11,Eclipse和JFreeChart 1.0.14时遇到了同样的问题.我发现备份到1.0.13可以解决问题.
I was having the same problem using Linux Mint 11, Eclipse, and JFreeChart 1.0.14. I found that backing up to 1.0.13 resolved the problem.
这篇关于为什么JFreeChart中没有文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!