Sign in to follow this  
geebee

Fusioncharts_Gen.php And Ajax Call

Recommended Posts

Trying to call a $.ajax function to render chart.

 

Here is the code when I click the button:

 

$("#myAjaxChartButton").live('click',function(){

var strURL = "/MyFCPHPClassCharts/Charts/FirstAjaxChart.php";

$.ajax({

type: "GET",

url: strURL,

success: function(msg){

$("#chartContainer").show().html(msg);

}

});

});

 

the FristAjaxChart.php :

<?php

include('../Class/FusionCharts_Gen.php');

# Create Column3D chart Object

$FC = new FusionCharts("Line2D","300","250");

# set the relative path of the SWF file

$FC->setSWFPath("../FusionCharts/");

# Set chart attributes

$strParam="caption=Weekly Sales;xAxisName=Week;yAxisName=Revenue;numberPrefix={:content:}quot;;

$FC->setChartParams($strParam);

# add chart values and category names

$FC->addChartData("40800","label=Week 1");

$FC->addChartData("31400","label=Week 2");

$FC->addChartData("26700","label=Week 3");

$FC->addChartData("54400","label=Week 4");

?>

 

<script language='javascript' src="MyFCPHPClassCharts/FusionCharts/FusionCharts.js"></script>

 

<?php

# Render Chart

$FC->renderChart();

?>

 

**********************************************************

 

All I get is a brief flash of the word "Chart." appear in the place where I want the chart to appear.

 

What am I missing?

 

PS This is just to test how I am supposed to render vis Ajax - so the code is very basic. Later I will build the details.

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