SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Want to dynamically create graphs using XML + PHP

    Hi All,

    I have been looking at this: http://www.maani.us/xml_charts/.

    What this does, is it allows you to create an XML file, then from a HTML page this XML file gets called as the source, and a graph is created. The HTML page is basic, and has Javascript which looks like this:

    Code:
    <script language="JavaScript" type="text/javascript">
    <!--
    if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
    	alert("This page requires AC_RunActiveContent.js.");
    } else {
    	var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
    	if(hasRightVersion) { 
    		AC_FL_RunContent(
    			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',
    			'width', '400',
    			'height', '250',
    			'scale', 'noscale',
    			'salign', 'TL',
    			'bgcolor', '#777788',
    			'wmode', 'opaque',
    			'movie', 'charts',
    			'src', 'charts',
    			'FlashVars', 'library_path=charts_library&xml_source=sample.xml', 
    			'id', 'my_chart',
    			'name', 'my_chart',
    			'menu', 'true',
    			'allowFullScreen', 'true',
    			'allowScriptAccess','sameDomain',
    			'quality', 'high',
    			'align', 'middle',
    			'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
    			'play', 'true',
    			'devicefont', 'false'
    			); 
    	} else { 
    		var alternateContent = 'This content requires the Adobe Flash Player. '
    		+ '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
    		document.write(alternateContent); 
    	}
    }
    // -->
    </script>
    As you see, the only portion which references the XML file is FlashVars', 'library_path=charts_library&xml_source=sample.xml'.

    Using data from a MySQL database I am looking at creating the XML, but how can I do this dynamically? I dont want to create a new XML file everything a user wants to see a new graph, but it seems the above javascript needs to reference a physical file?

    Alternatively, if there are any other ways to create nice graphs input is appreciated.

  2. #2
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    358
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Replace sample.xml with sample.php and create PHP script on the server that creates and returns XML.
    I'm creating trouble-free Apache, PHP, MySQL installer, WITSuite,
    and use it to setup my development environment.
    Demo, support, contact. Questions?

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Canada
    Posts
    373
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by alex.w747 View Post
    Replace sample.xml with sample.php and create PHP script on the server that creates and returns XML.
    I get that.

    However, I somehow have to call the file that creates the graph in such a way that I can use PHP/MySQL to grab the specific data I need.

  4. #4
    SitePoint Member
    Join Date
    May 2009
    Posts
    13
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by tdob View Post
    I get that.

    However, I somehow have to call the file that creates the graph in such a way that I can use PHP/MySQL to grab the specific data I need.
    I would like to do the same thing in my project, did you find out how to create a graph with data från mysql and present it with php?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •