PlesTech

Using the Data String Method for Stacked Charts

Recommended Posts

In the documentation for FusionCharts XT for the first chart example you give an example of the data string method which was:

      myChart.setXMLData("<chart caption='Weekly Sales Summary' xAxisName='Week' " +

        "yAxisName='Sales' numberPrefix='$'>" +

          "<set label='Week 1' value='14400' />" +

          "<set label='Week 2' value='19600' />" +

          "<set label='Week 3' value='24000' />" +

          "<set label='Week 4' value='15700' />" +

        "</chart>");

I got this example to work fine, but when I tried to do a stacked column chart I could not successfully get it to plot. Could you please advise how you would use the data string method for the following example in your documentation?

<chart caption='Weekly Sales Summary for two Products' xAxisName='Weeks' yAxisName='Amount' numberPrefix='$'>

 

   <categories>

      <category Label="Week1"/>

      <category Label="Week2"/>

      <category Label="Week3"/>

      <category Label="Week4"/>

   </categories>

 

   <dataset seriesName="Product A">

       <set  value='14400' />

       <set  value='19600' />

       <set  value='24000' />

       <set  value='15700' />

   </dataset>

   <dataset seriesName="Product B">

       <set  value='12000' />

       <set  value='15000' />

       <set  value='20000' />

       <set  value='11000' />

   </dataset>

</chart>

Share this post


Link to post
Share on other sites

In the documentation for FusionCharts XT for the first chart example you give an example of the data string method which was:

      myChart.setXMLData("<chart caption='Weekly Sales Summary' xAxisName='Week' " +

        "yAxisName='Sales' numberPrefix='$'>" +

          "<set label='Week 1' value='14400' />" +

          "<set label='Week 2' value='19600' />" +

          "<set label='Week 3' value='24000' />" +

          "<set label='Week 4' value='15700' />" +

        "</chart>");

I got this example to work fine, but when I tried to do a stacked column chart I could not successfully get it to plot. Could you please advise how you would use the data string method for the following example in your documentation?

<chart caption='Weekly Sales Summary for two Products' xAxisName='Weeks' yAxisName='Amount' numberPrefix='$'>

 

   <categories>

      <category Label="Week1"/>

      <category Label="Week2"/>

      <category Label="Week3"/>

      <category Label="Week4"/>

   </categories>

 

   <dataset seriesName="Product A">

       <set  value='14400' />

       <set  value='19600' />

       <set  value='24000' />

       <set  value='15700' />

   </dataset>

   <dataset seriesName="Product B">

       <set  value='12000' />

       <set  value='15000' />

       <set  value='20000' />

       <set  value='11000' />

   </dataset>

</chart>

Hi,

 

Please try removing the extra spaces and line-breaks from the XML while rendering the chart using Data String method.

Ex: 

var myChart = new FusionCharts("StackedColumn2D.swf", "Chart1Id", "600", "400", "0", "1");  myChart.setXMLData("<chart caption='Weekly Sales Summary for two Products' xAxisName='Weeks' yAxisName='Amount' numberPrefix='$'><categories><category Label='Week1'/><category Label='Week2'/><category Label='Week3'/><category Label='Week4'/></categories><dataset seriesName='Product A'><set  value='14400' /><set  value='19600' /><set  value='24000' /><set  value='15700' /></dataset><dataset seriesName='Product B'><set  value='12000' /><set  value='15000' /><set  value='20000' /><set  value='11000' /></dataset></chart>");  

Please check with the attached HTML file for your reference.

 

Hope this helps. :)

StackedChart.html

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