Fusion chart variable `$defaultParameterValues` found to be empty while exporting the chart as image/pdf-Collection of common programming errors

Somehow, I am not sure, how and why as I not aware whether you have modified any part of the code, the global $defaultParameterValues, that I find the php file is defined as the following:

$defaultParameterValues = array( 
"exportfilename"       => "FusionCharts",
"exportaction"         => "download",
"exporttargetwindow"   => "_self",
"exportformat"         => "PDF"
);  

is not being referenced inside the function parseExportParams and thus getting an undefined array which can not be iterated!!

One way to resolve this is to get the original FCExporter.php from the FusionCharts pack and then replace this with you own or do a diff of the two files to check if you have modified anything anywhere that is breaking this.

The other way is:

to check whether $defaultParameterValues is an array and if not – instantiate it.

if (!isset($defaultParameterValues)) {
$defaultParameterValues = array();
} 

Meanwhile, there is anther alternative to extend the parameters with default values:

Modify the parseExportParams to replace the existing:

foreach ( $defaultParameterValues as $key => $value )
{
    // if a parameter from the default parameter array is not present
    // in the $params array take the parameter and value from default
    // parameter array and add it to params array
    // This is needed to ensure proper export  
    $params [$key ] =  @$params[$key ] ? $params[$key ] : $value ;
}

with

if (isset($defaultParameterValues) && is_array($defaultParameterValues)) {
    $params = $params + $defaultParameterValues;
} 

Originally posted 2013-11-27 05:08:48.