Dashed lines don't appear when using ChartViewer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
SystemsEngineer
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm
antibot: No, of course not.

Dashed lines don't appear when using ChartViewer

Post by SystemsEngineer » Wed Mar 15, 2017 1:15 pm

Hello,

I am using JFreeChart with JavaFX.
For the needs of my application I have to redraw the whole chart several times. At the first time, all chart functions (zooming, panning, etc.) perform pretty well. However, after several times of redrawing, these functionalities become very sluggish. Keep in mind that every time I redraw the chart, I create everything from scratch (ChartViewer, Chart, etc.), so I cannot find a good reason why this gradual slow down is happening.

My second problem is quite strange. When I try to use dashed lines in my TimeSeries chart, they appear as solid lines, or to be more precise, they appear as two lines, one dashed and one solid on top of the dashed one! When I save the plot as jpeg for example, dashed lines appear correctly! I guess there must be a problem with the ChartViewer (but I can't detect where!) since outside JavaFX, dashed lines work properly using the exact same code.
I have also used setDrawSeriesLineAsPath() with both TRUE and FALSE arguments without any change.

I would appreciate a lot any help or ideas on these two issues.
Last edited by SystemsEngineer on Thu Mar 16, 2017 10:36 am, edited 1 time in total.

John Matthews
Posts: 513
Joined: Wed Sep 12, 2007 3:18 pm

Re: Slow chart functionalities and dashed lines don't appear

Post by John Matthews » Thu Mar 16, 2017 3:14 am

Profile your application to help isolate performance problems. Also, note that JPEG typically loses some detail during compression; try PNG instead, as suggested here.

SystemsEngineer
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm
antibot: No, of course not.

Re: Slow chart functionalities and dashed lines don't appear

Post by SystemsEngineer » Thu Mar 16, 2017 10:35 am

Thanks a lot for your reply!

I managed to solve my performance issue.

As far as the dashed lines problem, I wrote that as saved jpeg image, the dashed lines of my JFreeChart appear as they should. The problem is when the chart is drawn and appeared within a ChartViewer in my application (I use JavaFX). In this case, the dashed lines are covered by solid ones in a strange way. I guess it is a ChartViewer bug since outside JavaFX, JFreeChart shows dashed lines properly.

Any other possible fix ideas are welcome :)

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

Re: Dashed lines don't appear when using ChartViewer

Post by david.gilbert » Thu Mar 16, 2017 3:39 pm

Are you using the JFreeChart 1.0.19 release version, or the latest code from GitHub?

I will try to reproduce the problem, but if you have a small self contained demo program that you can post that will speed things up.
David Gilbert
JFreeChart Project Leader

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

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

Re: Dashed lines don't appear when using ChartViewer

Post by david.gilbert » Thu Mar 16, 2017 3:47 pm

Also, looking in the FXGraphics2D code, it looks like support for dashed lines was added in version 1.2.1. You should have that, but it is worth checking. Look in the source code for the setStroke() method and see if it has code for dashed lines in there.
David Gilbert
JFreeChart Project Leader

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

SystemsEngineer
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm
antibot: No, of course not.

Re: Dashed lines don't appear when using ChartViewer

Post by SystemsEngineer » Thu Mar 16, 2017 5:45 pm

Thanks for the quick response!

You are right I was using the FXGraphics2D.java from release 1.0.19 (didn't know about the updates...). After updating it with the new code it works fine!

Locked