Sign in to follow this  
GaetVa

Modifying Datas In Xml Without Generating Again All The Chart

Recommended Posts

Hello,

 

I am trying, after updating some datas in the xml, to generate only the datas changed without generating each time completly the chart.

But nothing is change on my chart. I followed examples i found (ex : http://docs.fusioncharts.com/widgets/Contents/JavaScript/JS_ChangeData.html#update

and this one : file:///C:/R&D%20TECH/fusion%20Charts%20full%20version/FusionCharts_XT_OLSrc/FusionCharts_XT/Contents/index.html)

 

Below is my code. I used setxmldata instead of setXMLUrl, but tried with myChart.setChartData(xmlfile2, "xml"), and nothing appears too.

 

If someone can provide me some help, i would be gratefull :-)

 

 

//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
//<html xmlns="http://www.w3.org/1999/xhtml">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>            
<title>My First chart using FusionCharts - Using JavaScript</title>   
    <meta http-equiv="X-UA-Compatible" content="IE=8">
    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />
    <meta http-equiv="Content-Style-Type" content="text/css" />          
<script type="text/javascript" src="Charts/FusionCharts.js"></script>  

</head>     
<body>       


<div id="chartContainer">FusionCharts XT will load here!</div>              
<script type="text/javascript"><!--  

function onclickCallback () {


var xmlfile2 = '<chart showValues="0" caption="test" numberPrefix="$" xAxisName="Date" yAxisName="Quantity" useRoundEdges="1"  ><categories><category label="01/01/2013"/><category label="02/01/2013"/><category label="03/01/2013"/><category label="04/01/2013"/></categories><dataset seriesName="Truck 1" color = "FF0000" ><set value="235000"/><set value="225100"/><set value="222000"/><set value="230500"/></dataset><dataset seriesName="Truck 2"><set value="23000"/><set value="13000"/><set value="0"/><set value="8000" /></dataset><dataset seriesName="Truck 3" color="F984A1"><set value="230000"/><set value="143000"/>";/><set value="198000"/><set value="327600"/></dataset><dataset seriesName="Free" color="8BBA00"><set value="110000"/><set value="180000"/><set value="700000"/><set value=""/></dataset><dataset seriesName="Capacity" renderAs="Line" ><set value="800000"/><set value="700000"/><set value=""/><set value="500000"/></dataset></chart>'
var myChart = FusionCharts("myChartId");
myChart.setXMLData(xmlfile2);

}




//FusionCharts.setCurrentRenderer('javascript');

var xmlfile = '<chart showValues="0" caption="Stored load" numberPrefix="$" xAxisName="Date" yAxisName="Quantity" useRoundEdges="1"  ><categories><category label="01/01/2013"/><category label="02/01/2013"/><category label="03/01/2013"/><category label="04/01/2013"/></categories><dataset seriesName="Truck 1" color = "009900" ><set value="235000"/><set value="225100"/><set value="222000"/><set value="230500"/></dataset><dataset seriesName="Truck 2"><set value="230000"/><set value="143000"/><set value="0"/><set value="80000" /></dataset><dataset seriesName="Truck 3" color="F984A1"><set value="230000"/><set value="143000"/>";/><set value="198000"/><set value="327600"/></dataset><dataset seriesName="Free" color="8BBA00"><set value="110000"/><set value="180000"/><set value="700000"/><set value=""/></dataset><dataset seriesName="Capacity" renderAs="Line" ><set value="800000"/><set value="700000"/><set value=""/><set value="500000"/></dataset></chart>'

var myChart = new FusionCharts( "Charts/StackedColumn2DLine.swf", "myChartId", "860", "340", "0", "1" );

myChart.setXMLData(xmlfile);

myChart.render("chartContainer");


// -->      
</script>

 <input type="button" onClick="onclickCallback();" value="Change Chart Data">

 
</body>
</html>

 

 

 

 

Share this post


Link to post
Share on other sites

Hello,

 

I am trying, after updating some datas in the xml, to generate only the datas changed without generating each time completly the chart.

But nothing is change on my chart. I followed examples i found (ex : http://docs.fusioncharts.com/widgets/Contents/JavaScript/JS_ChangeData.html#update

and this one : file:///C:/R&D%20TECH/fusion%20Charts%20full%20version/FusionCharts_XT_OLSrc/FusionCharts_XT/Contents/index.html)

 

Below is my code. I used setxmldata instead of setXMLUrl, but tried with myChart.setChartData(xmlfile2, "xml"), and nothing appears too.

 

If someone can provide me some help, i would be gratefull :-)

 

 

//<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

//<html xmlns="http://www.w3.org/1999/xhtml">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>            

<title>My First chart using FusionCharts - Using JavaScript</title>   

    <meta http-equiv="X-UA-Compatible" content="IE=8">

    <meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />

    <meta http-equiv="Content-Style-Type" content="text/css" />          

<script type="text/javascript" src="Charts/FusionCharts.js"></script>  

 

</head>     

<body>       

 

 

