| Locate Previous Next | Contents |
There is no particular magic about publishing compound documents on the internet you can simply save your charts in any of the Internet-friendly formats (.GIF or .PNG) and refer to them as images in the normal way in your web page ...
<img src="mychart.png" alt="My first chart">
From Dyalog APL you can use PostScrp.MakePNG or PostScrp.MakeGIF directly, but note that Dyalog can only make uncompressed GIF files, so if you want to use this format, it may be worth loading the file into PSP and resaving it anyway!
To make a really simple web page, you can open Notepad, and type a couple of lines such as:
<h2>Here is My Chart</h2> <img src="mychart.png"> <p>That was easy!</p>
Save the file as c:\temp\first.htm, and double-click it in Windows Explorer. You will see the text (with the top line in bold), a placeholder for the picture, as it doesnt exist yet, and the last line in normal text.
Lets use a simple piechart as our first picture ...
ch.Set 'head' 'My First Chart' ch.Pie 5 4 3 2 PGch.Close
Now we need to convert PG to a suitable format. In Dyalog APL, you can type:
pngPostScrp.MakePNG PG
... now lets have a look at the content of png.
½png
3
½¨png
5750 30 8
2png
<MAP name="chart186">
</MAP>
3png
chart186
The first element is a vector of integers, which may be written raw to file to make an image in the correct format. Lets test this unlikely idea ....
20png
¯119 80 78 71 13 10 26 10 0 0 0 13 73 72 68 82 0 0 1 ¯80
'c:\temp\mychart.png' PostScrp.rput png
Assuming you used the same file name as you typed into that fragment of HTML, if you go back to the web browser and hit the Refresh button (or just press F5 in IE) the chart will magically appear! The result may look something like this ...
You can use the left argument of MakePNG to play with different scale factors for now lets make a miniature:
'c:\temp\mychart.png' PostScrp.rput 0.4 PostScrp.MakePNG PG
Press F5 again in the browser to see a much smaller pie.
Note on GIFs and PNGs
The GIF format is universally acceptable (it works in all browsers from Netscape-1 upwards) but the compression algorithm used was retrospectively claimed as copyright by Unisys who charge a ridiculous fee for developers (like us) to license it.
The PNG format is supported by any browser with a version number of 4 and above, and is an all-round better performer. It is also public, free and well supported by Microsoft tools such as Word97. Use it if you are reasonably sure your readers mostly have up-to-date browsers!