d_goodgame

Simple Chart in Wordpress

Recommended Posts

<?php 
	include("/fusioncharts.php"); 
?>

<HTML>

<HEAD>
<?php
	echo "in head";
?>

	<TITLE>Simple Chart Example</TITLE>
	
	
<?php
	echo " in head2";
?>
</HEAD>

<BODY>
<?php
	echo " in body";
?>

<?php

	echo " create string";
	
    //Create an XML data document in a string variable
    $strXML  = "";
    $strXML .= "<graph caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units'
    decimalPrecision='0' formatNumberScale='0'>";
    $strXML .= "<set name='Jan' value='462' color='AFD8F8' />";
    $strXML .= "<set name='Feb' value='857' color='F6BD0F' />";
    $strXML .= "<set name='Mar' value='671' color='8BBA00' />";
    $strXML .= "<set name='Apr' value='494' color='FF8E46' />";
    $strXML .= "<set name='May' value='761' color='008E8E' />";
    $strXML .= "<set name='Jun' value='960' color='D64646' />";
    $strXML .= "<set name='Jul' value='629' color='8E468E' />";
    $strXML .= "<set name='Aug' value='622' color='588526' />";
    $strXML .= "<set name='Sep' value='376' color='B3AA00' />";
    $strXML .= "<set name='Oct' value='494' color='008ED6' />";
    $strXML .= "<set name='Nov' value='761' color='9D080D' />";
    $strXML .= "<set name='Dec' value='960' color='A186BE' />";
    $strXML .= "</graph>";
    
      echo "string done";

    //Create the chart - Column 3D Chart with data from strXML variable using dataXML method
    echo renderChartHTML("/FusionCharts/Column3D.swf", "", $strXML, "myNext", 600, 300);
?>
      
</BODY>
</HTML>

I'm new to Wordpress, and I'm trying to get FusionCharts to work on it.  I've followed lots of examples in this forum, but can't seem to get anything to show up.   I just don't feel like the Include ("fusioncharts.php"); is really loading.   The code I have is above, it is for the following site:   http://discounthuntgear.com/tryme.php

 

I also have an image of the "File Manager"...the fusioncharts.php file is in the same folder as the tryme.php that is trying to call it.   Any advise would be much appreciated!!!

 

 

 

post-66543-0-13947500-1436731021_thumb.png

Share this post


Link to post
Share on other sites

Hi,

 

Welcome to FusionCharts Forum.

 

It seems that you are using older version of FusionCharts and its PHP wrapper. Please check and confirm with the latest version.

 

Please refer the latest documentation for implementation: http://www.fusioncharts.com/dev/usage-guide/using-with-server-side-languages/php/introduction.html

 

You can refer the following sample using XML:
 
Hope this helps.

Share this post


Link to post
Share on other sites

Thanks Vishalika, I did have some out of date files.    I updated to the ones in the link you provided.

 

I have the php wrapper file that I downloaded in the fusioncharts folder I created.   However, as soon as the code hits the "include("fusioncharts/fusioncharts.php"); statement..it dies.   If I comment it out, it runs all the way through till it gets to the render portion (and then doesn't know what to do with it, as we'd expect with the wrapper file in there).   Do you know of something that would cause it to just stop as soon as it tries to include that file?

 

http://discounthuntgear.com/tryme.php

 

Thanks again.

Share this post


Link to post
Share on other sites

Hi,

 

Can you please try using require() to include the *.php file or try uploading the *.php within the server through FTP?

For more information, please refer the following link:
http://wp.tutsplus.com/tutorials/creative-coding/how-to-include-and-require-files-and-templates-in-wordpress/

http://wordpress.org/support/topic/how-to-upload-php-file

 

Hope this helps.

Share this post


Link to post
Share on other sites

Hi,

I went into the fusioncharts.php file and enabled some error reporting.

 

Here's what it's spitting out.   "PHP Parse error:  syntax error, unexpected '[' in /home6/discowo3/public_html/fusioncharts/fusioncharts.php on line 5

Share this post


Link to post
Share on other sites

Corrected.   The Parse error was due to the platform I'm on running PHP 5.2, and the wrapper was for 5.4.  I was able to find a compatible version of the wrapper, and now it works just fine.   The other piece that helped it was changing the include statement to --> include($_SERVER['DOCUMENT_ROOT']."/fusioncharts/fusioncharts.php");   I'm not sure if it was just a CPanel problem...but the document root function was needed to get it to the correct file. 

 

Thanks again for ya'lls help, and getting me pointed in the right direction.   I've been using FusionCharts for years now (with ASP.NET)...this is my first venture in doing it in PHP...so it took me a while to get it going.   Couldn't have done it without ya'lls help...Thanks again.

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