Help for line chart

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
bill_chuang
Posts: 4
Joined: Wed Sep 14, 2016 4:31 am
antibot: No, of course not.

Help for line chart

Post by bill_chuang » Wed Sep 14, 2016 4:54 am

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!

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Help for line chart

Post by paradoxoff » Wed Sep 14, 2016 10:26 am

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?
No. You could try to create a new Title that is using an AttributedString.
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?
Only by overriding getItemLabelFont(int, int) in the renderer and returning an individual Font 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?
Same approach as above: override getPositiveItemLabelPosition(int, int) in the renderer and return an individual ItemLabelPosition based on the column index.

bill_chuang
Posts: 4
Joined: Wed Sep 14, 2016 4:31 am
antibot: No, of course not.

Re: Help for line chart

Post by bill_chuang » Thu Sep 15, 2016 2:13 am

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.

paradoxoff
Posts: 1634
Joined: Sat Feb 17, 2007 1:51 pm

Re: Help for line chart

Post by paradoxoff » Mon Sep 19, 2016 10:49 am

I don't understand the question. Do you have an image that indicates which objects are misaligned?

bill_chuang
Posts: 4
Joined: Wed Sep 14, 2016 4:31 am
antibot: No, of course not.

Re: Help for line chart

Post by bill_chuang » Fri Sep 23, 2016 6:32 am

paradoxoff wrote:I don't understand the question. Do you have an image that indicates which objects are misaligned?
I've solved this question. Thanks very much.
But I don't know how to upload an img in this forum. Using Img element?

Locked