CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 FlashCharts and CCS

Print topic Send  topic

Author Message
smokingguns


Posts: 51
Posted: 10/19/2007, 7:00 AM

Hey all,
Here is how you generate flash charts based on a XML data source using PHP.The data is retrieved from DB and written to a xml file. I created a CCS page called 'ExampleChart'.

  
$db = new clsDB<ConnectionName>();  
$strQuery ="select field1, field2 from tablename ...... " ;   
$db->query($strQuery);  
$rows=$db->num_rows($db->f("field1")); //get number of rows returned by the query  
$Array1=array();  
$Array2=array();  
$i=0;  
     while($db->next_record())  
    {  
       $Array1[$i] = $db->f("field1");   
       $Array2$i]=$db->f("field2");   
       $i++;  
     }  
     
    $strXML ="<chart><chart_data><row><null/>";// xml generation  
  
    for($i=0;$i<$rows;$i++)  
   $strXML.="<string>".$field1[$i]."</string>";  
  
  $strXML.="</row><row><string></string>";  
  
   for($i=0;$i<$rows;$i++)  
  $strXML.="<number>".$field2[$i]."</number>";  
  
$strXML.="</row></chart_data><chart_grid_h alpha='20' color='000000' thickness='0' type='solid' />";  
  
$strXML.="<chart_rect positive_color='ffffff' positive_alpha='20' negative_color='ff0000' negative_alpha='10' />";  
  
 $strXML.="<chart_type>pie</chart_type>";  
  
$strXML.="<chart_value color='ffffff' alpha='90' font='arial' bold='true' size='10' position='inside' prefix='' suffix='' decimals='0' separator='' as_percentage='false' />";  
  
$strXML.="<draw>";  
  
$strXML.="<text color='000000' alpha='10' font='arial' rotation='0' bold='true' size='30' x='0' y='140' width='400' height='150' h_align='center' v_align='bottom'>|||||||||||||||||||||||||||||||||||||||||||||||</text></draw>";  
  
$strXML.="<legend_label layout='horizontal' bullet='circle' font='arial' bold='true' size='9' color='ffffff' alpha='85'/>";  
  
$strXML.="<legend_rect fill_color='ffffff' fill_alpha='10' line_color='000000' line_alpha='0' line_thickness='0' /></chart>";  
     $strXML.="<series_color><color>ddaa41</color><color>88dd11</color><color>4e62dd</color><color>ff8811</color><color>4d4d4d</color><color>5a4b6e</color></series_color></chart>";   
  
// The xml string has been constructed.. We now dump this string into a XML file  
  
$myfile="Dir/example.xml";  
$myfilehandle= fopen($myfile, 'w') or die("can't open file");  
fclose($myfilehandle);  
  
$fh = fopen($myfile, 'w') or die("can't open file");  
fwrite($fh, $strXML);  
fclose($fh);  
  
$db->close();  
  
This code is written in my page's(ExampleChart) Before Show event

To actually render the chart I created a html page called example.html. I provided a Link on ExampleChart to 'example.html'

This is the html source of 'example.html':
  
  
<body>  
<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"  
	codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"   
	WIDTH="400"   
	HEIGHT="250"   
	id="charts"   
	ALIGN="">  
<PARAM NAME=movie VALUE="charts.swf?library_path=charts_library&xml_source=Dir/example.xml">  
<PARAM NAME=quality VALUE=high>  
<PARAM NAME=bgcolor VALUE=#666666>  
  
<EMBED src="charts.swf?library_path=charts_library&xml_source=Dir/example.xml"  
       quality=high   
       bgcolor=#666666    
       WIDTH="400"   
       HEIGHT="250"   
       NAME="charts"   
       ALIGN=""   
       swLiveConnect="true"   
       TYPE="application/x-shockwave-flash"   
       PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">  
</EMBED>  
</OBJECT>  
  
</body>  

Here is the website u can refer to, for more examples:

http://maani.us
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

MS Access to Web

Convert MS Access to Web.
Join thousands of Web developers who build Web applications with minimal coding.

CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.