hi...i've research fusion chart... and i find it nice ..

I would like to retrieve from my database(SQL) and graph it using php

is there anybody here experience working with fusion chart and php?...

Recommended Answers

All 5 Replies

According to the documentation you have to provide the data in XML or JSON format.

yeah i read it :D .... im currently working with SQL-php- fusionchart and i use odbc connection ... im learning xml about 2 days ago and im hoping someone experience odbc with fusion chart and help me just only a basic of it..

this is my code with odbc ...there's something wrong with it (it will not display the chart)...

<?php
//We've included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
//functions to help us easily embed the charts and connect to a database.
include("/Includes/FusionCharts.php");

?>
<HTML>
   <HEAD>
      <TITLE>FusionCharts Free - Database Example</TITLE>
      <SCRIPT LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
   </HEAD>
   <BODY>
   <CENTER>
   <?php   
  
$conn=odbc_connect('datasourcegaby','','');



$firststring= "Select POWER_GEN_1_VAL0,POWER_GEN_2_VAL0 from generators";

 
$rs=odbc_exec($conn,$firststring);

 $conn = connectToDB();


$strXML = "<graph caption='Sales' subCaption='of the month' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>";



while (odbc_fetch_row($rs))

{

$g1=odbc_result($rs,"POWER_GEN_1_VAL0");

$g2=odbc_result($rs,"POWER_GEN_2_VAL0");

$strXML .= "<set name='POWER_GEN_1_VAL0' value='".$rs['POWER_GEN_1_VAL0']."' />";
$strXML .= "<set name='POWER_GEN_2_VAL0' value='".$rs['POWER_GEN_2_VAL0']."' />";

}

$strXML .= "</graph>";



//Create the chart - Column 3D Chart with data from strXML variable using dataXML method

echo renderChartHTML("./Charts/FCF_Bar2D.swf", "", $strXML, "ad", 800, 600, false);

?> 

</BODY>
</HTML>

table name:generators

column name1: POWER_GEN_1_VAL0
column name2: POWER_GEN_2_VAL0

ohhh... i got it! ..


this is where i stuck...

echo renderChartHTML("./Charts/FCF_Bar2D.swf", "", $strXML, "ad", 800, 600, false);

it must be:
echo renderChartHTML("./MyFolderHere/FCF_Bar2D.swf", "", $strXML, "ad", 800, 600, false);

I am getting error as:
include(includes/fusioncharts.php): failed to open stream: No such file or directory in C:\xampp\htdocs\ghi.php on line 5

My code is :

<script type="text/javascript" src="/path/to/fusioncharts.js"></script> <script type="text/javascript" src="/path/to/themes/fusioncharts.theme.ocean.js"></script> <?php

include("includes/fusioncharts.php");
$columnChart = new FusionCharts("column2d", "ex1" , 600, 400, "chart-1", "json", '{  
       "chart":{  
          "caption":"Harry SuperMart",
          "subCaption":"Top 5 stores in last month by revenue",
          "numberPrefix":"$",
          "theme":"ocean"
       },
       "data":[  
          {  
             "label":"Bakersfield Central",
             "value":"880000"
          },
          {  
             "label":"Garden Groove harbour",
             "value":"730000"
          },
          {  
             "label":"Los Angeles Topanga",
             "value":"590000"
          },
          {  
             "label":"Compton-Rancho Dom",
             "value":"520000"
          },
          {  
             "label":"Daly City Serramonte",
             "value":"330000"
          }
       ]
    }');
    // Render the chart
    $columnChart->render();
    ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.