I encountered a few troublesome difficulties to create a customizing line chart. My jFreeChart version is 1.0.13 and my chart will be saved to a png image.
I use ChartFactory.createLineChart() to create a line chart.
1. I want to use 2 kinds of font for primary title, but I found that TextTitle.setFont() method can only set one font, so is it capable?
2. I want to customize each item label's font of a series respectively, but LineAndShapeRenderer.setSeriesItemLabelFont() method will set all item label to one font, so are there solutions to setting item labels' font respectively?
3. I want to customize each item label's position of a series respectively, but LineAndShapeRender.setSeriesPositiveItemLabelPosition() method can only set all item labels' position, so are there solutions to setting item labels' position respectively?
So any professional can help me?
Thanks very much!
Help for line chart
-
- Posts: 4
- Joined: Wed Sep 14, 2016 4:31 am
- antibot: No, of course not.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Help for line chart
No. You could try to create a new Title that is using an AttributedString.bill_chuang wrote: 1. I want to use 2 kinds of font for primary title, but I found that TextTitle.setFont() method can only set one font, so is it capable?
Only by overriding getItemLabelFont(int, int) in the renderer and returning an individual Font based on the column index.bill_chuang wrote: 2. I want to customize each item label's font of a series respectively, but LineAndShapeRenderer.setSeriesItemLabelFont() method will set all item label to one font, so are there solutions to setting item labels' font respectively?
Same approach as above: override getPositiveItemLabelPosition(int, int) in the renderer and return an individual ItemLabelPosition based on the column index.bill_chuang wrote: 3. I want to customize each item label's position of a series respectively, but LineAndShapeRender.setSeriesPositiveItemLabelPosition() method can only set all item labels' position, so are there solutions to setting item labels' position respectively?
-
- Posts: 4
- Joined: Wed Sep 14, 2016 4:31 am
- antibot: No, of course not.
Re: Help for line chart
WOW! Thanks for your advices very much which help me realize my features perfectly. To solve the first problem previous mentioned, I extend the TextTitle class, overriding the drawHorizontial() method, as a result, it's nice.
But I have an another problem: Default chart's each tick, tick label of X axis and their corresponding item shape (point) of value is aligned vertically. But now my requirement needs me to let tick label and item shape aligned vertically and at the center between the tick and former tick.
The first thought comes to me is shift the tick right. But I don't find related methods to realize it.
Now I want to override the related method to redraw category axis.
So do you have some advice?
Thank you.
But I have an another problem: Default chart's each tick, tick label of X axis and their corresponding item shape (point) of value is aligned vertically. But now my requirement needs me to let tick label and item shape aligned vertically and at the center between the tick and former tick.
The first thought comes to me is shift the tick right. But I don't find related methods to realize it.
Now I want to override the related method to redraw category axis.
So do you have some advice?
Thank you.
-
- Posts: 1634
- Joined: Sat Feb 17, 2007 1:51 pm
Re: Help for line chart
I don't understand the question. Do you have an image that indicates which objects are misaligned?
-
- Posts: 4
- Joined: Wed Sep 14, 2016 4:31 am
- antibot: No, of course not.
Re: Help for line chart
I've solved this question. Thanks very much.paradoxoff wrote:I don't understand the question. Do you have an image that indicates which objects are misaligned?
But I don't know how to upload an img in this forum. Using Img element?