Sign in to follow this  
enna

Problem Generating Chart

Recommended Posts

hi,i am trying to get the data from my database and i successfully got what i wanted..

but when i added a link that when clicked should alter the content of the div (where the chart is placed)

with a new chart with different data from the database, i only get the word "Chart" inside the div..

can someone enlighten me?

thank you!

 

 

 

heres a snippet of the codes:

 

<script>

 

function openProvList(code){

var welcome= document.getElementById("graphs");

$.ajax({

type: "POST",

url: "obpims.php",

data: "code="+ code,

dataType:"html",

success: function (html) {

welcome.innerHTML = html;

}

});

}

</script>

 

 

<?php include('../dbconnect.php'); include("FusionCharts.php");

?>

 

<div id="graphs">

<a href="#" onClick="openProvList(<?php echo $rowProv['province_code']; ?>)">CLICK ME</a>

<div class="gen-chart-render">

<?php

$strXML1 = "<chart caption='ToTal Barangay Projects' pieSliceDepth='30' showBorder='1' formatNumberScale='0' xAxisName='City/Municipality' yAxisName='Projects' numberSuffix=' projects'>";

$strQuery1 = "select * from province";

$result1 = mysql_query($strQuery1) or die(mysql_error());

if ($result1) {

while($ors1 = mysql_fetch_array($result1)) {

$str1 = "select COUNT(*) from project a, brgy b, city c, province d where a.brgy_code=b.brgy_code and b.city_code=c.city_code and c.province_code=". $ors1['province_code'];

$result12 = mysql_query($str1) or die(mysql_error());

if($result12){

$cnt1 = mysql_fetch_row($result12);

}

else{ echo "Error in query: ".mysql_error();}

$strXML1 .= "<set label='" . $ors1['province_name'] . "' value='" . $cnt1[0] . "' />";

mysql_free_result($result12);

}

}

$strXML1 .= "</chart>";

echo renderChart("../tmp/FusionCharts/Column3D.swf", "", $strXML1, "myChartId2", 600, 260, false, false);

?>

</div>

</div>

 

 

inside obpims.php that should replace the content of div (id='graphs')

 

 

 

<?php include('../dbconnect.php'); include("FusionCharts.php"); $code = htmlspecialchars(trim($_POST['code']));

?>

 

<div class="gen-chart-render">

<?php

$strXML = "<chart caption='ToTal Allocated Budget' pieSliceDepth='30' showBorder='1' formatNumberScale='0' numberPrefix='Php '>";

$strQuery = "select * from city";

$result = mysql_query($strQuery) or die(mysql_error());

if ($result) {

while($ors = mysql_fetch_array($result)) {

$str = "select sum(cost) as totalCost from project a, brgy b, city c where a.brgy_code=b.brgy_code and b.city_code=". $ors['city_code'];

$result2 = mysql_query($str) or die(mysql_error());

$cnt = mysql_fetch_array($result2);

$strXML .= "<set label='" . $ors['city_name'] . "' value='" . $cnt[totalCost] . "' />";

mysql_free_result($result2);

}

}

$strXML .= "</chart>";

echo renderChart("Pie3D.swf", "", $strXML, "myChartId4", 600, 260, false, false);

?>

</div>

Share this post


Link to post
Share on other sites

i have found the solution.. i just need to change renderChart("Pie3D.swf", "", $strXML, "myChartId4", 600, 260, false, false);

to renderChartHTML("Pie3D.swf", "", $strXML, "myChartId4", 600, 260, false, false);

*cheers!*

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

We are glad to know that you have managed to solve your problem.

 

Keep FusionCharting!biggrin.gif

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