Sign in to follow this  
STM71

Chart Renders With Flash But Will Not With Javascript In Drupal 6.25

Recommended Posts

Please help. The example below, which was more or less copied from the FusionCharts site, works just fine when rendered with Flash, but will not render with Javascript. When I attempt to render with Javascript using "FC_SetRenderer( "javascript");" I get the message, "Loading Chart. Please Wait" that never goes away. The jquery.min, FusionCharts.HC & FusionChart.HC.Chart JavaScript files are present in the same directory as FusionCharts.js.

 

We are currently using the trail version of FusionCharts XT, but will move to the paid version if we can get this issue worked out.

 

Any assistance you can provide would be greatly appreciated.

 

<?php drupal_add_js('/FusionCharts/FusionCharts.js'); ?>

 

<?php

 

//We have included ../Includes/FusionCharts.php, which contains functions

//to help us easily embed the charts.

include("../includes/FusionCharts.php");

 

?>

 

 

<?php

 

// Store Name of Products

$arrData[0][1] = "Product A";

$arrData[1][1] = "Product B";

$arrData[2][1] = "Product C";

$arrData[3][1] = "Product D";

$arrData[4][1] = "Product E";

$arrData[5][1] = "Product F";

// Store sales data for current year

$arrData[0][2] = 567500;

$arrData[1][2] = 815300;

$arrData[2][2] = 556800;

$arrData[3][2] = 734500;

$arrData[4][2] = 676800;

$arrData[5][2] = 648500;

// Store sales data for previous year

$arrData[0][3] = 547300;

$arrData[1][3] = 584500;

$arrData[2][3] = 754000;

$arrData[3][3] = 456300;

$arrData[4][3] = 754500;

$arrData[5][3] = 437600;

 

 

// Now, we need to convert this data into multi-series XML.

// We convert using string concatenation.

// $strXML - Stores the entire XML

// $strCategories - Stores XML for the <categories> and child <category> elements

// $strDataCurr - Stores XML for current year's sales

// $strDataPrev - Stores XML for previous year's sales

// Initialize <chart> element

$strXML = "<chart caption='Sales by Product' numberPrefix='$' formatNumberScale='1' rotateValues='1' placeValuesInside='1' decimals='0' >";

// Initialize <categories> element - necessary to generate a multi-series chart

$strCategories = "<categories>";

// Initiate <dataset> elements

$strDataCurr = "<dataset seriesName='Current Year'>";

$strDataPrev = "<dataset seriesName='Previous Year'>";

// Iterate through the data

foreach ($arrData as $arSubData) {

// Append <category label='...' /> to strCategories

$strCategories .= "<category label='" . $arSubData[1] . "' />";

// Add <set value='...' /> to both the datasets

$strDataCurr .= "<set value='" . $arSubData[2] . "' />";

$strDataPrev .= "<set value='" . $arSubData[3] . "' />";

}

// Close <categories> element

$strCategories .= "</categories>";

//Close <dataset> elements

$strDataCurr .= "</dataset>";

$strDataPrev .= "</dataset>";

 

// Assemble the entire XML now

$strXML .= $strCategories . $strDataCurr . $strDataPrev . "</chart>";

 

#FC_SetRenderer( "javascript");

 

// Create the chart - MS Column 3D Chart with data contained in strXML

echo renderChart("/drupalcharting/FusionCharts/MSColumn3D.swf", "", $strXML, "productSales", 600, 300, true, true);

?>

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

The code seems to be alright.

 

I see that you have commented the line #FC_SetRenderer( "javascript"); Please remove the comment.

 

Also, can you please confirm once again that you have placed all the JavaScript files in the same directory as that of FusionCharts.js file?

 

This error message will be seen when the other JavaScript files are unavailable.

 

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