Example #1
0
function FusionCharts($chart_type = '', $width = "300", $height = "250")
{
    require_once 'fusion/FusionCharts_Gen.php';
    $FC = new FusionCharts($chart_type, $width, $height);
    $FC->setSWFPath(base_url() . "chart/");
    return $FC;
}
Example #2
0
 function mychart()
 {
     //$this->load->libraries('fusion_pi');
     $arrData = array();
     $FC = new FusionCharts("Column3D", "720", "400");
     /*$arrData = array( 500, 269, 254, 895, 633);  
       foreach( $arrData as $i=>$data ){  
           $FC->addChartData( $data );  
       } */
     //$sql="select count(distinct(nama_spb)) as nama_spb,month(tgl_spb) as bln from spb group by concat(month(tgl_spb),year(tgl_spb))";
     //echo $sql;
     $FC->setDataURL("graph.xml");
     $strParam = "numberSuffix=; formatNumberScale=0; decimalPrecision=0; xAxisName=Bulan; animation=1";
     $FC->setChartParams($strParam);
     $FC->setChartMessage("ChartNoDataText=Chart Data not provided; PBarLoadingText=Please Wait.The chart is loading...");
     return $FC->renderChart(false, false);
 }
Example #3
0
 function makeBar($val, $IDSuffix)
 {
     //---------- Creating First Chart ----------------------------------------------
     # Create FusionCharts PHP object
     $FC = new FusionCharts("Column3D", "300", "250", "myChartId" . $IDSuffix);
     # set the relative path of the swf file
     $FC->setSWFPath("../../FusionCharts/");
     # Define chart attributes#  Set chart attributes
     $strParam = "caption=Weekly Sales;subcaption={$val};xAxisName=Week;yAxisName=Revenue;numberPrefix=\$";
     # Setting chart attributes
     $FC->setChartParams($strParam);
     # add chart values and category names for the First Chart
     $FC->addChartData("40800", "Label=Week 1");
     $FC->addChartData("31400", "Label=Week 2");
     $FC->addChartData("26700", "Label=Week 3");
     $FC->addChartData("54400", "Label=Week 4");
     //-------------------------------------------------------------------
     $FC->renderChart();
 }
Example #4
0
                $start = $_POST["start"];
                $end = $_POST["end"];
                if (strtotime($end) < strtotime($start)) {
                    echo "Tanggal tidak valid";
                } else {
                    $per_periode = "SELECT nama_barang, sum(n_pakai) as 'jumlah pemakaian' FROM t_pemakaian WHERE tanggal<='" . $end . "' and tanggal>='" . $start . "' GROUP BY kode_barang";
                    $result = $conn->query($per_periode);
                    echo "<br>";
                    if ($result->num_rows > 0) {
                        include "fusioncharts.php";
                        $arrData = array("chart" => array("caption" => "Pemakaian ATK dari periode " . $start . " sampai " . $end, "xAxisName" => "Nama Barang", "yAxisName" => "Jumlah Pemakaian (pcs)"));
                        $arrData["data"] = array();
                        while ($row = mysqli_fetch_array($result)) {
                            array_push($arrData["data"], array("label" => $row["nama_barang"], "value" => $row["jumlah pemakaian"]));
                        }
                        $chart = new FusionCharts("column2D", "periodChart", 600, 400, "chart-1", "json", json_encode($arrData));
                        $chart->render();
                        ?>
						    <div id="chart-1"></div>
						    <?php 
                    } else {
                        echo "tidak ada hasil";
                    }
                }
            }
        }
    }
}
$conn->close();
?>
						</div>
Example #5
0
	-->
	</style>
</HEAD>
<BODY>

<CENTER>
<h2>FusionCharts Examples</h2>
<h4>Example using XML having multilingual text</h4>
<?php 
//This page demonstrates the ease of generating charts containing UTF-8 encoded
//multilingual text using FusionCharts PHPClass.
//For this chart, we've cread a chart  object used FusionCharts PHP Class
//supply chart data and configurations to it and render chart using the instance
//Here, we've kept this example very simple.
# Create column 2d chart object
$FC = new FusionCharts("Column2D", "500", "400");
# Set Relative Path of swf file.
$FC->setSWFPath("../../FusionCharts/");
# Set Chart attributes
$FC->setChartParams("caption=Monthly Sales Summary;subcaption=For the year 2008;");
$FC->setChartParams("xAxisName=Month;yAxisName=Sales;numberPrefix=\$;showNames=1;");
$FC->setChartParams("showValues=0;showColumnShadow=1;animation=1;");
$FC->setChartParams("baseFontColor=666666;lineColor=FF5904;lineAlpha=85;");
$FC->setChartParams("valuePadding=10;labelDisplay=rotate;useRoundEdges=1");
#add chart data values and category names
$FC->addChartData("17400", "Label=januári");
$FC->addChartData("19800", "Label=Fevruários");
$FC->addChartData("21800", "Label=مارس");
$FC->addChartData("23800", "Label=أبريل");
$FC->addChartData("29600", "Label=五月");
$FC->addChartData("27600", "Label=六月");
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column2D chart Object
$FC = new FusionCharts("column2D", "300", "250");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Weekly Sales;xAxisName=Week;yAxisName=Revenue;numberPrefix=\$";
# Set chart attributes
$FC->setChartParams($strParam);
# add chart values and category names
$FC->addChartData("40800", "label=Week 1");
$FC->addChartData("31400", "label=Week 2");
$FC->addChartData("26700", "label=Week 3");
$FC->addChartData("54400", "label=Week 4");
# Add First TrendLine
$FC->addTrendLine("startValue=42000;color=ff0000");
# Add Second TrendLine
$FC->addTrendLine("startValue=30000;color=008800;displayvalue=Average;showOnTop=1");
# Add  TrendZone
$FC->addTrendLine("startValue=50000;endValue=60000;color=0000ff;alpha=20;displayvalue=Dream Sales;showOnTop=1;isTrendZone=1");
?>
<html>
  <head>
    <title>First Chart - Advanced - Add Trendlines : Using FusionCharts PHP Class</title>
    <script language='javascript' src='../FusionCharts/FusionCharts.js'></script>
  </head>
  <body>
Example #7
0
<?php

/**
 * Created by PhpStorm.
 * User: Allan Wiz
 * Date: 4/17/15
 * Time: 4:48 PM
 */
