Hi Nicolas,
The issue is due to the different understanding of text width between ChartDirector and the SVG renderer.
As an example, assuming there are two characters, each 2.7 pixels in size, and the spacing between them is 0.7 pixels. To drawing them clearly, ChartDirector will round the character to 3 pixels and the spacing to 1 pixel. So the total text width is 3 + 1 + 3 = 7 pixels. ChartDirector positions and algins the text based on this width.
However, for SVG, the text is "scalable", which means it can be viewed at any arbitrary size. For SVG, it is not useful to round 2.7 "unit" to 3 "unit", because after you scale the SVG, each "unit" may not align with a pixel. So for SVG, the total text width will be treated as 2.7 + 0.7 + 2.7 = 6.1 "units".
Because ChartDirector aligns the text by assuming 7 pixels, but the SVG draws the text as 6.1 units, so the alignment may not be accurate when viewed in SVG. The SVG text can be longer or shorter than the ChartDirector text. Usually, the error is not significant if the text is large. For example, if the text is many pixels wide, then a 0.7 unit error is just a small percentage of the width and is not easy to notice.
For your case, is it that the text in your original chart is very small, so that even small errors become significant? If you intend to output in SVG, try to use a text size is that not small than the normal view size in SVG. In some cases, you may need to add additional margins between the text and the axis to absorb the inaccuracies. (See Axis.setLabelGap.)
Regards
Peter Kwan |