Sign in to follow this  
ericb1

Fusionchart dataURL method with DNN

Recommended Posts

any help is greatly appreciated.  I've got a chart working great inside an ASP page, this part is fine.

Now I'm trying to call this from a DNN module via the sample dataURL method:

<div id="chart1div">
  This text is replaced by the chart.
</div>
<script type="text/javascript">
  var chart1 = new FusionCharts("Funnel.swf", "ChId1", "600", "400", "0", "0"); 
  chart1.setDataURL("Data.asp");
  chart1.render("chart1div");
</script>

but nothing is happening here.  What should the "Data.asp" page output look like?  Just standard XML?

Any help is appreciated, thanks!

Share this post


Link to post
Share on other sites

Thanks so much for the reply.  Yes, the HTML embed method does work on the same page.  Should I just use the HTML embed method?  What's the difference, or do I lose anything functionality with this option?

On my test ASP page, I have the following that does not work:


<SCRIPT LANGUAGE="Javascript" SRC="./Charts/FusionCharts.js">
//You need to include the above JS file, if you intend to embed the chart using JavaScript. 
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript"> 
function FC_Rendered(DOMId){
//This method is called whenever a FusionCharts chart is loaded.
//Check if it's the required chart using ID
if (DOMId=="ChId1"){
//Invoke updateChart() method to update chart with new data
updateChart();
}
} 
function updateChart(){
//Get reference to chart object using Dom ID "ChId1" 
var chartObj = getChartFromId("ChId1"); 
//Update its XML Data URL 
chartObj.setDataURL("./test/aspXML.asp"); 
}
</SCRIPT>
<BODY>
<div id="chart1div">
This text is replaced by the chart.
</div>
<script type="text/javascript">
var chart1 = new FusionCharts("./Charts/AngularGauge.swf", "ChId1", "600", "400", true,true); 
//Start Chart with empty data as we'll later update using JavaScript 
chart1.setDataXML("<chart></chart>");
chart1.render("chart1div");
</script>

and then right below it, this, which does work:


<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/
cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="200" id="MyFirstChart" >
<param name="movie" value="./Charts/AngularGauge.swf" />
<param name="FlashVars" value="&dataURL=./test/aspXML.asp">
<param name="quality" value="high" />
<embed src="./Charts/AngularGauge.swf" flashVars="&dataURL=./test/aspXML.asp" quality="high" width="400" height="200" name="MyFirstChart" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

Any help is greatly appreciated, thanks!

Share this post


Link to post
Share on other sites

Hi,

 
Yes, you just need to use HTML embed method, since the previous method writes the javascript tag into the DIV which is not executing.

Also, you won't loose any functionalities, if you need to update your chart dynamically then please pass a query string parameter "registerWithJS=1" in FlashVars attribue like below:

E.g:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="400" height="200" id="MyFirstChart" >

<param name="movie" value="./Charts/AngularGauge.swf" />

<param name="FlashVars" value="&DOMId=MyFirstChart&registerWithJS=1&dataURL=./test/aspXML.asp">

<param name="quality" value="high" />

<embed src="./Charts/AngularGauge.swf" flashVars="&MyFirstChart&registerWithJS=1&dataURL=./test/aspXML.asp" quality="high" width="400" height="200" name="MyFirstChart" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />

</object>

 

And need to change your chart id in updateChart function as follow:

function

updateChart(){

//Get reference to chart object using Dom ID "ChId1"

var chartObj = getChartFromId("MyFirstChart");

//Update its XML Data URL

chartObj.setDataURL(

"./test/aspXML.asp");

}

Share this post


Link to post
Share on other sites

Hey, i am also having trouble getting my ASP.Net pages to display my Fusion Charts in DNN 5. I have them working in ASP.Net using the recommended <object> HTML Tag also, I am, however, not using JavaScript on my page, I am only using ASP.Net & HTML with C# back end code. What am I doing wrong.

Please HELP! I have been searching for DAYS!!!!: :w00t:

Share this post


Link to post
Share on other sites

Rick,

 

In my experience with DNN and FusionCharts, I found that the calling path was the problem that prevented the chart from rendering. Here's how I fixed it to make it work well with other portals:

 

 

 

Firstly, my examples are in C# and I'm assuming that you are approaching this from a module programming standpoint.

 

 

 

I am using the c# example "charting data from an array" from the documentation, so my solution will reference it.

 

 

 

The first problem is that dnn does directories differently than other systems, so I place the FusionCharts folder with the js and flash files in the PORTAL root directory eg /portals/1/ this is essential for the rest to work. The dll still goes in the bin directory for the dnn application.

 

 

 

Next, I had to tell the example code to look via the mapped path instead of ../. In the example code, find the line:

 

 

 

return FusionCharts.RenderChart("../FusionCharts/FCF_Column3D.swf", "", strXML, "productSales", "600", "300", false, false);

 

 

 

the path to the above swf won't work since it is in the PORTAL root now I handled it like this:

 

 

 

string filepath = "http://" + PortalAlias.HTTPAlias + "/portals/" + PortalId.ToString() + "/FusionCharts/FCF_Column3D.swf";

 

return FusionCharts.RenderChart(filepath, "", strXML, "productSales", "600", "300", false, false);

 

 

 

the above code will trace the existing portal path and find the elusive files. This is only step one. We need to do the same thing in the aspx file where the script tag lives

 

 

 

Line in Example file:

 

 

 

<SCRIPT LANGUAGE="Javascript" SRC="../FusionCharts/FusionCharts.js"></SCRIPT>

 

 

 

Change:

 

 

 

<SCRIPT LANGUAGE="Javascript" SRC="<%="http://" + PortalAlias.HTTPAlias + "/portals/" + PortalId.ToString() + "/FusionCharts/FusionCharts.js" %>"></SCRIPT>

 

 

 

now the script will be found as well.

 

 

 

In summary, DNN needs to know where to look to get files referenced in example code. I changed nothing other than these lines when I placed the CreateChart method into my existing module code. ALSO don't forget that if you are compiling c# with dnn, you will need to add the code directory to the web.config file to get it to compile. If you translate these concepts to VB there should be no issue.

 

 

 

COLOSSUS

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