{"id":1549,"date":"2022-08-30T15:17:27","date_gmt":"2022-08-30T15:17:27","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/27\/fusion-chart-variable-defaultparametervalues-found-to-be-empty-while-exporting-the-chart-as-image-pdf-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:27","modified_gmt":"2022-08-30T15:17:27","slug":"fusion-chart-variable-defaultparametervalues-found-to-be-empty-while-exporting-the-chart-as-image-pdf-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/fusion-chart-variable-defaultparametervalues-found-to-be-empty-while-exporting-the-chart-as-image-pdf-collection-of-common-programming-errors\/","title":{"rendered":"Fusion chart variable `$defaultParameterValues` found to be empty while exporting the chart as image\/pdf-Collection of common programming errors"},"content":{"rendered":"<p>Somehow, I am not sure, how and why as I not aware whether you have modified any part of the code, the global <code>$defaultParameterValues<\/code>, that I find the php file is defined as the following:<\/p>\n<pre><code>$defaultParameterValues = array( \n\"exportfilename\"       =&gt; \"FusionCharts\",\n\"exportaction\"         =&gt; \"download\",\n\"exporttargetwindow\"   =&gt; \"_self\",\n\"exportformat\"         =&gt; \"PDF\"\n);  \n<\/code><\/pre>\n<p>is not being referenced inside the function <code>parseExportParams<\/code> and thus getting an undefined array which can not be iterated!!<\/p>\n<p>One way to resolve this is to get the original <code>FCExporter.php<\/code> 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.<\/p>\n<p>The other way is:<\/p>\n<p>to check whether <code>$defaultParameterValues<\/code> is an array and if not &#8211; instantiate it.<\/p>\n<pre><code>if (!isset($defaultParameterValues)) {\n$defaultParameterValues = array();\n} \n<\/code><\/pre>\n<p>Meanwhile, there is anther alternative to extend the parameters with default values:<\/p>\n<p>Modify the <code>parseExportParams<\/code> to replace the existing:<\/p>\n<pre><code>foreach ( $defaultParameterValues as $key =&gt; $value )\n{\n    \/\/ if a parameter from the default parameter array is not present\n    \/\/ in the $params array take the parameter and value from default\n    \/\/ parameter array and add it to params array\n    \/\/ This is needed to ensure proper export  \n    $params [$key ] =  @$params[$key ] ? $params[$key ] : $value ;\n}\n<\/code><\/pre>\n<p>with<\/p>\n<pre><code>if (isset($defaultParameterValues) &amp;&amp; is_array($defaultParameterValues)) {\n    $params = $params + $defaultParameterValues;\n} \n<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-27 05:08:48. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>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( &#8220;exportfilename&#8221; =&gt; &#8220;FusionCharts&#8221;, &#8220;exportaction&#8221; =&gt; &#8220;download&#8221;, &#8220;exporttargetwindow&#8221; =&gt; &#8220;_self&#8221;, &#8220;exportformat&#8221; =&gt; &#8220;PDF&#8221; ); is not being referenced [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1549","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1549","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1549"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1549\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}