<div id="chartContainer">FusionCharts XT will load here!</div>              

<script type="text/javascript"><!--  

 

function onclickCallback () {

 

 

var xmlfile2 = '<chart showValues="0" caption="test" numberPrefix="$" xAxisName="Date" yAxisName="Quantity" useRoundEdges="1"  ><categories><category label="01/01/2013"/><category label="02/01/2013"/><category label="03/01/2013"/><category label="04/01/2013"/></categories><dataset seriesName="Truck 1" color = "FF0000" ><set value="235000"/><set value="225100"/><set value="222000"/><set value="230500"/></dataset><dataset seriesName="Truck 2"><set value="23000"/><set value="13000"/><set value="0"/><set value="8000" /></dataset><dataset seriesName="Truck 3" color="F984A1"><set value="230000"/><set value="143000"/>";/><set value="198000"/><set value="327600"/></dataset><dataset seriesName="Free" color="8BBA00"><set value="110000"/><set value="180000"/><set value="700000"/><set value=""/></dataset><dataset seriesName="Capacity" renderAs="Line" ><set value="800000"/><set value="700000"/><set value=""/><set value="500000"/></dataset></chart>'

var myChart = FusionCharts("myChartId");

myChart.setXMLData(xmlfile2);

 

}

 

 

 

 

//FusionCharts.setCurrentRenderer('javascript');

 

var xmlfile = '<chart showValues="0" caption="Stored load" numberPrefix="$" xAxisName="Date" yAxisName="Quantity" useRoundEdges="1"  ><categories><category label="01/01/2013"/><category label="02/01/2013"/><category label="03/01/2013"/><category label="04/01/2013"/></categories><dataset seriesName="Truck 1" color = "009900" ><set value="235000"/><set value="225100"/><set value="222000"/><set value="230500"/></dataset><dataset seriesName="Truck 2"><set value="230000"/><set value="143000"/><set value="0"/><set value="80000" /></dataset><dataset seriesName="Truck 3" color="F984A1"><set value="230000"/><set value="143000"/>";/><set value="198000"/><set value="327600"/></dataset><dataset seriesName="Free" color="8BBA00"><set value="110000"/><set value="180000"/><set value="700000"/><set value=""/></dataset><dataset seriesName="Capacity" renderAs="Line" ><set value="800000"/><set value="700000"/><set value=""/><set value="500000"/></dataset></chart>'

 

var myChart = new FusionCharts( "Charts/StackedColumn2DLine.swf", "myChartId", "860", "340", "0", "1" );

 

myChart.setXMLData(xmlfile);

 

myChart.render("chartContainer");

 

 

// -->      

</script>

 

 <input type="button" onClick="onclickCallback();" value="Change Chart Data">

 

 

</body>

</html>

Hi,

 

Please note that your sample seems to be working perfectly at our end. Please check with the attached sample.

 

Also, in case you are rendering a Flash chart, please note that the Flash Player Global Security settings needs to be enabled, if you are running the application from local file system (C:\ or D:\) and not from web server (local or live).

 

Flash Player's Global Security setting blocks invoking/calling JavaScript from SWF (Flash Movie) by default. So you need to reset your setting into Global Security Setting panel and enable it while using Drill-down functions and various other JavaScript related functions.

 

Please refer to the following page for further details on the Flash Player Global Security settings:

http://docs.fusioncharts.com/charts/Tools/FlashPlayerSecuritySetup/HowToSetup.html

 

Hope this helps. :)

ChangeData.zip

Share this post


Link to post
Share on other sites

Hello Sanjukta,

 

Thanks a lot for your answer. I changed my Flash Global Security setting and chart is generated.

 

But i have a question regarding this :

 

I saw that even i changed only a colour for only a stacked bar, all the bars are generated again.

Is there a way to only generate the stacked bar modified without generating all the bars of the chart ?

 

For instance, we would like that when the user click on a stacked bar, this stacked bar changes its colour without all the stacked bars generated again,

as when you have a lot of bars, it takes some times to generate again all the bars and it is more user friendly if it is possible to generate only the updated

bar without generating all the others bars.

 

Thanks and regards,

 

Alain

 

 

Share this post


Link to post
Share on other sites

Hello Sanjukta,

 

Thanks a lot for your answer. I changed my Flash Global Security setting and chart is generated.

 

But i have a question regarding this :

 

I saw that even i changed only a colour for only a stacked bar, all the bars are generated again.

Is there a way to only generate the stacked bar modified without generating all the bars of the chart ?

 

For instance, we would like that when the user click on a stacked bar, this stacked bar changes its colour without all the stacked bars generated again,

as when you have a lot of bars, it takes some times to generate again all the bars and it is more user friendly if it is possible to generate only the updated

bar without generating all the others bars.

 

Thanks and regards,

 

Alain

Hi,

 

Could you please try setting the attributes "animation" and "default" animation to '0' in the XML which is getting updated so that it does not display all the plots to be re-rendered?

<chart ... animation='0' defaultAnimation='0' >

 

Hope this helps. :)

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