legend problem?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
pubmail75
Posts: 6
Joined: Mon Oct 20, 2003 2:23 am

legend problem?

Post by pubmail75 » Thu Oct 23, 2003 2:04 pm

I use JFreeChart create a chart,such as:JFreeChart chart = new JFreeChart(chinese.getStr(PartName[0]), JFreeChart.DEFAULT_TITLE_FONT, plot, true)
I must use chart.setLegend(Null) , otherwise there is some error.But I want display Legend! How can I do?Can give me some examples?
I'm a rookie for JFreeChart?
by way,I use jfreechart-0.9.13!

Thank a lot!

pubmail75
Posts: 6
Joined: Mon Oct 20, 2003 2:23 am

error code

Post by pubmail75 » Fri Oct 24, 2003 2:11 am

Exception - java.lang.NullPointerException
java.lang.NullPointerException
at java.awt.Font.getLineMetrics(Font.java:1621)
at java.awt.FontMetrics.getLineMetrics(FontMetrics.java:396)
at org.jfree.chart.StandardLegend.createDrawableLegendItem(Unknown Sourc
e)
at org.jfree.chart.StandardLegend.draw(Unknown Source)
at org.jfree.chart.StandardLegend.draw(Unknown Source)
at org.jfree.chart.JFreeChart.draw(Unknown Source)
at org.jfree.chart.JFreeChart.createBufferedImage(Unknown Source)
at org.jfree.chart.ChartUtilities.writeChartAsPNG(Unknown Source)
at org.jfree.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at org.jfree.chart.ChartUtilities.saveChartAsPNG(Unknown Source)
at org.jfree.chart.servlet.ServletUtilities.saveChartAsPNG(Unknown Sourc
e)
at com.ieslab.e200.chart.WebDisplayChart.generateXYChart(WebDisplayChart
.java:283)
at com.ieslab.e200.chart.WebDisplayChart.main(WebDisplayChart.java:400)
filename - public_error_500x300.png

minal
Posts: 2
Joined: Thu Oct 30, 2003 1:37 pm

Re: legend problem?

Post by minal » Thu Oct 30, 2003 1:49 pm

Hi,

try this,
Step 1:
Create an object of JfreeChart:
JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT,plot,true);


the legend is displayed if Step1 is done. Incase it does not, go for Step2 also.
Step2:
jfreechart.setLegend(Legend.createInstance(jfreechart));

good luck :)
Thanx & Best Regards,
Minal

pubmail75
Posts: 6
Joined: Mon Oct 20, 2003 2:23 am

Thanks

Post by pubmail75 » Fri Oct 31, 2003 1:30 am

Thank a lot!It's JDK's problem!It supports chinese no good!
Thanks again!

Locked