dashed lines effect gets lost as points increase DEFECT??

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
prolaznik22
Posts: 11
Joined: Fri Feb 03, 2006 9:27 pm

dashed lines effect gets lost as points increase DEFECT??

Post by prolaznik22 » Wed Jul 12, 2006 9:09 pm

Hi,

I have noticed that as the number of points increases, the dashing line effect gets lost completely (I am using the latest JFreeChart). The reason for this problem is that dashing effect occcurs only between points not throughout the whole line. Thus, as the number of points increase, the effect gets unnoticeable. Is it possible to set dashing effect over the whole line?

Playing with stroke does not help since the effect takes place between points as mentioned :(

Look at the images below:

Good image:
[img]
http://images6.theimagehosting.com/dash ... ood.th.gif
[/img]

Bad image:
[img]
http://images6.theimagehosting.com/dash ... bad.th.gif
[/img]

[/code]

ladislav.petera
Posts: 1
Joined: Mon Dec 18, 2006 12:02 pm
Location: Germany

Solution

Post by ladislav.petera » Mon Dec 18, 2006 12:11 pm

Hi,

I have had the same problem and decompilation of the library code has shown me, that there is an parameter of the XYLineAndShapeRenderer which decides whether the serie is rendered as path or as a couple of lines.

The default setting is rendering is to draw single lines between the points. This makes troubles with the dashed lines though the renderer always starts the line from the dashPhase of your dashPattern. If you have for example a dashpattern (10f, 10f) and dashPhase 0f and paint a lot of lines shorter that 10f, you will get a solid line.

By setting the setDrawSeriesLineAsPath parameter of the XYLineAndShapeRenderer to true, you cause the chart to create one single shape and render it at once. This creates nice dashed lines.

I can only guess why this is not the default settings - may be performance optimization, may be just not thought about?

Here some sample code:

Code: Select all

XYItemRenderer r = getChart().getXYPlot().getRenderer();
if (r instanceof XYLineAndShapeRenderer) {
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer)r;
    renderer.setDrawSeriesLineAsPath(true);
}
regards
Ladi

Locked