Highlow / bar chart customization
Highlow / bar chart customization
Hi.
Hope this is the correct place for a new question regarding the JFreechart API. And apologies if there is already an answer in the forum.
I am creating a report (using jasper reports server) that requires bars on an x axis. Each bar has a high value and a low value on the y axis. So the bars would float in the chart (similar to a high low chart). Each bar will represent a day in the month (along the x axis).
It is similar to a high low chart but simpler (no open/close, etc) and I also require a bars not lines. Eventually I would like to add a line or circle on the bar where another data point resides (so there are three values: high, low, middle).
I intend to build a jasper reports server customizer to help me do this. I was going to use a bar chart as the basis and then add a new renderer through the customizer. I would like to know if this is the correct chart to use and correct approach. I will probably start by trying to get this to work as a plain Java code first before migrating into jasper reports server.
I'm not sure if anything like this already exists, so any advice welcome.
Thanks.
Hope this is the correct place for a new question regarding the JFreechart API. And apologies if there is already an answer in the forum.
I am creating a report (using jasper reports server) that requires bars on an x axis. Each bar has a high value and a low value on the y axis. So the bars would float in the chart (similar to a high low chart). Each bar will represent a day in the month (along the x axis).
It is similar to a high low chart but simpler (no open/close, etc) and I also require a bars not lines. Eventually I would like to add a line or circle on the bar where another data point resides (so there are three values: high, low, middle).
I intend to build a jasper reports server customizer to help me do this. I was going to use a bar chart as the basis and then add a new renderer through the customizer. I would like to know if this is the correct chart to use and correct approach. I will probably start by trying to get this to work as a plain Java code first before migrating into jasper reports server.
I'm not sure if anything like this already exists, so any advice welcome.
Thanks.
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Highlow / bar chart customization
You might look at MinMaxCategoryRenderer, seen among the Statistical Charts in the demo.
Re: Highlow / bar chart customization
Thanks John,
That certainly helped. I purchased the developer's guide which also helped hugely. I would prefer a 'bar' rather than a line with bobbles at each end. I'll see if I can increase the width of the line and remove the bobbles and I think change the way the min/max/middle are rendered.
G.
That certainly helped. I purchased the developer's guide which also helped hugely. I would prefer a 'bar' rather than a line with bobbles at each end. I'll see if I can increase the width of the line and remove the bobbles and I think change the way the min/max/middle are rendered.
G.
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Highlow / bar chart customization
Excellent. There's a minimal setObjectIcon() example here. I haven't tried it, but setGroupStroke() looks promising for the line thickness.
Re: Highlow / bar chart customization
Hi John,
It's really good and has expanded my knowledge of how to use this amazing API! I purchased the development guide which is worth its weight in gold. However, I would like to change the order of the rendering so that the icons are rendered on top of the line / bar (setting the stroke widens the bar width hiding the icons). Aside from re-writing the drawItem method in the MinMaxCategoryRenderer, do you know of a way to do this?
It's really good and has expanded my knowledge of how to use this amazing API! I purchased the development guide which is worth its weight in gold. However, I would like to change the order of the rendering so that the icons are rendered on top of the line / bar (setting the stroke widens the bar width hiding the icons). Aside from re-writing the drawItem method in the MinMaxCategoryRenderer, do you know of a way to do this?
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Highlow / bar chart customization
Given a choice, I'd implement a custom Icon, rather than rewriting the drawItem() method. You may have to try both to see which looks better.
Re: Highlow / bar chart customization
Thanks John. It's all a bit new to me. Will a custom icon allow me to render on top of the line? Or rather something such as a little pointy arrow to the left for example?
-
- Posts: 513
- Joined: Wed Sep 12, 2007 3:18 pm
Re: Highlow / bar chart customization
I'm pretty sure the order is fixed by drawItem(). Your Icon idea sounds right, but also look a the available org.jfree.chart.annotations.
Re: Highlow / bar chart customization
Thanks for all your help and suggestions, John.
I've ended up writing my own render class because we need other additional behaviour. It's a great exercise in understanding the API and libraries and really enjoyable! I'll look at annotations!
I've ended up writing my own render class because we need other additional behaviour. It's a great exercise in understanding the API and libraries and really enjoyable! I'll look at annotations!