ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  SVG graphics tricks
Posted by Mark on Jul-14-2013 21:00
Attachments:
In my Java code (on Linux), I create a PNG and an SVG in back-to-back lines, like this:

byte[] imagepng = this.c.makeChart2(Chart.PNG);
byte[] imagesvg = this.c.makeChart2(Chart.SVG);

and then my code writes out these byte arrays to disk.  I have attached both of them.
The PNG graphic is how it is supposed to look, but the SVG graphic only shows the title bar
and plot background, no matter which viewer I use.

What I am doing wrong for the SVG graphic?

Mark
GOLI2_HGIRGZZr.png
GOLI2_HGIRGZZr.png

82.10 Kb
GOLI2_HGIRGZZr.svg
GOLI2_HGIRGZZr.svg

38.96 Kb

  Re: SVG graphics tricks
Posted by Mark on Jul-14-2013 23:22
Attachments:
I searched "SVG" and found a post from 17-Nov-2010 which explains that I have to call
enableVectorOutput() for all the sub-charts of a multi-chart, not just the multi-chart itself.
So when I did this, the full SVG graphic is present.  But now I see that my fonts are
different then from the PNG file.  Why is that and what can I do to make them the same?
I've attached a new SVG file.  The PNG file from the original thread post is still the same, so
I didn't upload it.

Mark
GOLI2_HGIRGZZr.svg
GOLI2_HGIRGZZr.svg

193.20 Kb

  Re: SVG graphics tricks
Posted by Peter Kwan on Jul-15-2013 19:09
Hi Mark,

For the PNG output, the graphics are rendered by ChartDirector (using the Java VM in your case). In SVG, the graphics are rendered by the browser (or by whatever program that are used to view them).

Just like a web page, it is normal every browser can display things differently. (I think you are aware that the same web page can look different in different browsers.) So it is normal the SVG can look different in different browsers or viewers, and it can certainly look different from the charts rendered by ChartDirector using the Java VM.

In particular, for the text, there are the following common differences:

(a) If the viewer device does not have the font you use, it may use a substitute font. For example, if you use some fancy fonts and install it for the Java VM and use it for the charts, then ChartDirector can render the chart using these fonts. However, if the same font are not installed on the browser computer (which can be different from the server computer), it is not possible for the browser to display the font, so the browser may use a substitute font of its choice, or it may fail to display any text at all (it depends on your browser implementation).

Note that on Linux, there is no standard on where are the fonts. (In contrast, on Windows and Mac OS X, the operating system manages the fonts.) So even on the same computer, it is possible a font is visible by the Java VM but not by the browser (or by the SVG viewer prorgram).

(b) Even if the same fonts are available to both the Java VM and the browser (or SVG viewer), the text can still look slightly different. I think you are aware different browsers or viewers can render text differently. For example, text rendered by IE 6, IE 9, Safari, FireFox, Chrome, or PDF viewer, can be slightly different.


In brief, in using SVG, please make sure all computers that can view your SVG has the proper fonts installed. If you are writing a web application and you cannot control which computers can view you web site, you may consider to use only standard web fonts (like Arial, Times New Roman, etc).


Hope this can help.

Regards
Peter Kwan