jfreechart icon indicating copy to clipboard operation
jfreechart copied to clipboard

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

Open JDBC-0 opened this issue 2 years ago • 11 comments

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.

JDBC-0 avatar Apr 06 '22 14:04 JDBC-0

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.

trashgod avatar Apr 06 '22 17:04 trashgod

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.

JDBC-0 avatar Apr 07 '22 16:04 JDBC-0

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.

trashgod avatar Apr 07 '22 17:04 trashgod

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.

JDBC-0 avatar Apr 08 '22 05:04 JDBC-0

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.

trashgod avatar Apr 08 '22 18:04 trashgod

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)

JDBC-0 avatar Apr 11 '22 07:04 JDBC-0

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

trashgod avatar Apr 11 '22 19:04 trashgod

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.

JDBC-0 avatar Apr 12 '22 06:04 JDBC-0

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?

trashgod avatar Apr 12 '22 22:04 trashgod

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.

JDBC-0 avatar Apr 13 '22 07:04 JDBC-0

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

  • Does the issue show up consistently for right aligned titlesor just when the spasce is constrained?
  • Are the titles directly added to the chart, or are the part of an annotation? I have noted tha the data area of a plot is now integerised (not sure when this was introduced), but this should not affect titles that are added to a chart
  • There are no problems with standard fonts? You have written that the customer fonts worked well with 1.0.17, but you have not stated how normal fonts behave with 1.5.3 (or I may have missed that)
  • If you can reproduce the problem with the custom fonts and a simple chart, you could try to create a diff file and post it here. Then, somebody may notice where thew changed coordinates come from.

erlenmeyer avatar May 17 '22 17:05 erlenmeyer