Tradition chinese word can not display normally

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Nick Lee

Tradition chinese word can not display normally

Post by Nick Lee » Tue Dec 03, 2002 4:34 am

HI there :

i want to use Tradition chinese words to display my chart title

and the chart title display broken chinese words but the tool tips

can display Tradition chinese words normally and how to solve

this problem??? > <.... anybody can teach me thanks a lot.......

David Gilbert

Re: Tradition chinese word can not display normally

Post by David Gilbert » Wed Dec 04, 2002 12:01 pm

As long as the font you use to display the title supports the characters you have used in the title, there should be no problem. What font are you using?

Regards,

DG

Nick Lee

Re: Tradition chinese word can not display normally

Post by Nick Lee » Thu Dec 05, 2002 6:27 am

dear david:

this is my pie chart sample code , i don't know how to use

font to display the title can u tell me how to .... thanks a lot ..





import com.jrefinery.data.DefaultPieDataset;
import com.jrefinery.chart.ChartFactory;
import com.jrefinery.chart.JFreeChart;
import com.jrefinery.chart.ChartFrame;



public class test {


public static void main(String[] args) {
// create a dataset...
DefaultPieDataset data = new DefaultPieDataset();
data.setValue("國文", new Double(43.2));
data.setValue("英文", new Double(27.9));
data.setValue("數學", new Double(79.5));


// create a chart...
JFreeChart chart = ChartFactory.createPieChart("圓餅圖",data,true); // legend
ChartFrame frame = new ChartFrame("Test", chart);
frame.pack();
frame.setVisible(true);

}
}

Rex Lam

Re: Tradition chinese word can not display normally

Post by Rex Lam » Mon Dec 16, 2002 5:31 am

Hi,

I have tried displaying Big5 chart title with:
String text = "some big5 text";
TextTitle subtitle = new TextTitle(text, new Font("Arial Unicode MS", Font.PLAIN, 12));
chart.addTitle(subtitle);

It can be displayed properly. Please note that you need to download that font, which is about 10MB....

Hope this is what you want

Rex

David Gilbert

Re: Tradition chinese word can not display normally

Post by David Gilbert » Mon Dec 16, 2002 6:10 pm

If you use the ChartFactory class, you chart will get a title in the default font. Changing it is not simple, but it can be done. The getTitles() method in the JFreeChart class will return a list of titles (you'll probably have only one, but it is possible to have many). The main chart title is item zero in this list. You'll need to cast it to TextTitle, then you can use the setFont(...) method in the TextTitle class. Something like this:

TextTitle myTitle = (TextTitle) myChart.getTitles().get(0);
myTitle.setFont(...);

There is also this thread that talks about some changes that will be introduced in 0.9.5 to clean up this messy part of the code:

http://www.object-refinery.com/phorum-3 ... 269&t=5232

Regards,

Dave Gilbert

Locked