One of the biggest drawbacks of using the HTTP Reqeust method is that there is no easy way to support Best Image Fallback. Whereas with the PopChart Embedder you can use the fallback attribute to have PopChart Server automatically return an image in the best supported image format (refer to "Best Image Fallback"), you have to use JavaScript to hand-code this functionality into images that you embed using the HTTP request method.
The basic idea of such code is to use a combination of JavaScript and VBScript to detect the version of the client's browser and the plug-ins that browser supports. Based on that information, you then output a FLASH, SVG, or GIF image, depending on what the browser supports.
Example 11.3 shows how to create a FLASH image with Best Image Fallback to a GIF image.
Note: The JavaScript code for doing this is not for the faint-hearted. In fact, we hope a simple glance at the code necessary to do this will convince you to use the PopChart Embedder.
Example 11.3 Best Image Fallback with HTTP Request Method
<script language="JavaScript1.2">
var flash_str = "Shockwave Flash";
if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0)
if (navigator.plugins[flash_str] != null) {
var pos=navigator.plugins[flash_str].description.search(/\d/);
var len = navigator.plugins[flash_str].description.length;
var ver=parseFloat(navigator.plugins[flash_str].description.slice(pos,len));
hasSVGSupport = IsObject(CreateObject("Adobe.SVGCtl"))
hasFlash = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash"))
<script language="JavaScript1.2">
var ms = "%25#23 20?3F<3c>3E{7B}7D[5B]5D|7C^5E~7E`60";
rs = ms.substring(++msi, msi +2);
str = ts + "%" + rs + str.substring(++i, str.length);
<script language="JavaScript1.2">
<!-- //CODE TO BUILD HTTP REQUEST
var pcscript = "Graph.Categories(Group 1, Group 2, Group 3)";
pcscript += "Graph.SetSeries(Item 1;54;75;85)";
pcscript += "Graph.SetSeries(Item 2;92;60;70)";
pcscript += "Graph.SetSeries(Item 3;69;87;37)";
var popchart_request = "http://localhost:2001";
popchart_request += "/?" + "@_FILEexamples/apfiles/bar.pcxml";
popchart_request += "@_PCSCRIPT" + urlEncode(pcscript);
<script language="JavaScript1.2">
if (hasFlash3up == true || hasFlash == true) {
document.write('<object width="540" height="330" ');
document.write('classid="clsid:D27CDB6E-AE6D-11cf-96B8-');
document.write('444553540000" codebase="http://download.');
document.write('macromedia.com/pub/shockwave/cabs/flash/');
document.write('swflash.cab#version=4,0,0,0"><param ');
document.write('name="MOVIE" value="');
document.write(popchart_request+'@_FLASH"></object>');
document.write('<embed width="540" height="330" ');
document.write('type="application/x-shockwave-flash" ');
document.write('pluginspage="http://www.macromedia.com/');
document.write('shockwave/download/index.cgi?');
document.write('P1_Prod_Version=ShockwaveFlash" ');
document.write('src="'+popchart_request+'@_FLASH"></embed>');
document.write('<img width="540" height="330" border="0"');
document.write('usemap="#13727203" src="');