Dashed lines don't appear when using ChartViewer

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

Dashed lines don't appear when using ChartViewer

Postby 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.
SystemsEngineer
 
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm

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

Postby 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.
John Matthews
 
Posts: 346
Joined: Wed Sep 12, 2007 3:18 pm

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

Postby 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 :)
SystemsEngineer
 
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm

Re: Dashed lines don't appear when using ChartViewer

Postby 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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11620
Joined: Fri Mar 14, 2003 10:29 am

Re: Dashed lines don't appear when using ChartViewer

Postby 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: Ask your company to buy the JFreeChart Developer Guide
:idea: Check out other products sold by my company Object Refinery Limited
david.gilbert
JFreeChart Project Leader
 
Posts: 11620
Joined: Fri Mar 14, 2003 10:29 am

Re: Dashed lines don't appear when using ChartViewer

Postby 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!
SystemsEngineer
 
Posts: 16
Joined: Thu Jan 19, 2017 5:54 pm


Return to JFreeChart

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests

cron