Hi
How can i set Label font in pie chart, i tries these
PiePlot.setLabelFont() will set fonts for the labels of each Section of pie,
chart.getLegent().setItemFont() will set font for the legends...
but i didn't any thing for Labels written below the pie charts.
[img]
http://122.166.11.56/rdg43628.png
[/img]
in this chart label 2008/06/01 --- AUM is not coming proper because character between date and "AUM" is not supported by the font being used, so i need to change font for this Label.
Thanks in Advance
How to set font of Label in PIE chart
-
- Posts: 58
- Joined: Mon Dec 15, 2008 7:07 am
- Location: India
- Contact:
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: How to set font of Label in PIE chart
The text with the ___aum looks like the chart title or a subtitle, in any case it should be a TextTitle. You can change the font of that title by calling title.setFont(Font f);.
-
- Posts: 58
- Joined: Mon Dec 15, 2008 7:07 am
- Location: India
- Contact:
Re: How to set font of Label in PIE chart
Hi
Thanks for reply,
I tried 1st with title and here is the code i have written
But this didn't work, then i went for subtitle thing
but this is giving exception "ClassCastException", because subtitle is of Title class and not TextTile.
So useing proper class casing i.e. using Title we can't set Font becasue setFont() Method is not suported by
Title or LegendTitle class.
please let me know i did some thing worng....
and what else i can do to make it working....?
Thanks for reply,
I tried 1st with title and here is the code i have written
Code: Select all
TextTitle title = jf.getTitle();
title.setFont(new Font("Arial Unicode MS", 0, 6));
Code: Select all
TextTitle subtitle;
for(int ix=0; ix<jf.getSubtitleCount(); ix++){
subtitle = (TextTitle) jf.getSubtitle(ix);
subtitle.setFont(new Font("Arial Unicode MS", 0, 1));
}
So useing proper class casing i.e. using Title we can't set Font becasue setFont() Method is not suported by
Title or LegendTitle class.
please let me know i did some thing worng....
and what else i can do to make it working....?
Abhay Singh
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: How to set font of Label in PIE chart
I was not saying that every subtitle of the chart is a TextTitle. In fact, the list with subtitles also includes the legend.
I meant that the title in question (with the "__AUM") is (most certainly) a TextTitle, and you should be abale to use the setFont(Font font) method.
W/o the source code, it is difficult to clarify the origin of the title in question, its type and finally possible ways to change its font.
I meant that the title in question (with the "__AUM") is (most certainly) a TextTitle, and you should be abale to use the setFont(Font font) method.
W/o the source code, it is difficult to clarify the origin of the title in question, its type and finally possible ways to change its font.
-
- Posts: 58
- Joined: Mon Dec 15, 2008 7:07 am
- Location: India
- Contact:
Re: How to set font of Label in PIE chart
Hi
Here is the code i am using for this pie chart
and here is the dataset
スキームコード | 2008/06/01 クロージングAUM
____________________________________________
203G | 6633002453.85
01D | 4521770890.79
01G | 3070528801.82
205WD | 2434769907.68
205G | 1553560002.39
03G | 1362684340.35
03D | 1131688973
202DD | 781813522.38
04G | 772943715
02G | 450065100
_______________________________________________
As you see, one of heading of dataset is "2008/06/01 クロージング AUM", this is what i am printing below my pie chart, because of font its showing square box instead of actual string, that is why i want to set its font which support this language(japanease).
Thanks for your time.
Here is the code i am using for this pie chart
Code: Select all
jf = ChartFactory.createMultiplePieChart("", (CategoryDataset) dataset[0], TableOrder.BY_ROW, true, true, true);
MultiplePiePlot mp = (MultiplePiePlot) jf.getPlot();
JFreeChart jc = mp.getPieChart();
PiePlot pp = (PiePlot) jc.getPlot();
pp.setLabelGenerator(new StandardPieSectionLabelGenerator( "{0} ({2})", NumberFormat.getNumberInstance(), NumberFormat.getPercentInstance()));
pp.setLabelFont(new Font("Arial Unicode MS", 0, 10));
pp.setSectionOutlinesVisible(true);
pp.setBaseSectionOutlinePaint(new Color(0xFFFFFF));
pp.setBaseSectionOutlineStroke(new BasicStroke(2F));
jf.getLegend().setItemFont(new Font("Arial Unicode MS", 0, 10));
TextTitle title = jf.getTitle();
title.setFont(new Font("Arial Unicode MS", 0, 6));
TextTitle subtitle;
for(int ix=0; ix<jf.getSubtitleCount(); ix++){
subtitle = (TextTitle) jf.getSubtitle(ix);
log.debug("subtitle="+subtitle);
subtitle.setFont(new Font("Arial Unicode MS", 0, 1));
}
pp = null;
スキームコード | 2008/06/01 クロージングAUM
____________________________________________
203G | 6633002453.85
01D | 4521770890.79
01G | 3070528801.82
205WD | 2434769907.68
205G | 1553560002.39
03G | 1362684340.35
03D | 1131688973
202DD | 781813522.38
04G | 772943715
02G | 450065100
_______________________________________________
As you see, one of heading of dataset is "2008/06/01 クロージング AUM", this is what i am printing below my pie chart, because of font its showing square box instead of actual string, that is why i want to set its font which support this language(japanease).
Thanks for your time.
Abhay Singh
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: How to set font of Label in PIE chart
OK, now we no longer talk about a PiePlot but about a MultiplePiePlot which is a different thing.
As discussed in one of your previous threads, a MultiplePiePlot has an "internal JFreeChart" which in turn has an internal PiePlot. The "internal" JFreeChart/PiePlot combination is used to draw the individual PiePlots of the MultiplePiePlot.
The title in question is the chart title of the "internal JFreeChart" which can be accessed by (following your code fragment above)
As discussed in one of your previous threads, a MultiplePiePlot has an "internal JFreeChart" which in turn has an internal PiePlot. The "internal" JFreeChart/PiePlot combination is used to draw the individual PiePlots of the MultiplePiePlot.
The title in question is the chart title of the "internal JFreeChart" which can be accessed by (following your code fragment above)
Code: Select all
jc.getTitle();//NOT jf!!
-
- Posts: 58
- Joined: Mon Dec 15, 2008 7:07 am
- Location: India
- Contact:
Re: How to set font of Label in PIE chart
Hi
Thanks alot, this works fine....
i know this point but don't know why i forgot this... once again thanks for helping me out.
Thanks alot, this works fine....
i know this point but don't know why i forgot this... once again thanks for helping me out.
Abhay Singh