include '../classes/aardb_conn.php';
include '../charts/JSClass/FusionCharts_Gen.php';
global $session, $database;
global $conn;
$FC = new FusionCharts("FC_Line.swf", "900", "450");
$FC->setDataBaseType("Oracle");
$FC->setSwfPath("../Charts/");
$strParam = "caption=INTEREST VIEW REPORT (for the last 14 days);subCaption=BY APPLICABLE DATE ; showNames='1';pieSliceDepth=30;showBorder=1;numberSuffix= %; formatNumberScale='0'; xAxisName=Date; pYAxisName=Net Asset Value;sYAxisName=BalancedFund";
$FC->setChartParams($strParam);
$start = date("d/M/Y", strtotime('-50 days'));
$today = date("d/M/Y");
$sql = "SELECT I_RATES.RATE_ID, I_RATES.RATE_DATE AS DATEY, I_RATES.RATE AS RATE, SECURITIES.DESCRIPT AS DESCRIPTION FROM I_RATES INNER JOIN\r        SECURITIES ON I_RATES.SECURITY_CODE = SECURITIES.SECURITY_CODE WHERE I_RATES.CONFIRMD = 1 AND I_RATES.RATE_DATE  BETWEEN '{$start}' AND '{$today}' ORDER BY I_RATES.RATE_DATE";
$result = oci_parse($conn, $sql) or die("");
oci_execute($result);
if ($result) {
    //$FC->addCategoryFromDatabase($result,"DESCRIPTION");
    $FC->addDataFromDatabase($result, "RATE", "DATEY");
}
print $FC->getXML();
Example #8
0
// If the query returns a valid response, prepare the JSON string
if ($result) {
    // The `$arrData` array holds the chart attributes and data
    $arrData = array("chart" => array("caption" => "Cereal Crop Index", "paletteColors" => "#0075c2", "bgColor" => "#ffffff", "borderAlpha" => "20", "canvasBorderAlpha" => "0", "usePlotGradientColor" => "0", "plotBorderAlpha" => "10", "showXAxisLine" => "1", "xAxisLineColor" => "#999999", "showValues" => "0", "divlineColor" => "#999999", "divLineIsDashed" => "1", "showAlternateHGridColor" => "0"));
    $arrData["data"] = array();
    // Push the data into the array
    while ($row = mysqli_fetch_array($result)) {
        array_push($arrData["data"], array("label" => $row["district_name"], "value" => $row["cerial_index"]));
    }
    /*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */
    $jsonEncodedData = json_encode($arrData);
    /*Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor.*/
    $columnChart1 = new FusionCharts("Column3D", "myFirstChart1", 1000, 500, "chart-1", "json", $jsonEncodedData);
    $columnChart2 = new FusionCharts("Pie3D", "myFirstChart2", 1000, 500, "chart-2", "json", $jsonEncodedData);
    $columnChart3 = new FusionCharts("line", "myFirstChart3", 1000, 500, "chart-3", "json", $jsonEncodedData);
    $columnChart4 = new FusionCharts("area2D", "myFirstChart4", 1000, 500, "chart-4", "json", $jsonEncodedData);
    // Render the chart
    $columnChart1->render();
    $columnChart2->render();
    $columnChart3->render();
    $columnChart4->render();
    // Close the database connection
    $dbhandle->close();
}
?>
    <div id="chart-1"><!-- Fusion Charts will render here--></div>
    <div id="chart-2"><!-- Fusion Charts will render here--></div>
    <div id="chart-3"><!-- Fusion Charts will render here--></div>
    <div id="chart-4"><!-- Fusion Charts will render here--></div>

   </body>
	</style>
</HEAD>
<BODY>

<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> -Database and Drill-Down Example</h2>


