This week I've been working on getting amCharts to work in a dashboard I'm working on. I was pointed to amCharts and the inkling of how to accomplish this by the sample database from the LotusPhere 2008 session BP210: Reports, Charts and Graphs in IBM Lotus Notes over on Julian Robichaux 's site. In this SnTT, I want to show you another way to implement this
functionality into your applications. It gives your applications a nice professional look and keeps the customer's boss happy with nice pretty charts.

The dashboard is a form with a drop down box to pick the information you want to see and then a "Go" button to go out and get the pertinent numbers, create/update an XML file/document and then display 2 charts in a Microsoft Web Browser control embedded on the form. One chart is a bar chart with the hard numbers and the other is a pie chart which shows the percentages the numbers represent. The idea here was that I would display this information in a nice looking dialog box. However I couldn't get this to work. I spoke with Nathan Freeman because I knew he had worked with the Microsoft Web Browser control quite a few times and he informed me in a dialog box that the auto-run did not work for ole objects. I attempted to get it to work by using the PostOpen event to no avail. So, I ended up just displaying it as a normal form.
But to get this to work here's the path I followed, I'll also post a demo database in case my ramblings turn into just that, rambling...
>I created the Dashboard form with a drop down box so that you can pick what data you want displayed along with a "Go" button. The Go button when clicked goes out to the proper views to get the numbers for whatever was selected and call the browser.Navigate(url) function to send the web browser to the pertinent web page. The only downside to this function is I did hardcode the server name for figuring out the URL string to pass to the browser. I guess you could probably include a field in a profile document or something like that to store the host name. So far, easy right? I also created another form which is the configuration form. You'll need a lookup key field and a rich text lite field on this form for attachments. You'll also need to create another form to be stored as an XML file. This form includes 2 fields, a lookup key field and an XMLData field. In the form properties you'll have to change the content type to Other: text/xml.
You'll also need to create 3 views to support all this. One is the XMLData view which will contain all the XML files sorted by the lookup key. Second is a view which will contain the configuration documents sorted by Lookup Key and third is a view or views which will contain the documents where you'll get all the data that you want to show in the charts.
Now, amCharts uses several files in order to function. To start with you'll need an html file, the data.xml file, the settings.xml, swfobject.js and a special .swf file depending on the type of chart you want to display. In our case we're showing a pie chart and a bar chart so you'll need ampie.swf and amcolumn.swf. All of these files will need to be attached to the configuration document. I'll go ahead and cover the contents of the html file as the contents of the settings.xml file are a little too complex to cover here. In my case the html file is called showgraph.html, but you can name it whatever you like as this will be the page that is displayed in the Microsoft Web Browser control. Below is the one I used in the demo:
Now, of note here is the divs, they have to be named differently and then use that div in the so.write/sr.write calls. Also of note is the function CleanupF9IELeaks, this is to work around a bug with the Flash 9 player displaying multiple flash objects on the same page. You get the error "Out of memory on line: 56" when navigating away from the page. That function helps get rid of that but unfortunately it really doesn't work with the Microsoft Web Browser control, it doesn't return an error, just doesn't work. Also, the data here is hard coded, I'm sure some of you javascript gurus out there could get around the hard coding.
I think that is about it. Check out the demo database in the downloads section and that should cover everything. Just be aware of the hardcoded references in the showgraph.html file and the "Go" button on the dashboard form. Hopefully this will give you some ideas on how you can incorporate quick, easy charts and graphs in your Lotus Notes applications.