jfree / jfreechart

A 2D chart library for Java applications (JavaFX, Swing or server-side).
http://www.jfree.org/jfreechart/
GNU Lesser General Public License v2.1
1.22k stars 462 forks source link

Update to V 1.5.3: chart titles moved to left/right #291

Open JDBC-0 opened 2 years ago

JDBC-0 commented 2 years ago

We upgraded from V 1.0.17 to V 1.5.3. For some Fonts, the chart titles moved to the left or right. As we have chart titles aligned to the right boorder, this led to cut of chart titles! This occurs dependend on the used font. Somehow, JFreeChart 1.5.x changed the generation of the chart titles so that they are misplaced compared to the previous V1.0.x version.

trashgod commented 2 years ago

I frequently migrate charts from v1.0.19 to v1.5.x with the default fonts, but I haven't encountered this. Do you have a short example and font that reproduces this.

JDBC-0 commented 2 years ago

Unfortunately, these are customer fonds that are only their property. But perhaps you could try misc fonts, set the chart title aligned to the right and see if the very same text is displaced on each other fond.

trashgod commented 2 years ago

I understand about proprietary fonts: if you can't reproduce the problem without their font, they may need to contact the font vendor. If you can, I'll try your code on my platform.

JDBC-0 commented 2 years ago

It is not about these fonts as they work flawlessly with JFreeChart 1.0.17 .... just by switching to 1.5.3, some of such chart titles suddenly moved to the right or to the left. We noticed this as most of our chart titles are right aligned and now many of them have displaced chart titles.

We now must revert all the code changes back to JFreeChart 1.0.17 as this is unacceptable.

trashgod commented 2 years ago

I only see wrapping, not truncation. A title terminated with suggests checking the maximumLinesToDisplay setting. Otherwise, I'm nonplussed; history since 2016 is here; previously here.

JDBC-0 commented 2 years ago

I went back and created 2 versions of our app: one with the JfreeChart 1.0.17 API and one with JFreeChart 1.5.3 API. I compared both generated SVGs and noticed differences in the numbers! We still use the Apache FOP internal Batik API to save the chart as SVG - not a single character is changed in the source code - only JFreeCjart exchanged.

I noticed the with JFreechart 1.5.3, several numbers changed. Some numbers now miss the decimal places: (I had to remove the opening/closing XML charatcers for the code show here!)

` old: text x="138.0029" xml:space="preserve" y="7.4395" style="clip-path:url(#clipPath1); stroke:none;"

new: text x="147" xml:space="preserve" y="7.4395" style="clip-path:url(#clipPath1); stroke:none;"

old: rect x="112.2358" y="163.8018" width="115.5283" style="clip-path:url(#clipPath1); fill:white; stroke:none;" height="15.1982"

new : rect x="112" y="163" width="116" style="clip-path:url(#clipPath1); fill:white; stroke:none;" height="16" `

Some differ by 1 maybe some changed rounding?):

` old : rect x="38" y="15" width="290" style="clip-path:url(#clipPath1); stroke:none;" height="127"

new : rect x="37" y="15" width="291" style="clip-path:url(#clipPath1); stroke:none;" height="126" `

I even noticed a new attribute (here: "stroke-width"):

` old: g style="fill:rgb(0,48,87); text-rendering:geometricPrecision; font-size:8px; shape-rendering:crispEdges; font-family:'Corporate S Light'; stroke:rgb(0,48,87);"

new : g style="font-size:8px; fill:rgb(0,48,87); text-rendering:geometricPrecision; font-family:'Corporate S Light'; shape-rendering:crispEdges; stroke:rgb(0,48,87); stroke-width:0.5;" `

Again: I changed back to JFreeChart 1.0.17 and the new SVG is identical to the version before JFreeChart 1.5.3.

So, as all other things are equal, there had to be changes in JFreeChart that had side effects to the placement ... when I look at the numbers, not only to the chart title, but also the chart itself. (The title is just obvious as you cleary see the displacement of the text leading to several characters cut off - within the boundary box of the FOP report that displays the chart SVG)

trashgod commented 2 years ago

I see that JFreeSVG has evolved with recent JFreeChart releases. Might that represent a path forward?

JDBC-0 commented 2 years ago

Well, I tested JFreeSVG and the problem does not show up with it. But we can't switch fast to JFreeSVG as this involves a lot of testing and might introduce other problems.

However, I showed that this problem was introduced by only JFreeChart (from 1.0.17 to 1.5.3) with all other parts staying the same. It is suspicious that suddenly some values seem to be rounded (and not with earlier JFreeChart version) and especially some do not have a fraction anymore. I consider this a bug as this reduced precision.

trashgod commented 2 years ago

I see that Apache FOP has also evolved in the interim. Can you indicate which version was working with JFreeChart 1.0.17? Does a later vision work with JFreeChart 1.5.3?

JDBC-0 commented 2 years ago

We also keep FOP up to date, so JFreeChart 1.0.17 worked with all the latest FOP versions - incl. the latest 2.7 we use. So, we we use FOP 2.7 and after switching to JFrereChat 1.5.3, the problem appeared.

erlenmeyer commented 2 years ago

Just stumbled over this thread. Sounds like a very annoying problem! A couple of suggestions from my side: