Monday, May 29, 2006

Creating dynamic SVG graph using agent

A friend asked about generating dynamic graph for a domino web application. I've been using Scalable Vector Graphic (SVG) to generate graph for some of my application so I recommended him that.

SVG is a language for describing two-dimensional graphics and graphical applications in XML. SVG can be use to create dynamic graph for your website. Dynamic SVG can be generated using Lotus Notes agent.

Create a lotus notes agent (name "svgagent").

Sub Initialize
Print |Content-type:image/svg+xml|
Print |<?xml version="1.0"?>|
Print |<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">|
Print |<svg width="200" height="200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">|
Print |<desc>polyline</desc>|
Print |<g>|
Print |<polyline id="lens" points="10,180 40,120 70,140 100,90 130,40 160,100" fill="none" stroke="purple" stroke-width="2"/>|
'processing and draw the graph
Print |</g>|
Print |</svg>|
End Sub


Then in your webpage you can embed the code below.
For Mozilla, Firefox, Netscape
<object type="image/svg+xml" data="svgagent?OpenAgent" width="200" height="200"></object>
For IE
<embed src="svgagent?OpenAgent" width="200" height="200" pluginspage="http://www.adobe.com/svg/viewer/install/"><embed>

You need to install SVG viewer to view the SVG files. You can download one from Adobe SVG viewer. Below is a sample graph.

23 comments:

Anonymous said...

Hi,

I wrote a similar article on my site. However, it uses a view instead of an agent. Just a different way to accomplish the same thing :-)

Here is the url : http://www.sith.be/sith/home.nsf/PageID/SITH-65DMP5

Anonymous said...

Hi,

I have developed a script library to simplify the creation of charts using svg. I will happily provide the sample database (which includes the lib) free of charge.

To see it in action :
http://217.204.16.228/svgdemo.nsf/svgDemo/1?EditDocument

Regards

Tim Crannigan

William Beh said...

@Tim. Nice. It works on IE but not on Firefox. The Embed tag doesn't work on Firefox. I check for browser, for Mozilla, I use the object tag instead.
btw, where can i download the sample database?

Anonymous said...

Happy to email it to you - what's your address

William Beh said...

Thanks. You can email me - willbeh at gmail.com

Anonymous said...

These are some great examples. Tim, could you please send me a copy of the database? I'd like to learn (by example) more about this, and hopefully start using it soon.

Thanks *very* much.

Mark
mheich@sprintmail.com

Anonymous said...

Hi,
I am interested in using the SVG to plot graph with my notes application , and saw this sample :
http://217.204.16.228/svgdemo.nsf/svgDemo/1?EditDocument&force_refresh=%2038961.275150463

but , where and how to download the svgdemo.nsf database sample ?
please help to give a clear direction ....

Thanks very much.....

William Beh said...

The database is from Tim. I'm not sure if I can distribute it directly. You could leave your email and I'll forward it to Tim.

Anonymous said...

Hi Tim,
Appreciate your great charting by using svg ...
Tim, could you please send me a copy of the database? I'd like to learn (by example)and implement in my Notes application .
hopefully can hear from you soon.
Thanks a lot.

my email: banirtown@yahoo.com

Anonymous said...

Hi, William
Thanks for your reply ...
My email : ephanlc@yahoo.com.sg

Please help to forward to Tim .
Hope to hear from you soon.
Thanks very much.

Anonymous said...

Hi Tim,
i like this database Tim(http://217.204.16.228/svgdemo.nsf/svgDemo/1?EditDocument).Could you mail me(attitude@yahoo.com.sg) your database please...
Adam

Anonymous said...

and pls send it to me to.
email: oceanmoon618@hotmail.com

Thanks for sharing

Anthony Miller said...

I also would like a copy of the database.

Anthony Miller
amiller@efcocorp.com

Unknown said...

Please email it to me
mostely@gmail.com

ED-DETECTIVE.COM said...

please email to me: luca@geminiconsulting.net

ED-DETECTIVE.COM said...

please send to me too please: luca@geminiconsulting.net

Anonymous said...

Hi Tim,
i like this database .Could you mail me(akr30212@gmail.com) your database please...

सुभमई राय said...

I am unable top see your database kindly mail it to me at suvomoyroy@gmail.com

Unknown said...

Hi Tim,

Please mail the sample database to me also - sriman.koduru@gmail.com
Your work is amaizing.
Thanks in Advance

Anonymous said...

I wish to have a copy to the database too, you're reply will be much appreciated.

morpheus@live.hk

Anonymous said...

Hi Tim... could you please send me the database where I can refrence the script as I need to build the same for my project. many thanks

my email address is girish.chopra@gmail.com

Unknown said...

how to create dynamic svg graphics and connect to the database

Unknown said...

how to create dynamic svg graphics and connect to the database

saputra_nopri@yahoo.co.id