mcarpe

Form Examples loading different XML files into the same chart

Recommended Posts

I am having a hard time understanding the load xml function via a dropdown box form. The examples I have seen (below) in the documentation work with a single button and a single XML file. Are there any examples out there with a drop down box form and multiple xml files?

<html>
  <head>
    <title>Update Chart data</title>
    <script type="text/javascript" src="../../Charts/FusionCharts.js">
    </script>
  </head>
  <body>
    <div id="chartContainer">Chart will load here!</div>
    <script type="text/javascript"><!--

      var myChart = new FusionCharts( "../../Charts/Pyramid.swf", 
        "myChartId", "400", "300", "0", "1" );
      myChart.setXMLUrl("RevenueData.xml");
      myChart.render("chartContainer");

                function changeData()
                {
                        var chartReference = FusionCharts("myChartId");
                        chartReference.setXMLUrl("QunatityData.xml");
                }
    // -->
    </script>

    <input type="button" onClick="changeData();" value="Change Chart Data">
  </body>
</html>

Share this post


Link to post
Share on other sites
Guest Sumedh

Hi,

 

First, you would need to get the id of the drop-down element.

 

Ref. Code:

 var getvalue = document.getElementById("id1").value;

 

Hence, you would need to pass this value in the each "value" element of <option> tag.

 

Depending on this values, you can change the chart type using "onChange" event.

 

Ref. Code:

<select id="id1" onchange="changeChart();">
<option value="Please select chart" disabled="disabled" selected="selected">Please select chart</option>
<option value="Pie3D" >Pie 3D</option>
.
.
 
Please find attached illustration for your reference,
 
Hope this helps!
 

ChangeChart_onDropDown.zip

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