Sign in to follow this  
STravis

Java Script Drill Down Problem

Recommended Posts

Hello,

I am attempting to get a handle on FusionCharts v3 using a product called Websmart accessing an AS/400 database.  I have crated a simple page using three graphs being populated by external XML calls.  All is working great and I am now trying to establish a simple drill down function.  Page is populated by a location number being passed via URL - right now I am simply attempting to change MTD graph to a different location by clicking ANY YTD graph bar.  The location change is hardcoded until I establish function  - I can then setup all necessary parameters to control graphs.  I have very little Javascript experience but have tried a number of methods that I have deciphered from blueprint - but when obvious errors removed seems to come back to - Object doesn't support this property or method.  I am just not getting it right!  Can anybody there take a look a code and point out obvious problems.  I can provide URL but would rather not publish to public.

Basic code - internal address

<html>
   <head>
   
    <script language="JavaScript" src="FusionCharts.js"></script>
  
  <Script LANGUAGE="JavaScript">
  function UpdateMTDChart(Year)
  { 
MTDChart.setDataURL("http://192.168.0.2/scs400web/xml002.pgm?Location=27");
  }
 </Script>

</head> 
   
<body bgcolor="#ffffff">
 
 <BR>
 
   <div id="YTDChartDiv" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
   <script type="text/javascript">
    var YTDChart = new FusionCharts("Column3D.swf","YTDChartId","900","300","0","0");
    YTDChart.setDataURL("http://192.168.0.2/scs400web/xml001.pgm?Location=000321");
    YTDChart.render("YTDChartDiv");
   </script>
 
 <BR>
 
   <div id="MTDChartDiv" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
   <script type="text/javascript">
    var MTDChart = new FusionCharts("Column3D.swf","MTDChartId","900","300","0","0");
    MTDChart.setDataURL("http://192.168.0.2/scs400web/xml002.pgm?Location=000321");
    MTDChart.render("MTDChartDiv");
   </script>
  
 <BR>

   <div id="DLYChartDiv" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
   <script type="text/javascript">
    var DLYChart = new FusionCharts("Column3D.swf","DLYChartId","900","300","0","0");
    DLYChart.setDataURL("http://192.168.0.2/scs400web/xml004.pgm?Location=000321");
    DLYChart.render("DLYChartDiv");
   </script>   
  
 <BR>
  
</body>
</html>

Thanks for your help!

Share this post


Link to post
Share on other sites

In your function UpdateMTDChart, you've not first referenced the chart back from its ID. You need to use the getChartFromId(DOMId) function to get a reference back to chart. Only then, you can call it's methods.

Share this post


Link to post
Share on other sites

I tried every method that I could decipher from blueprint!

I think you mean somthing like this!!! - Same error???

<html>
<head>

 <script language="JavaScript" src="FusionCharts.js"></script>
 
 <script LANGUAGE="JavaScript">	
 
 function updateMTDChart()
 {
 var strURL = "http://192.168.0.2/scs400web/xml102.pgm?Location=00002%26Year=2007%26X=112046";
 strURL = escape(strURL);
 var chartObj = getChartFromId("MTDChart");
 chartObj.setDataURL(strURL);
 }
 
 </script>
  
</head> 
   
<body bgcolor="#ffffff">
 
 <BR>
 
   <div id="Div_YTDChart" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
   <script type="text/javascript">
    var Chart_YTDChart = new FusionCharts("Column3D.swf","YTDChart","900","300","1","0");
    Chart_YTDChart.setDataURL("http://192.168.0.2/scs400web/xml101.pgm?Location=000321%26X=112046");
    Chart_YTDChart.render("Div_YTDChart");
   </script>
 
 <BR>
 
   <div id="Div_MTDChart" align="center">The chart will appear within this DIV. This text will be replaced by the chart.</div>
   <script type="text/javascript">
    var Chart_MTDChart = new FusionCharts("Column3D.swf","MTDChart","900","300","1","0");
    Chart_MTDChart.setDataURL("http://192.168.0.2/scs400web/xml102.pgm?Location=000321%26Year=2007%26X=112046");
    Chart_MTDChart.render("Div_MTDChart");
   </script>

</body>
</html>

I am obiously trying to force this to work so I can get syntax right - will then pass variables!

Thanks again,

S Travis

Share this post


Link to post
Share on other sites

Just one more change required- you need to enable the registerWithJS flag. See bold code below:

var Chart_YTDChart = new FusionCharts("Column3D.swf","YTDChart","900","300","1","1");

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