liza

Chart is not rendering on second time

Recommended Posts

Hi,

I had develop a searching page that will enable user to view chart on Jquery UI dialog.

 

When Search button is click, the searching result will display with chart icon (To show chart on dialog when user click on it).

 

For first searching action, the chart is display fine but when I try click search button again, the chart is not render.

 

here is chart code when dialog is display

<?php
session_start();
require_once("../class/default.php");
require_once("../class/define.php");
include("../fusionchart/Code/PHP/Includes/FusionCharts.php");
$obj = new utama();
$id_trans = $_GET["id_trans"];
$transaksi = $obj->transaksiMM($id_trans);
$bulan = $transaksi[0]["bulan"];
$bulannama = $obj->bulanPapar($bulan);
$tahun = $transaksi[0]["tahun"];
$no_pendaftaran = $transaksi[0]["no_pendaftaran"];
$syarikat = $obj->syarikatPapar($no_pendaftaran);
$chart = "";
?>
<html>
<head>
<script>
</script>
</head>
<body>
<label class="tajuk">tajuk </label></br>
<label class="tajuksub"><?php echo $syarikat[0]["nama"];?>, <?php echo $bulannama[0]["bulan"]." ".$tahun;?></label><br/>
<?php
$chart = '<chart bgcolor="FFFFFF" charttopmargin="0" chartleftmargin="0" chartrightmargin="0" bordercolor="FFFFFF"
canvasbordercolor="DFBAAD" xAxisMinValue="0" xAxisMaxValue="100" yAxisMinValue="0" yAxisMaxValue="100"
bubbleScale="3" is3D="1" numDivLines="0" showFormBtn="0">
<dataset plotborderAlpha="0" >
<set x="50" y="90" width="120" height="90" color="FFFFFF" name="Mr. Harry Sawyer, CEO" alpha="100" toolText="Pengilang" id="CEO" imageNode="1" imageurl="../images/kilang.jpg" imageAlign="bottom" labelAlign="top" imageHeight="65" imageWidth="108" />
<set x="20" y="70" width="120" height="40" name="Name:Tom McQuin {BR}Age: 54yrs {BR}Designation:CTO" color="62D0FE" id="CTO" />
<set x="51" y="70" width="120" height="40" name="Name:Jim Kerry {BR}Age: 46yrs {BR}Designation:CFO" color="62D0FE" link="n-http://www.fusioncharts.com" id="CFO" />
<set x="80" y="70" width="120" height="40" name="Name:Michelle Saler {BR}Age: 58yrs {BR}Designation:COO" color="62D0FE" link="n-http://www.fusioncharts.com" id="COO" />
</dataset>
<connectors color="83C6E1" stdThickness="8">
<connector strength="0.45" from="CEO" to="CTO" arrowAtStart="0" arrowAtEnd="1"/>
<connector strength="0.45" from="CEO" to="CFO" arrowAtStart="0" arrowAtEnd="1" />
<connector strength="0.45" from="CEO" to="COO" arrowAtStart="0" arrowAtEnd="1" />
</connectors>
</chart>';
FC_SetRenderer( "javascript" );
echo renderChart("../fusionchart/Charts/DragNode.swf", "",$chart, "chart1", 1150, 500, false, true);
?>
</body>
</html>

Here i attach the scenario image

1. first searching attempt (Cari button), chart icon is click

2. dialog that successfully display chart

3. second searching attempt(Cari button)

4. dialog not render the chart

 

Thanks in advance.

post-29898-0-54041500-1414660100_thumb.jpg

post-29898-0-91938000-1414660116_thumb.jpg

post-29898-0-84168500-1414660124_thumb.jpg

post-29898-0-57890800-1414660131_thumb.jpg

Edited by liza

Share this post


Link to post
Share on other sites

EDIT :-

 

 After i  check, its because it create same chart ID.

 

Test 1 :so  i had try to put dispose() like below code.

 

its stil not working for second searching attempt

<?php
session_start();
require_once("../class/default.php");
require_once("../class/define.php");
include("../fusionchart/Code/PHP/Includes/FusionCharts.php");
$obj            = new utama();
$id_trans       = $_GET["id_trans"];
$transaksi      = $obj->transaksiMM($id_trans);
$bulan          = $transaksi[0]["bulan"];
$bulannama      = $obj->bulanPapar($bulan);
$tahun          = $transaksi[0]["tahun"];
$no_pendaftaran = $transaksi[0]["no_pendaftaran"];
$syarikat       = $obj->syarikatPapar($no_pendaftaran); 
$chart          = "";
$idchart        = "";
echo $idchart        = rand(0,100000);
?>
<html>
<head>
    <script>
        if  ( FusionCharts( "chart1ID") )  
        {
           alert("sini ");
            FusionCharts( "chart1ID" ).dispose();
        }
    </script>
