Here are a sample of code I have written to get my charts to populate.This is a simple 2D pie chart with v3 charts. There are two seperate files, one is a data file and the other displays the chart and other html items on the viewable page. What this code is from is the data file. Hope it helps you out.
<?php
session_start(); // used to start a session for security reasons
include ('login.php'); // security files
include ('names.php'); //misc files
include './includes/Connection_'.$conn.'.php'; // connection file with functions
include './includes/chart_colors.php';
// get the variables posted in the page form; prepend 'r_' to them
import_request_variables("gp", "r_");
$date = date("m/d/y");
// get the customer data
// query the MySQL database
$query = "SELECT SUM((qty_ord - qty_ship) * line_price) as sales, reason_code, reason_group,
reason_name FROM sales_late_orders WHERE closed = 'no' GROUP BY reason_group, reason_name";
// result of the query
$result = db_query($query, $DBLink) or die ('Error: Cannot get Data!');
// generate the XML for the chart
$strXML = "<graph caption='Late Orders by Reason ".$date."' useRoundEdges='1' chartLeftMargin='0'
chartRightMargin='5' chartTopMargin='0' chartBottomMargin='0' decimalPrecision='0'
showPercentageValues='0' showNames='1' rotateNames='1' numberPrefix='".$symbol."'
showPercentageInLabel='0' canvasBgColor='FFFFFF,".$_GET["daColor"]."' canvasBgAngle='270'
canvasBgAlpha='90' bgColor='".$strColor[10]."' showAlternateHGridColor='0' showBorder='0'
baseFontSize='12' baseFontColor='".$strColor[8]."'>";
// connection settings for other servers
if ($hostname == "192.168.5.50") {
switch ($cCo) {
case "csgc":
$file = "csgc/";
break;
case "ucl":
$file = "csgw/";
break;
}
}
// as long as there is a result in the row (function called out in the connection file) it will keep doing the loop
while ($row = db_fetch_assoc($result)){
// append the data
if ($row["reason_code"] == 0){
$reason = "Unassigned";
}
else {
if ($row["reason_group"] == $row["reason_name"]) {
$reason = $row["reason_group"];
}
else {
$reason = $row["reason_group"]." - ".$row["reason_name"];
}
}
$htmlLink = "" target=_"blank" class="SmlLinks">http://".$hostname."/cgi-bin/wspd_cgi.sh/WService=ws".$broker."/dash/".$file."reason1.html?cReason=".$row["reason_code"];
$strXML = $strXML."<set value='".$row["sales"]."' name='".$reason."' link='".$htmlLink."' />"; }
// close tags
// concatenate to form the whole XML document
$strXML = $strXML;
$strXML = $strXML."</graph>";
// output the data
echo($strXML);
?>