HighLow renderer renders open/close ticks too large

Discussion about JFreeChart related to stockmarket charts.
Locked
korvus
Posts: 5
Joined: Mon Apr 28, 2008 7:14 pm

HighLow renderer renders open/close ticks too large

Post by korvus » Mon Apr 28, 2008 7:37 pm

I am rendering some stock charts to PDF. I almost have it working, but when I have too many data points in the chart, it renders the open/close ticks so large that they overlap a number of data points on either side.

Is there a way to customize the size of the ticks that stick out from the HighLow items? It looks like I need to modify HighLowRenderer.java, and change:

double delta = 2.0;

into something smaller. Obviously I'd prefer not to do that.

korvus
Posts: 5
Joined: Mon Apr 28, 2008 7:14 pm

Post by korvus » Mon Apr 28, 2008 7:38 pm

Here's an example.
Full chart: korvus.net/stockchart.png
Closeup of ticks: korvus.net/stockchart_closeup.png

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Apr 29, 2008 11:47 am

Yes, that's not great. Would it be sufficient to have an attribute for the 'delta', so you can set the absolute length of the open and close indicators, instead of it being hardcoded as 2.0?
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

korvus
Posts: 5
Joined: Mon Apr 28, 2008 7:14 pm

Post by korvus » Tue Apr 29, 2008 2:48 pm

Yeah, I think that would be fine. While I'd love for the "delta" to be calculated on the fly, that might not make sense for most applications.

Honestly, if I was rendering this chart to a PNG or the screen, I suspect 2.0 renders as 2 pixels, so I really wouldn't be able to shrink it too much. The fact that I'm writing it to PDF means that when I decided yesterday to hard-code it to 0.4, I can still see them fine. But I suspect many people don't render to PDF/SVG, so they probably wouldn't want it to be set below 1.0. As such, just the ability to change it without modifying the code would provide the necessary power with only a few lines of code.

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Post by david.gilbert » Tue Apr 29, 2008 4:05 pm

I'd like to calculate the tick length on the fly, but I'm not sure what the best way to do it is. It seems obvious, when you see some daily data against a linear axis - but then there can be gaps in the data (Friday to Monday), and when the number of observations is low, you probably don't want the tick marks to extend all the way between observations.

Well, for now I've just added getTickLength() and setTickLength() methods (to be included in the 1.0.10 release).
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

korvus
Posts: 5
Joined: Mon Apr 28, 2008 7:14 pm

Post by korvus » Tue Apr 29, 2008 4:11 pm

I completely understand the issue. Back in 2001 or so, I wrote a Java program to graph sensor data, and wrote the graph engine from scratch. Even with a pretty constrained application, it was still pretty daunting.

I appreciate you adding that functionality in. I really don't want to maintain my own branch of the JFreeChart code, and adding that ability means I won't have to. Thanks!

Locked