</head>
<body>
<form id="form-hirarki" name="form-hirarki" method="POST" >
    <label class="tajuk">Penyata Stok Pengilang  </label></br>
    <label class="tajuksub"><?php echo $syarikat[0]["nama"];?>, <?php echo $bulannama[0]["bulan"]." ".$tahun;?></label><br/>
    <?php
    if($id_trans==1):
        $chart = '<chart bgcolor="FFFFFF" charttopmargin="0" chartleftmargin="0" chartrightmargin="0" bordercolor="FFFFFF"
                   canvasbordercolor="DFBAAD" xAxisMinValue="0" xAxisMaxValue="100" yAxisMinValue="0" yAxisMaxValue="100" 
                   bubbleScale="3" is3D="1" numDivLines="0" showFormBtn="0">
                    <dataset plotborderAlpha="0" >
                        <set x="50" y="90" width="120" height="90" color="FFFFFF" name="Mr. Harry Sawyer, CEO" alpha="100" toolText="Pengilang" id="CEO" imageNode="1" imageurl="../images/kilang.jpg" imageAlign="bottom" labelAlign="top" imageHeight="65" imageWidth="108" />
                        <set x="20" y="70" width="120" height="40" name="Name:Tom McQuin {BR}Age: 54yrs {BR}Designation:CTO" color="62D0FE" id="CTO" />
                        <set x="51" y="70" width="120" height="40" name="Name:Jim Kerry {BR}Age: 46yrs {BR}Designation:CFO" color="62D0FE" link="n-http://www.fusioncharts.com" id="CFO" />
                        <set x="80" y="70" width="120" height="40" name="Name:Michelle Saler {BR}Age: 58yrs {BR}Designation:COO" color="62D0FE" link="n-http://www.fusioncharts.com" id="COO" />
                    </dataset>
                    <connectors color="83C6E1" stdThickness="8">
                            <connector strength="0.45" from="CEO" to="CTO"  arrowAtStart="0" arrowAtEnd="1"/>
                            <connector strength="0.45" from="CEO" to="CFO"  arrowAtStart="0" arrowAtEnd="1" />
                            <connector strength="0.45" from="CEO" to="COO"  arrowAtStart="0" arrowAtEnd="1" />
                    </connectors>
                 </chart>';
    else:
            $chart = '<chart bgcolor="FFFFFF" charttopmargin="0" chartleftmargin="0" chartrightmargin="0" bordercolor="FFFFFF"
                   canvasbordercolor="DFBAAD" xAxisMinValue="0" xAxisMaxValue="100" yAxisMinValue="0" yAxisMaxValue="100" 
                   bubbleScale="3" is3D="1" numDivLines="0" showFormBtn="0">
                    <dataset plotborderAlpha="0" >
                        <set x="50" y="90" width="120" height="90" color="FFFFFF" name="Mr. Harry Sawyer, CEO" alpha="100" toolText="Pengilang" id="CEO" imageNode="1" imageurl="../images/kilang.jpg" imageAlign="bottom" labelAlign="top" imageHeight="65" imageWidth="108" />
                        <set x="20" y="70" width="120" height="40" name="Name:Tom McQuin {BR}Age: 54yrs {BR}Designation:CTO" color="62D0FE" id="CTO" />
                        <set x="51" y="70" width="120" height="40" name="Name:Jim Kerry {BR}Age: 46yrs {BR}Designation:CFO" color="62D0FE" link="n-http://www.fusioncharts.com" id="CFO" />                    
                    </dataset>
                    <connectors color="83C6E1" stdThickness="8">
                            <connector strength="0.45" from="CEO" to="CTO"  arrowAtStart="0" arrowAtEnd="1"/>
                            <connector strength="0.45" from="CEO" to="CFO"  arrowAtStart="0" arrowAtEnd="1" />
                    </connectors>
                 </chart>';
    endif;
            FC_SetRenderer( "javascript" );
             echo renderChart("../fusionchart/Charts/DragNode.swf",  "",$chart, "chart1ID", 1150, 500, false, true);
    ?>
    <input type="hidden" id="idchart" name="idchart" value="<?php echo $idchart;?>"/>
</form>
</body>
</html>

Test 2: i try again to create random chart id using php and had assign the value when render the chart like below code

$idchart        = rand(0,100000);

echo renderChart("../fusionchart/Charts/DragNode.swf",  "",$chart, $idchart, 1150, 500, false, true);

its working but i'm afraid it effect the memory for unused chart or to avoid memory leaks like mention in documentation.

 

Love to help any suggest or opinion.

 

Appreciate your response.

 

Thanks in advanced.

Edited by liza

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