Sign in to follow this  
Arindam

Problem populating the chart with data form XML file or thru XML string

Recommended Posts

Hi,

I am having this issue with the free version of the chart.

I am working on a project where i need to read data from a MySQL DB and create a chart form this data.

The chart and DB are on a remote server.

I tried the following 2 aproaches and both did not work:

1) using VBscript/Javascript I read the data from the DB into a string than saved it (using the FileSystemObject) to the Data.XML, this did work locally running the scripts and having the XML file and the flash etc.. files on my local machine and accessing the DB from the remote server. When i uploaded the files to the server, and changed all the relative paths the XML file wouldn't get updated and I will always get the same data displayed ( from the Data.XML file on the server)

The 2nd aproach: 

2) I tried using cookies to create and Pass the XML data from the parsing html page to the Report page.

In this case i checked the created XML string and it looked ok, but the chart will give me invalid XML data.

The following is the code I used to read the cookie etc.. on the report page:

<script language="JavaScript">  

 <!--

 alert("In JScript");

 var strXML = get_cookie ( "XMLData" );

 strXML = strXML + "";

 alert(strXML);

 //var Temp = WrFile(strXML);

 var chart1 = new FusionCharts("Charts/FCF_Column3D.swf", "chart1Id", "400", "300", "0", "0");

 chart1.setDataXML(strXML);

 chart1.render("chartdiv1");

 //alert("Before Delete");

 var ClsCookie = delete_cookie("XMLData");

 

 function get_cookie ( cookie_name )

 {

var results = document.cookie.match ( '(^|:) ?' + cookie_name + '=([^;]*)(;|$)' );

 

if ( results )

return ( unescape ( results[2] ) );

else

return null;

 }

 function delete_cookie ( cookie_name )

 {

var cookie_date = new Date ( );  // current date & time

cookie_date.setTime ( cookie_date.getTime() - 1 );

document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();

 }

 -->

</script>

 

And the following is the created string from the cookie: 6fcc8b78-8b72-4425-853e-93fb.JPG

I tried seperating the XML elements using VBTab, VBCRLF also " " and none would work.

Any help will be really apreciated.

Thanks

Share this post


Link to post
Share on other sites

Hi,

I did try that, I created the XML string using VBscript and I tried seperating the XML tags with VBCRLF, VBCR, Just Space, and no separation, and I got the same result.

The VBCRL and the VBCR shows as "___" in the alert message.

The following is the code i am using the create the cookie:

. . .

dim FirstLine

Firstline ="<graph caption=""" & ChartCaption & """  xAxisName=""NNN"" yAxisName=""Power Month"" showNames=""1"" decimalPrecision=""2"" formatNumberScale=""0"">"

do until objRecordset.EOF

 

NNNNAME=objRecordset.Fields(3)

  mValue= objRecordSet.Fields(4) 

 

  XMLText = "<set name=" & "'" & NNNNAME & "'" & " " & "value=" & "'" & mValue & "'" & " " & "color=" & "'" &  DecToHex(Randomizing) & "'" & " " & "/>" & VBcrlf

 

  LinesInFile =LinesInFile & XMLText

  objRecordSet.MoveNext

 nRec =nRec +1

 loop

 Exp = "expires=Thursday, 30-Jun-2008 00:00:00 GMT"

 Document.cookie= "XMLData" & "=" & Firstline &  LinesInFile &  "</graph>" '& ";" & Exp

 alert document.cookie 

 

 objRecordset.Close

. . .

 

Thx

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this