<?php 
//In this example, we show how to connect FusionCharts to a database.
//For the sake of ease, we've used an MySQL databases containing two
//tables.
// Connect to the Database
$link = connectToDB();
# Create pie 3d chart object using FusionCharts PHP Class
$FC = new FusionCharts("Pie3D", "650", "450");
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
//Store chart attributes in a variable for ease of use
$strParam = "caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30; showBorder=1;showNames=1;formatNumberScale=0;numberSuffix= Units;decimalPrecision=0";
#  Set chart attributes
$FC->setChartParams($strParam);
// Fetch all factory records usins SQL Query
//Store chart data values in 'total' column/field and category names in 'FactoryName'
$strQuery = "select a.FactoryID, b.FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.FactoryName";
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database
if ($result) {
    $FC->addDataFromDatabase($result, "total", "FactoryName");
<?php 
//This page builds XML from database. The database contains UTF-8 encoded multilingual text.
//We have pre encoded this file as UTF-8 encoded with BOM
//Hence, we would just retrieve the text and relay it to the chart
//We've included  ../../Includes/DBConn.php, which contains functions
//to help us easily connect to a database.
include "../../Includes/DBConn.php";
//We've included ../Includes/FusionCharts_Gen.php, which FusionCharts PHP Class
//to help us easily embed the charts.
include "../../Includes/FusionCharts_Gen.php";
//For the sake of ease, we've used an MySQL databases - sales and all data in a table - 'monthly_utf8'
//Connect to the Database
$link = connectToDB('sales');
# Create column 2d chart object
$FC = new FusionCharts("Column2D", "500", "400");
# Set Chart attributes
$FC->setChartParams("caption=Monthly Sales Summary;subcaption=For the year 2008;");
$FC->setChartParams("xAxisName=Month;yAxisName=Sales;numberPrefix=\$;showNames=1;");
$FC->setChartParams("showValues=0;showColumnShadow=1;animation=1;");
$FC->setChartParams("baseFontColor=666666;lineColor=FF5904;lineAlpha=85;");
$FC->setChartParams("valuePadding=10;labelDisplay=rotate;useRoundEdges=1");
//Connect to the DB
$link = connectToDB('sales');
// Fetch all factory records
$strQuery = "select * from monthly_utf8";
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database
if ($result) {
    $FC->addDataFromDatabase($result, "amount", "month_name");
Example #11
0
</HEAD>


<BODY>

<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> Examples</h2>
<h4>Simple Column 3D Chart</h4>
<p>&nbsp;</p>
<?php 
//This page demonstrates the ease of generating charts using FusionCharts PHPClass.
//For this chart, we've cread a chart  object used FusionCharts PHP Class
//supply chart data and configurations to it and render chart using the instance
//Here, we've kept this example very simple.
# Create column 3d chart object
$FC = new FusionCharts("Column3D", "600", "300");
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
# Store Chart attributes in a variable
$strParam = "caption=Monthly Unit Sales;xAxisName=Month;yAxisName=Units;decimalPrecision=0; formatNumberScale=0";
#  Set Chart attributes
$FC->setChartParams($strParam);
#add chart data values and category names
$FC->addChartData("462", "name=Jan");
$FC->addChartData("857", "name=Feb");
$FC->addChartData("671", "name=Mar");
$FC->addChartData("494", "name=Apr");
$FC->addChartData("761", "name=May");
$FC->addChartData("960", "name=Jun");
$FC->addChartData("629", "name=Jul");
$FC->addChartData("622", "name=Aug");
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column 3D + Line Dual Y-Axis Combination Chart
$FC = new FusionCharts("MSColumn3DLineDY", "450", "350");
# Set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Store chart attributes in a variable
$strParam = "caption=Weekly Sales;subcaption=Comparison;xAxisName=Week;pYAxisName=Revenue;sYAxisName=Total Quantity;numberPrefix=\$;sNumberSuffix= U";
# Set chart attributes
$FC->setChartParams($strParam);
# Add category names
$FC->addCategory("Week 1");
$FC->addCategory("Week 2");
$FC->addCategory("Week 3");
$FC->addCategory("Week 4");
# Add a new dataset with dataset parameters
$FC->addDataset("This Month", "showValues=0");
# Add chart data for the above dataset
$FC->addChartData("40800");
$FC->addChartData("31400");
$FC->addChartData("26700");
$FC->addChartData("54400");
# Add aother dataset with dataset parameters
$FC->addDataset("Previous Month", "showValues=0");
# Add chart data for the second dataset
$FC->addChartData("38300");
$FC->addChartData("28400");
$FC->addChartData("15700");
$FC->addChartData("48100");
Example #13
0
<?php

# Include FusionCharts PHP Class
include '../Class/FusionCharts_Gen.php';
# Create SSGrid chart Object
$FC = new FusionCharts("grid", "300", "200");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Set grid value Percent on
$FC->setGridParams("showPercentValues=1");
# Set alternet row back ground color
$FC->setGridParams("alternateRowBgColor=EAECEF");
# number item per page
$FC->setGridParams("numberItemsPerPage=4");
# set grid font and font size
$FC->setGridParams("baseFont=vardana");
$FC->setGridParams("baseFontSize=12");
# Add grid values and category names
$FC->addChartData("40800", "label=Week 1");
$FC->addChartData("31400", "label=Week 2");
$FC->addChartData("26700", "label=Week 3");
$FC->addChartData("54400", "label=Week 4");
$FC->addChartData("88544", "label=Week 5");
$FC->addChartData("22544", "label=Week 6");
$FC->addChartData("65548", "label=Week 7");
?>
<html>
  <head>
    <title>SSGrid with PHP Class</title>
    <script language='javascript' src='../FusionCharts/FusionCharts.js'></script>
  </head>
</style>
</head>
<body>	
	<?php 
if (isset($_REQUEST["area_rep"])) {
    ?>
		<script type="text/javascript">
			$(document).ready(function(){
			top = distancia_sup(document.getElementById("grafica"));
			$("#ayuda").css("top",top)
		});
		</script>
	<?php 
    $areas = $reporte->obtener_area($_REQUEST["area_rep"]);
    $area = $areas[0];
    $FC = new FusionCharts("Column3D", "720", "350");
    $FC->setSWFPath("../../FusionCharts/");
    $strParam = "caption=Productividad de Usuarios de " . $area["abreviatura"] . ";xAxisName=Usuario;yAxisName = Productividad (%)";
    $FC->setChartParams($strParam);
    ?>
	<form name="form_reporte" action="">	
	<table width="92%" border="0" align="center">
	<?php 
    if ($_REQUEST["tipo"] != 1 && $_REQUEST["tipo"] != 2) {
        ?>
	  <tr id = "barra_botones">
	    <td>&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td colspan="5">&nbsp;</td>
        <td colspan="2">&nbsp;</td>
        <td>&nbsp;</td>
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column3D chart Object
$FC = new FusionCharts("Column3D", "300", "250");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Weekly Sales;xAxisName=Week;yAxisName=Revenue;numberPrefix=\$;decimals=0;formatNumberScale=0";
# Set chart attributes
$FC->setChartParams($strParam);
# Add chart values and category names
$FC->addChartData("40800", "label=Week 1;alpha=40;showLabel=0;showValue=0");
$FC->addChartData("31400", "label=Week 2;alpha=40;showLabel=0;showValue=0");
$FC->addChartData("26700", "label=Week 3;hoverText=Lowest;link=tooLow.php");
$FC->addChartData("54400", "label=Week 4;showLabel=0;showValue=0; alpha=40; toolText=Highest");
?>
<html>
  <head>
    <title>First Chart - Advanded - Set Other Elements : Using FusionCharts PHP Class</title>
    <script language='javascript' src='../FusionCharts/FusionCharts.js'></script>
  </head>
  <body>

  <?php 
# Render Chart
$FC->renderChart();
?>

  </body>
Example #16
0
 function getFusionchart()
 {
     $document =& JFactory::getDocument();
     $params =& $this->getParams();
     $worker = new FabrikWorker();
     $fc_version = $params->get('fusionchart_version', 'free_old');
     if ($fc_version == 'free_22') {
         require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionChartsFree' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
         $document->addScript($this->srcBase . "fusionchart/lib/FusionChartsFree/JSClass/FusionCharts.js");
         $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionChartsFree/Charts/";
     } else {
         if ($fc_version == 'pro_30') {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FusionCharts' . DS . 'Code' . DS . 'PHPClass' . DS . 'Includes' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FusionCharts/Charts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FusionCharts/Charts/";
         } else {
             require_once $this->pathBase . 'fusionchart' . DS . 'lib' . DS . 'FCclass' . DS . 'FusionCharts_Gen.php';
             $document->addScript($this->srcBase . "fusionchart/lib/FCcharts/FusionCharts.js");
             $fc_swf_path = COM_FABRIK_LIVESITE . $this->srcBase . "fusionchart/lib/FCcharts/";
         }
     }
     $calc_prefixes = array('sum___', 'avg___', 'med___', 'cnt___');
     $calc_prefixmap = array('sum___' => 'sums', 'avg___' => 'avgs', 'med___' => 'medians', 'cnt___' => 'count');
     $w = $params->get('fusionchart_width');
     $h = $params->get('fusionchart_height');
     $chartType = $params->get('fusionchart_type');
     // Create new chart
     $FC = new FusionCharts("{$chartType}", "{$w}", "{$h}");
     //$FC->JSC["debugmode"]=true;
     // Define path to FC's SWF
     $FC->setSWFPath($fc_swf_path);
     $this->setChartMessages($FC);
     // Setting Param string
     $strParam = $this->getChartParams();
     $label_step_ratios = (array) $params->get('fusion_label_step_ratio');
     $x_axis_label = (array) $params->get('fusion_x_axis_label');
     $chartElements = (array) $params->get('fusionchart_elementList');
     $chartColours = (array) $params->get('fusionchart_colours');
     $listid = (array) $params->get('fusionchart_table');
     $axisLabels = (array) $params->get('fusionchart_axis_labels');
     foreach ($axisLabels as $axis_key => $axis_val) {
         //$worker->replaceRequest($axis_val);
         $axisLabels[$axis_key] = $worker->parseMessageForPlaceholder($axis_val, null, false);
     }
     $dual_y_parents = $params->get('fusionchart_dual_y_parent');
     $measurement_units = (array) $params->get('fusion_x_axis_measurement_unit');
     $legends = $params->get('fusiongraph_show_legend', '');
     $chartWheres = (array) $params->get('fusionchart_where');
     $c = 0;
     $gdata = array();
     $glabels = array();
     $gcolours = array();
     $gfills = array();
     $max = array();
     $min = array();
     $calculationLabels = array();
     $calculationData = array();
     $calcfound = false;
     $tmodels = array();
     $labelStep = 0;
     foreach ($listid as $tid) {
         $min[$c] = 0;
         $max[$c] = 0;
         if (!array_key_exists($tid, $tmodels)) {
             $listModel = null;
             $listModel = JModel::getInstance('list', 'FabrikFEModel');
             $listModel->setId($tid);
             $tmodels[$tid] = $listModel;
         } else {
             $listModel = $tmodels[$tid];
         }
         $table = $listModel->getTable();
         $form = $listModel->getForm();
         // $$$ hugh - adding plugin query, 2012-02-08
         if (array_key_exists($c, $chartWheres) && !empty($chartWheres[$c])) {
             $chartWhere = $this->_replaceRequest($chartWheres[$c]);
             $listModel->setPluginQueryWhere('fusionchart', $chartWhere);
         } else {
             // if no where clause, explicitly clear any previously set clause
             $listModel->unsetPluginQueryWhere('fusionchart');
         }
         // $$$ hugh - remove pagination BEFORE calling render().  Otherwise render() applies
         // session state/defaults when it calls getPagination, which is then returned as a cached
         // object if we call getPagination after render().  So call it first, then render() will
         // get our cached pagination, rather than vice versa.
         $nav = $listModel->getPagination(0, 0, 0);
         $listModel->render();
         //$listModel->doCalculations();
         $alldata = $listModel->getData();
         $cals = $listModel->getCalculations();
         $column = $chartElements[$c];
         //$measurement_unit = $measurement_units[$c];
         $measurement_unit = JArrayHelper::getValue($measurement_units, $c, '');
         $pref = substr($column, 0, 6);
         $label = JArrayHelper::getValue($x_axis_label, $c, '');
         $tmpgdata = array();
         $tmpglabels = array();
         $colour = array_key_exists($c, $chartColours) ? str_replace("#", '', $chartColours[$c]) : '';
         $gcolours[] = $colour;
         if (in_array($pref, $calc_prefixes)) {
             // you shouldnt mix calculation elements with normal elements when creating the chart
             // so if ONE calculation element is found we use the calculation data rather than normal element data
             // this is because a calculation element only generates one value, if want to compare two averages then
             //they get rendered as tow groups of data and on bar charts this overlays one average over the other, rather than next to it
             $calcfound = true;
             $column = substr($column, 6);
             $calckey = $calc_prefixmap[$pref];
             $caldata = JArrayHelper::getValue($cals[$calckey], $column . '_obj');
             if (is_array($caldata)) {
                 foreach ($caldata as $k => $o) {
                     $calculationData[] = (double) $o->value;
                     $calculationLabels[] = trim(strip_tags($o->label));
                 }
             }
             if (!empty($calculationData)) {
                 $max[$c] = max($calculationData);
                 $min[$c] = min($calculationData);
             }
             $gdata[$c] = implode(',', $tmpgdata);
             $glabels[$c] = implode('|', $tmpglabels);
             // $$$ hugh - playing around with pie charts
             //$gsums[$c] = array_sum($tmpgdata);
             $gsums[$c] = array_sum($calculationData);
         } else {
             $origColumn = $column;
             $column = $column . "_raw";
             //_raw fields are most likely to contain the value
             foreach ($alldata as $group) {
                 foreach ($group as $row) {
                     if (!array_key_exists($column, $row)) {
                         //didnt find a _raw column - revent to orig
                         $column = $origColumn;
                         if (!array_key_exists($column, $row)) {
                             JError::raiseWarning(E_NOTICE, $column . ': NOT FOUND - PLEASE CHECK IT IS PUBLISHED');
                             continue;
                         }
                     }
                     if (trim($row->{$column}) == '') {
                         $tmpgdata[] = -1;
                     } else {
                         $tmpgdata[] = (double) $row->{$column};
                     }
                     $tmpglabels[] = !empty($label) ? strip_tags($row->{$label}) : '';
                 }
                 if (!empty($tmpgdata)) {
                     $max[$c] = max($tmpgdata);
                     $min[$c] = min($tmpgdata);
                 }
                 $gdata[$c] = implode(',', $tmpgdata);
                 $glabels[$c] = implode('|', $tmpglabels);
                 // $$$ hugh - playing around with pie charts
                 $gsums[$c] = array_sum($tmpgdata);
             }
         }
         $c++;
     }
     if ($calcfound) {
         $calculationLabels = array_reverse($calculationLabels);
         // $$$ rob implode with | and not ',' as :
         //$labels = explode('|',$glabels[0]); is used below
         //$glabels = array(implode(',', array_reverse($calculationLabels)));
         $glabels = array(implode('|', array_reverse($calculationLabels)));
         // $$$ rob end
         $gdata = array(implode(',', $calculationData));
     }
     // $$$ hugh - pie chart data has to be summed - the API only takes a
     // single dataset for pie charts.  And it doesn't make sense trying to
     // chart individual row data for multiple elements in a pie chart.
     // Also, labels need to be axisLabels, not $glabels
     switch ($chartType) {
         // Single Series Charts
         case 'AREA2D':
         case 'BAR2D':
         case 'COLUMN2D':
         case 'COLUMN3D':
         case 'DOUGHNUT2D':
         case 'DOUGHNUT3D':
         case 'LINE':
             // $$$ tom - for now I'm enabling Pie charts here so that it displays
             // something until we do it properly as you said hugh
             // Well maybe there's something I don't get but in fact FC already draw
             // the pies by "percenting" the values of each data... if you know what I mean Hugh;)
         // $$$ tom - for now I'm enabling Pie charts here so that it displays
         // something until we do it properly as you said hugh
         // Well maybe there's something I don't get but in fact FC already draw
         // the pies by "percenting" the values of each data... if you know what I mean Hugh;)
         case 'PIE2D':
         case 'PIE3D':
         case 'SCATTER':
             // Adding specific params for Pie charts
             if ($chartType == 'PIE2D' || $chartType == 'PIE3D') {
                 $strParam .= ';pieBorderThickness=' . $params->get('fusionchart_borderthick', '');
                 $strParam .= ';pieBorderAlpha=' . $params->get('fusionchart_cnvalpha', '');
                 $strParam .= ';pieFillAlpha=' . $params->get('fusionchart_elalpha', '');
             }
             if ($c > 1) {
                 $arrCatNames = array();
                 foreach ($axisLabels as $alkey => $al) {
                     $arrCatNames[] = $al;
                 }
                 $arrData = array();
                 $i = 0;
                 foreach ($gsums as $gd) {
                     $arrData[$i][0] = $axisLabels[$i];
                     $arrData[$i][1] = $gd;
                     $i++;
                 }
                 $FC->addChartDataFromArray($arrData, $arrCatNames);
             } else {
                 // single table/elements, so use the row data
                 $labels = explode('|', $glabels[0]);
                 $gsums = explode(',', $gdata[0]);
                 // scale to percentages
                 $tot_sum = array_sum($gsums);
                 $arrData = array();
                 $labelStep = 0;
                 $label_step_ratio = (int) JArrayHelper::getValue($label_step_ratios, 0, 1);
                 if ($label_step_ratio > 1) {
                     $labelStep = (int) (count($gsums) / $label_step_ratio);
                     $strParam .= ";labelStep={$labelStep}";
                 }
                 //$$$tom: inversing array_combine as identical values in gsums will be
                 // dropped otherwise. Should I do that differently?
                 // $$$ hugh - can't use array_combine, as empty labels end up dropping values
                 //$arrComb = array_combine($labels, $gsums);
                 //foreach ($arrComb as $key => $value) {
                 $data_count = 0;
                 foreach ($gsums as $key => $value) {
                     $data_count++;
                     if ($value == '-1') {
                         $value = null;
                     }
                     $label = $labels[$key];
                     $str_params = "name={$label}";
                     if ($labelStep) {
                         if ($data_count != 1 && $data_count % $labelStep != 0) {
                             $str_params .= ";showName=0";
                         }
                     }
                     $FC->addChartData("{$value}", $str_params);
                 }
             }
             break;
         case 'MSBAR2D':
         case 'MSBAR3D':
         case 'MSCOLUMN2D':
         case 'MSCOLUMN3D':
         case 'MSLINE':
         case 'MSAREA2D':
         case 'MSCOMBIDY2D':
         case 'MULTIAXISLINE':
             //case 'PIE2D':
             //case 'PIE3D':
         //case 'PIE2D':
         //case 'PIE3D':
         case 'STACKEDAREA2D':
         case 'STACKEDBAR2D':
         case 'STACKEDCOLUMN2D':
         case 'STACKEDCOLUMN3D':
         case 'SCROLLAREA2D':
         case 'SCROLLCOLUMN2D':
         case 'SCROLLLINE2D':
         case 'SCROLLSTACKEDCOLUMN2D':
             /*$chd = implode('|', $gdata);
             		if (!empty($chds_override)) {
             			$chds = $chds_override;
             		}
             		else if ($c > 1 && !$calcfound) {
             			$minmax = $this->_getMinMax($gsums);
             			$chds = $minmax['min'] . ',' . $minmax['max'];
             		}
             		else {
             			$chds = $min.','.$max;
             		}
             		if ($calcfound) {
             			$glabels = array(implode('|', $calculationLabels));
             		}
             		// $$$ hugh - we have to reverse the labels for horizontal bar charts
             		$glabels[0] = implode('|',array_reverse(explode('|',$glabels[0])));
             		if (empty($chxl_override)) {
             			$chxl = '0:|'.$min.'|'.$max.$measurement_unit.'|'.'1:|'.$glabels[0];
             		}
             		else {
             			$chxl = '0:|'.$chxl_override.'|'.'1:|'.$glabels[0];
             		}
             		break;
             		*/
             if ($c > 1) {
                 if ($chartType == 'SCROLLAREA2D' || $chartType == 'SCROLLCOLUMN2D' || $chartType == 'SCROLLLINE2D') {
                     $strParam .= ';numVisiblePlot=' . $params->get('fusionchart_scroll_numvisible', 0);
                 }
                 // $$$ hugh - Dual-Y types
                 if ($chartType == 'MSCOMBIDY2D' || $chartType == 'MULTIAXISLINE') {
                     //var_dump($axisLabels);
                     /*
                     					    $strParam .= ';PYAxisName='.$axisLabels[0];
                     					    $strParam .= ';SYAxisName='.$axisLabels[1];
                     */
                     $p_parents = array();
                     $s_parents = array();
                     foreach ($dual_y_parents as $dual_y_key => $dual_y_parent) {
                         if ($dual_y_parent == "P") {
                             $p_parents[] = $axisLabels[$dual_y_key];
                         } else {
                             $s_parents[] = $axisLabels[$dual_y_key];
                         }
                     }
                     $strParam .= ';PYAxisName=' . implode(' ', $p_parents);
                     $strParam .= ';SYaxisName=' . implode(' ', $s_parents);
                 }
                 //$$$tom: This is a first attempt at integrating Trendlines but it's not actually working... :s
                 $eltype = $params->get('fusionchart_element_type', 'dataset');
                 for ($nbe = 0; $nbe < $c; $nbe++) {
                     if ($eltype[$nbe] != 'dataset') {
                         // Trendline Start & End values
                         $trendstart = $params->get('fusionchart_trendstartvalue', '');
                         $trendend = $params->get('fusionchart_trendendvalue', '');
                         if ($trendstart) {
                             $startval = $trendstart;
                             $endval = $trendend;
                         } else {
                             if ($eltype[$nbe] == 'trendline') {
                                 // If Start & End values are not specifically defined, use the element's min & max values
                                 $startval = $min[$nbe];
                                 $endval = $max[$nbe];
                             }
                         }
                         $strAddTrend = "startValue={$startval};endValue={$endval}";
                         // Label
                         $displayval = $params->get('fusionchart_trendlabel', '');
                         $showontop = $params->get('fusionchart_trendshowontop', '1');
                         $iszone = $params->get('fusionchart_trendiszone', '0');
                         $elcolour = $params->get('fusionchart_elcolour', '');
                         $elalpha = $params->get('fusionchart_elalpha', '');
                         //$strAddTrend .= ";displayvalue=".$displayval;
                         $strAddTrend .= ";displayvalue=" . $axisLabels[$nbe];
                         $strAddTrend .= ";showOnTop=" . $showontop;
                         if ($startval < $endval) {
                             $strAddTrend .= ";isTrendZone=" . $iszone;
                         }
                         $strAddTrend .= ";color=" . $elcolour[$nbe];
                         $strAddTrend .= ";alpha=" . $elalpha[$nbe];
                         $strAddTrend .= ";thickness=3";
                         //var_dump($strAddTrend);
                         $FC->addTrendLine("{$strAddTrend}");
                         unset($axisLabels[$nbe]);
                         unset($gdata[$nbe]);
                     }
                 }
                 // end for loop
                 /*------------------------------------------
                 * $$$tom: I'm trying something else, as per http://www.fusioncharts.com/free/docs/Contents/PHPClassAPI/MultiSeriesChart.html
                 * A MS Chart should use for example 2 elements from the same table and have Categories
                 * (the colored legend below the chart, e.g. "This month", "Previous month").
                 * Then different Datasets must be defined (e.g. one by row in the table: "Week 1", "Week 2", ...)
                 * And finally some Data for each Dataset (e.g. Sales: "40200", "38350", ...)
                 * Of course I kept what you made Hugh, I commented out between this comment and what I've added.
                 ------------------------------------------*/
                 /*if ($calcfound) {
                 							$glabels = array(implode('|', $calculationLabels));
                 						}
                 						$arrCatNames = array();
                 						foreach ($axisLabels as $alkey => $al) {
                 							$arrCatNames[] = $al;
                 						}
                 
                 						$arrData = array();
                 						$i = 0;
                 						foreach ($gdata as $gdkey => $gd) {
                 							$arrData[$i][0] = $glabels[$i];
                 							$arrData[$i][1] = '';
                 							$arrData[$i] = array_merge($arrData[$i], explode(',', $gd));
                 							$i++;
                 						}
                 
                 						$FC->addChartDataFromArray($arrData, $arrCatNames);*/
                 $label_step_ratio = (int) JArrayHelper::getValue($label_step_ratios, 0, 1);
                 if ($label_step_ratio > 1) {
                     $labelStep = (int) (count(explode(',', $gdata[0])) / $label_step_ratio);
                     $strParam .= ";labelStep={$labelStep}";
                 }
                 // Start tom's changes
                 $labels = explode('|', $glabels[0]);
                 $data_count = 0;
                 foreach ($labels as $catLabel) {
                     $data_count++;
                     $catParams = '';
                     if ($labelStep) {
                         if ($data_count == 1 || $data_count % $labelStep == 0) {
                             $catParams = "ShowLabel=1";
                         } else {
                             $catParams = "ShowLabel=0";
                             $catLabel = '';
                         }
                     }
                     $FC->addCategory($catLabel, $catParams);
                 }
                 foreach ($gdata as $key => $chartdata) {
                     $cdata = explode(',', $chartdata);
                     $dataset = $axisLabels[$key];
                     $extras = "parentYAxis=" . $dual_y_parents[$key];
                     //var_dump($dual_y_parents, $dataset, $extras);
                     $FC->addDataset("{$dataset}", $extras);
                     $data_count = 0;
                     foreach ($cdata as $key => $value) {
                         $data_count++;
                         if ($value == '-1') {
                             $value = null;
                         }
                         $FC->addChartData("{$value}");
                     }
                 }
                 // End tom's changes
             } else {
                 //$foo = $foo;
             }
             /*
             	default:
             		$chd = implode('|', $gdata);
             		$chxl = '0:|'.$glabels[0].'|'.'1:|'.$min.'|'.$max;
             		if ($c > 1 && !$calcfound) {
             			$minmax = $this->_getMinMax($gsums);
             			$chds = $minmax['min'] . ',' . $minmax['max'];
             		}
             		else {
             			$chds = $min.','.$max;
             		}
             		break;
             */
     }
     $colours = implode($calcfound ? '|' : ',', $gcolours);
     /*$return = '<img src="' . $this->_url . '?';
     		$qs =  'chs='.$w.'x'.$h;
     		$qs .= '&amp;chd=t:'.$chd;
     		$qs .= '&amp;cht='.$graph;
     		$qs .= '&amp;chco='.$colours;
     		$qs .= '&amp;chxt=x,y';
     		$qs .= '&amp;chxl='.$chxl;
     		$qs .= '&amp;chds='.$chds;
     		if ($fillGraphs) {
     			$qs .=  '&amp;chm=' . implode('|', $gfills);
     		}
     		if ($legends) {
     			$qs .= '&amp;chdl=' . implode('|', $axisLabels);
     		}
     		if (!empty($chg_override)) {
     			$qs .= '&amp;chg=' . $chg_override;
     		}
     		if (!empty($chm_override)) {
     			$qs .= '&amp;chm=' . $chm_override;
     		}
     		else if ($fillGraphs) {
     			$qs .=  '&amp;chm=' . implode('|', $gfills);
     		}
     		$return .= $qs . '" alt="'.$this->_row->label.'" />';
     		$this->image =  $return;*/
     # Set chart attributes
     if ($params->get('fusionchart_custom_attributes', '')) {
         $strParam .= ';' . trim($params->get('fusionchart_custom_attributes'));
     }
     $strParam = "{$strParam}";
     $FC->setChartParams($strParam);
     # Render Chart
     if ($chartType == 'MULTIAXISLINE') {
         // Nasty, nasty hack for MULTIAXIS, as the FC class doesn't support it.  So need to get the chart XML,
         // split out the <dataset>...</dataset> and wrap them in <axis>...</axis>
         $axis_attrs = (array) $params->get('fusionchart_mx_attributes');
         $dataXML = $FC->getXML();
         $matches = array();
         if (preg_match_all('#(<\\s*dataset[^>]*>.*?<\\s*/dataset\\s*>)#', $dataXML, $matches)) {
             $index = 0;
             foreach ($gdata as $key => $chartdata) {
                 $axis = "<axis " . $axis_attrs[$index] . ">" . $matches[0][$index] . "</axis>";
                 $dataXML = str_replace($matches[0][$index], $axis, $dataXML);
                 $index++;
             }
         }
         return $FC->renderChartFromExtXML($dataXML);
     } else {
         return $FC->renderChart(false, false);
     }
 }
//Store Name of Products
$arrData[0][0] = "Product A";
$arrData[1][0] = "Product B";
$arrData[2][0] = "Product C";
$arrData[3][0] = "Product D";
$arrData[4][0] = "Product E";
$arrData[5][0] = "Product F";
//Store sales data
$arrData[0][1] = 567500;
$arrData[1][1] = 815300;
$arrData[2][1] = 556800;
$arrData[3][1] = 734500;
$arrData[4][1] = 676800;
$arrData[5][1] = 648500;
# Create FusionCharts PHP Class object for single series column3d chart
$FC = new FusionCharts("Column3D", "600", "300");
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
# store chart attributes in a variable
$strParam = "caption=Sales by Product;numberPrefix=\$;formatNumberScale=0;decimalPrecision=0";
#  Set chart attributes
$FC->setChartParams($strParam);
## call FusionCharts PHP Class Function to add data from the array
$FC->addChartDataFromArray($arrData);
# Render the chart
$FC->renderChart();
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>&laquo; Back to list of examples</a></h5>
Example #18
0
      <!-- FusionCharts core package JS files -->
      <script src="http://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
      <script src="http://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
      <script src="http://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
   </head>
   <body>

<?php 
pg_query($dbconn, "SELECT DISTINCT browser, shareval FROM browsershare; ");
$result = pg_query($dbconn, "SELECT DISTINCT browser, shareval FROM browsershare; ") or exit("Error with quering database");
if ($result) {
    // creating an associative array to store the chart attributes
    $arrData = array("chart" => array("theme" => "fint", "caption" => "Browser Market Share", "subcaption" => "February 2016", "captionFontSize" => "24", "paletteColors" => "#A2A5FC, #41CBE3, #EEDA54, #BB423F #,F35685", "baseFont" => "Quicksand, sans-serif", "baseFontColor" => "#FFFFFF", "baseFontSize" => "14", "numberSuffix" => "%", "showBorder" => "0", "startingAngle" => "0", "showPercentValues" => "0", "showPercentInTooltip" => "0", "decimals" => "1", "labelFontColor" => "#FFFFFF", "labelFontSize" => "14", "bgColor" => "#50585F", "bgAlpha" => "100", "doughnutRadius" => "50", "enableSmartLabels" => "1", "smartLineColor" => "#FCFDFD", "smartLineThickness" => "1", "showLegend" => "1", "legendBorderAlpha" => '0', "legendShadow" => '0', "legendItemFontSize" => '10', "legendItemFontColor" => "#FFFFFF", "toolTipBgColor" => "#000000", "toolTipBgAlpha" => "70", "toolTipPadding" => "10", "toolTipBorderColor" => "#FFFFFF", "toolTipBorderThickness" => "1", "toolTipBorderRadius" => "2"));
    $arrData["data"] = array();
    // iterating over each data and pushing it into $arrData array
    while ($row = pg_fetch_array($result)) {
        array_push($arrData["data"], array("label" => $row["browser"], "value" => $row["shareval"]));
    }
    $jsonEncodedData = json_encode($arrData);
    // creating FusionCharts instance
    $doughnutChart = new FusionCharts("doughnut2d", "browserShareChart", '100%', 450, "doughnut-chart", "json", $jsonEncodedData);
    // FusionCharts render method
    $doughnutChart->render();
    // closing database connection
    pg_close($dbconn);
}
?>
 	<!-- creating chart container --> 	
 	<div id="doughnut-chart">A beautiful donut chart is on its way!</div>
   </body>
</html>
//forms or databases etc.Such examples are also present.
//Here, we've kept this example very simple.
//Create an XML data document in a string variable
$strXML = "<Chart caption='Monthly Unit Sales' xAxisName='Month' yAxisName='Units' >";
$strXML .= "<set Label='Jan' value='462' />";
$strXML .= "<set Label='Feb' value='857' />";
$strXML .= "<set Label='Mar' value='671' />";
$strXML .= "<set Label='Apr' value='494' />";
$strXML .= "<set Label='May' value='761' />";
$strXML .= "<set Label='Jun' value='960' />";
$strXML .= "<set Label='Jul' value='629' />";
$strXML .= "<set Label='Aug' value='622' />";
$strXML .= "<set Label='Sep' value='376' />";
$strXML .= "<set Label='Oct' value='494' />";
$strXML .= "<set Label='Nov' value='761' />";
$strXML .= "<set Label='Dec' value='960' />";
$strXML .= "</Chart>";
# Create object of FusionCharts class of single series
$FC = new FusionCharts("Column3D", "600", "300");
# Set Relative Path of swf file. default path is “charts/”
$FC->setSWFPath("../../FusionCharts/");
//Create the chart - Column 3D Chart with data from strXML
# Create the Chart
$FC->renderChartFromExtXML($strXML);
?>
<BR><BR>
<a href='../NoChart.html' target="_blank">Unable to see the chart above?</a>
<H5 ><a href='../default.htm'>&laquo; Back to list of examples</a></h5>
</CENTER>
</BODY>
</HTML>
Example #20
0
$result->bindParam('tahun', $tahun, PDO::PARAM_INT);
$result->execute();
// If the query returns a valid response, prepare the JSON string
if ($result) {
    // The `$arrData` array holds the chart attributes and data
    $arrData = array("chart" => array("caption" => "Jumlah Gangguan Penyulang > 5 menit Per Area Unit", "bgColor" => "#ffffff", "borderAlpha" => "20", "canvasBorderAlpha" => "0", "usePlotGradientColor" => "0", "plotBorderAlpha" => "10", "showXAxisLine" => "1", "xAxisLineColor" => "#999999", "showValues" => "0", "divlineColor" => "#999999", "divLineIsDashed" => "1", "showAlternateHGridColor" => "0"));
    $arrData["data"] = array();
    // Push the data into the array
    while ($row = $result->fetch()) {
        $GANGGUANTOTAL = @($row["BESAR5"] + $row["KECIL5"]) / $row["PANJANG"];
        array_push($arrData["data"], array("label" => $row["AREA"], "value" => $GANGGUANTOTAL));
    }
    /*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */
    $jsonEncodedData = json_encode($arrData);
    /*Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor.*/
    $columnChart = new FusionCharts("column2D", "myFirstChart", 700, 350, "chartContainer", "json", $jsonEncodedData);
    // Render the chart
    $columnChart->render();
    // Close the database connection
    $conn = null;
}
?>


<title> Rekapitulasi Laporan Gangguan Penyulang</title>
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
        <h1>
            Rekapitulasi Laporan
            <small>Gangguan Penyulang</small>
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column 2D chart Object
$FC = new FusionCharts("Column2D", "450", "350");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Set colon (:) as delimiter
$FC->setParamDelimiter(":");
# Define chart attributes
$strParam = "caption=Weekly Sales:xAxisName=Week:yAxisName=Revenue:numberPrefix=\$";
# Set chart attributes
$FC->setChartParams($strParam);
# add chart values and category names
$FC->addChartData("40800", "label=Week 1:alpha=80");
$FC->addChartData("31400", "label=Week 2:alpha=60");
$FC->addChartData("26700", "label=Week 3");
$FC->addChartData("54400", "label=Week 4");
# Set hash (#) as delimiter
$FC->setParamDelimiter("#");
# Add TrendLine
$FC->addTrendLine("startValue=42000#color=ff0000#displayvalue=Target#showOnTop=1");
# Set semicolon (;) as delimiter
$FC->setParamDelimiter(";");
# Add TrendLine
$FC->addTrendLine("startValue=30000;color=008800;displayvalue=Average;showOnTop=1");
?>
<html>
  <head>
    <title>First Chart - Set Delimiter : Using FusionCharts PHP Class</title>
Example #22
0
# Create FusionCharts PHP object
$FC = new FusionCharts("Column3D", "300", "250");
# set the relative path of the swf file
$FC->setSWFPath("../../FusionCharts/");
#  Set chart attributes
$strParam = "caption=Weekly Sales;subcaption=Revenue;xAxisName=Week;yAxisName=Revenue;numberPrefix=\$;decimalPrecision=0";
$FC->setChartParams($strParam);
# add chart values and category names for the First Chart
$FC->addChartData("40800", "name=Week 1");
$FC->addChartData("31400", "name=Week 2");
$FC->addChartData("26700", "name=Week 3");
$FC->addChartData("54400", "name=Week 4");
//-------------------------------------------------------------------
//----- Creating Second Chart ---------------------------------------
# Create FusionCharts PHP object
$FC2 = new FusionCharts("Column3D", "300", "250");
# set the relative path of the swf file
$FC2->setSWFPath("../../FusionCharts/");
#  Setting chart attributes
$strParam = "caption=Weekly Sales;subcaption=Quantity;xAxisName=Week;yAxisName=Quantity;decimalPrecision=0";
$FC2->setChartParams($strParam);
# add chart values and  category names for the second chart
$FC2->addChartData("32", "name=Week 1");
$FC2->addChartData("35", "name=Week 2");
$FC2->addChartData("26", "name=Week 3");
$FC2->addChartData("44", "name=Week 4");
//-------------------------------------------------------------------------
# Render First Chart
$FC->renderChart();
# Render Second Chart
$FC2->renderChart();
Example #23
0
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Bubble chart Object
$FC = new FusionCharts("bubble", "450", "350");
# set the relative path of the swf file
$FC->setSwfPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Monthly Sales;xAxisName=Number of Products;yAxisName=Revenue;numberPrefix=\$";
# Set chart attributes
$FC->setChartParams($strParam);
# Add Category, 1st parameter take label and 2nd parameter takes x axis value
# as parameter list
$FC->addCategory("0", "x=0;showVerticalLine=1");
$FC->addCategory("20", "x=20;showVerticalLine=1");
$FC->addCategory("40", "x=40;showVerticalLine=1");
$FC->addCategory("60", "x=60;showVerticalLine=1");
$FC->addCategory("80", "x=80;showVerticalLine=1");
$FC->addCategory("100", "x=100;showVerticalLine=1");
# Add a new dataset
$FC->addDataSet("Previous Month");
# Add chart data for the above dataset
# where 1st parameter for X axis value
# 2nd parameter take Y and Z axis as parameter list
# e.g y=12200;z=10
$FC->addChartData("20", "y=72000;z=8");
$FC->addChartData("43", "y=42000;z=5");
$FC->addChartData("70", "y=90000;z=2");
$FC->addChartData("90", "y=75000;z=4");
# Add another dataset
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Scatter chart Object
$FC = new FusionCharts("Scatter", "300", "250");
# set the relative path of the swf file
$FC->setSwfPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Server Performance;yAxisName=Response Time (sec);xAxisName=Server Load (TPS)";
# Set chart attributes
$FC->setChartParams($strParam);
# Add Category, 1st parameter take label and 2nd parameter takes x axis value
# as parameter list
$FC->addCategory("10", "x=10;showVerticalLine=1");
$FC->addCategory("20", "x=20;showVerticalLine=1");
$FC->addCategory("30", "x=30;showVerticalLine=1");
$FC->addCategory("40", "x=40;showVerticalLine=1");
$FC->addCategory("50", "x=50");
# Add a new dataset
$FC->addDataSet("Server 1", "anchorRadius=6");
# Add chart data for the above dataset
# where 1st parameter for X axis value
# 2nd parameter take Y axis as parameter list
# e.g y=27
$FC->addChartData("21", "y=2.4");
$FC->addChartData("32", "y=3.5");
$FC->addChartData("43", "y=2.5");
$FC->addChartData("48", "y=4.1");
# Add another dataset
$FC->addDataSet("Server 2", "anchorRadius=6");
            <div class="content-area">
                <div id="content-area-inner-main">
                    <h2 class="headline"> Simple Column 3D Chart </h2>

                    <div class="gen-chart-render">

                        <CENTER>
                            <p>&nbsp;</p>
                            <?php 
//This page demonstrates the ease of generating charts using FusionCharts PHPClass.
//For this chart, we've cread a chart  object used FusionCharts PHP Class
//supply chart data and configurations to it and render chart using the instance
//Here, we've kept this example very simple.
# Create column 3d chart object
$FC = new FusionCharts("Column3D", "600", "300");
# Enable Print Manager
$FC->enablePrintManager(true);
# Set Relative Path of swf file.
$FC->setSWFPath("../../FusionCharts/");
# Define chart attributes
$strParam = "caption=Monthly Unit Sales;xAxisName=Month;yAxisName=Units";
#  Set Chart attributes
$FC->setChartParams($strParam);
#add chart data values and category names
$FC->addChartData("462", "Label=Jan");
$FC->addChartData("857", "Label=Feb");
$FC->addChartData("671", "Label=Mar");
$FC->addChartData("494", "Label=Apr");
$FC->addChartData("761", "Label=May");
$FC->addChartData("960", "Label=Jun");
Example #26
0
<?php

//We've included ../../Includes/FusionCharts_Gen.php - FusionCharts PHP Class
//to help us easily embed the charts.
include "../../Includes/FusionCharts_Gen.php";
?>

<?php 
//This page demonstrates the ease of generating charts using FusionCharts PHPClass.
//We creata a FusionCharts object instance
//Set chart values and configurations and retunns the XML using getXML() funciton
//and write it to the response stream to build the XML
//Here, we've kept this example very simple.
# Create column 3d chart object
$FC = new FusionCharts("column3D", "600", "300");
# Set Relative Path of swf file.
$FC->setSWFPath("../../FusionCharts/");
# Define chart attributes
$strParam = "caption=Monthly Unit Sales;xAxisName=Month;yAxisName=Units;showLabels=1";
#  Set chart attributes
$FC->setChartParams($strParam);
#add chart data values and category names
$FC->addChartData("462", "Label=Jan");
$FC->addChartData("857", "Label=Feb");
$FC->addChartData("671", "Label=Mar");
$FC->addChartData("494", "Label=Apr");
$FC->addChartData("761", "Label=May");
$FC->addChartData("960", "Label=Jun");
$FC->addChartData("629", "Label=Jul");
$FC->addChartData("622", "Label=Aug");
$FC->addChartData("376", "Label=Sep");
<?php

# Include FusionCharts PHP Class
include "../Class/FusionCharts_Gen.php";
# Create Column2D chart Object
$FC = new FusionCharts("column2D", "300", "250");
# set the relative path of the swf file
$FC->setSWFPath("../FusionCharts/");
# Define chart attributes
$strParam = "caption=Weekly Sales;xAxisName=Week;yAxisName=Revenue;numberPrefix=\$";
# Set chart attributes
$FC->setChartParams($strParam);
# Add chart values and category names
$FC->addChartData("40800", "label=Week 1");
# Add first vline
$FC->addChartData("", "", "color=FF0000");
# Add chart values
$FC->addChartData("31400", "label=Week 2");
$FC->addChartData("26700", "label=Week 3");
# Add Second vline
$FC->addChartData("", "", "color=00FF00");
# Add chart value
$FC->addChartData("54400", "label=Week 4");
?>
<html>
  <head>
    <title>First Chart -Advanded Add Vlines - Single Series : Using FusionCharts PHP Class</title>
    <script language='javascript' src='../FusionCharts/FusionCharts.js'></script>
  </head>
  <body>
Example #28
0
</HEAD>
<BODY>

<CENTER>
<h2><a href="http://www.fusioncharts.com" target="_blank">FusionCharts Free</a> - Database and Drill-Down Example</h2>
<h4>Detailed report for the factory</h4>
<?php 
//This page is invoked from Default.php. When the user clicks on a pie
//slice in Default.php, the factory Id is passed to this page. We need
//to get that factory id, get information from database and then show
//a detailed chart.
//Request the factory Id from Querystring
$FactoryId = $_REQUEST['FactoryId'];
$FactoryName = $_REQUEST['FactoryName'];
# Create a column 3d chart object
$FC = new FusionCharts("Column2D", "600", "300");
# Set Relative Path of swf file.
$FC->setSwfPath("../../FusionCharts/");
// Store Chart attributes in a variable
$strParam = "caption={$FactoryName} Output;subcaption=(In Units);xAxisName=Date; formatNumberScale=0;decimalPrecision=0;rotateNames=1;showValues=0";
#  Set chart attributes
$FC->setChartParams($strParam);
// Connet to the DataBase
$link = connectToDB();
//Now, we get the data for that factory
//storing chart values in 'Quantity' column and category names in 'DDate'
$strQuery = "select Quantity, DATE_FORMAT(DatePro,'%e-%b-%Y') as DDate from Factory_Output where FactoryId=" . $FactoryId;
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL query result to the FusionCharts PHP Class' function
//that will extract data from database and add to the chart.
if ($result) {
Example #29
0
 private function getFusionChartFromDataArr($arr)
 {
     $FC = new FusionCharts("Column2D", "500", "350", null, true);
     $FC->setSWFPath("/fusionCharts_swf/");
     $strParam = "xAxisName=Rating;yAxisName=Number;decimalPrecision=0;formatNumberScale=1";
     $FC->setChartParams($strParam);
     if (isset($arr["NA"])) {
         $FC->addChartData($arr["NA"], "name=N/R");
     }
     $item = $arr["typeObj"];
     if ($item->getId() == EnumItemPeer::RATING_BOOLEAN) {
         for ($i = 0; $i < 2; $i++) {
             $FC->addChartData($arr[$i], "name={$i}");
         }
     } elseif ($item->getParentId() == EnumItemPeer::RATING_SCALE) {
         for ($i = 0; $i < $item->getDescr(); $i++) {
             $FC->addChartData($arr[$i], "name={$i}");
         }
     } else {
         // FIXME type not supported
         throw new Exception("type not supported");
     }
     return $FC;
 }
Example #30
0
<?php

//We've included  ../Includes/DBConn.php, which contains functions
//to help us easily connect to a database.
include "../Includes/DBConn.php";
//We've included ../Includes/FusionCharts_Gen.php, which FusionCharts PHP Class
//to help us easily embed the charts.
include "../Includes/FusionCharts_Gen.php";
//This page generates the XML data for the Pie Chart contained in
//Default.php.
//For the sake of ease, we've used an MySQL databases containing two
//tables..
//Connect to the Database
$link = connectToDB();
# Create a pie 3d chart object
$FC = new FusionCharts("Pie3D", "650", "450");
# Set Relative Path of swf file.
$FC->setSWFPath("../../FusionCharts/");
# Define chart attributes
$strParam = "caption=Factory Output report;subCaption=By Quantity;pieSliceDepth=30;showBorder=1;numberSuffix= Units";
#Set chart attributes
$FC->setChartParams($strParam);
// Fetch all factory records usins SQL Query
//Store chart data values in 'total' column/field and category names in 'FactoryName'
$strQuery = "select a.FactoryID, b.FactoryName, sum(a.Quantity) as total from Factory_output a, Factory_Master b where a.FactoryId=b.FactoryId group by a.FactoryId,b.FactoryName";
$result = mysql_query($strQuery) or die(mysql_error());
//Pass the SQL Query result to the FusionCharts PHP Class function
//along with field/column names that are storing chart values and corresponding category names
//to set chart data from database
if ($result) {
    $FC->addDataFromDatabase($result, "total", "FactoryName");