Esempio n. 1
0
# 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
$FC->addDataSet("Current 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("18", "y=22000;z=3");
$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;color=880000");
# 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;color=000088");
# 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=30
$FC->addChartData("23", "y=1.4");
$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");
# 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=30
$FC->addChartData("23", "y=1.4");
Esempio n. 4
0
function fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl = '', $unit = '')
{
    global $config;
    $graph_type = "MSArea2D";
    //MSLine is possible also
    $chart = new FusionCharts($graph_type, $width, $height);
    $pixels_between_xdata = 25;
    $max_xdata_display = round($width / $pixels_between_xdata);
    $ndata = count($chart_data);
    if ($max_xdata_display > $ndata) {
        $xdata_display = $ndata;
    } else {
        $xdata_display = $max_xdata_display;
    }
    $step = round($ndata / $xdata_display);
    if (is_array(reset($chart_data))) {
        $data2 = array();
        $count = 0;
        foreach ($chart_data as $i => $values) {
            $count++;
            $show_name = '0';
            if ($count % $step == 0) {
                $show_name = '1';
            }
            if (isset($long_index[$i])) {
                $chart->addCategory($i, 'hoverText=' . $long_index[$i] . ';showName=' . $show_name);
            } else {
                $chart->addCategory($i, 'showName=' . $show_name);
            }
            $c = 0;
            foreach ($values as $i2 => $value) {
                $data2[$i2][$i] = $value;
                $c++;
            }
        }
        $data = $data2;
    } else {
        $data = array($chart_data);
    }
    $a = 0;
    $empty = 1;
    foreach ($data as $i => $value) {
        $legend_text = '';
        if (isset($legend[$i])) {
            $legend_text = $legend[$i];
        }
        $alpha = '';
        $areaBorderColor = '';
        $color = '';
        $showAreaBorder = 1;
        //0 old default
        if (isset($colors[$i])) {
            if (!isset($colors[$i]['border'])) {
                $showAreaBorder = 1;
            }
            if (isset($colors[$i]['alpha'])) {
                $alpha = 'alpha=' . $colors[$i]['alpha'] . ';';
            }
            if (isset($colors[$i]['border'])) {
                $areaBorderColor = 'areaBorderColor=' . $colors[$i]['border'] . ';';
            }
            if (isset($colors[$i]['color'])) {
                $color = 'color=#' . $colors[$i]['color'];
            }
        }
        $chart->addDataSet($legend_text, $alpha . 'showAreaBorder=' . $showAreaBorder . ';' . $areaBorderColor . $color);
        $count = 0;
        $step = 10;
        $num_vlines = 0;
        foreach ($value as $i2 => $v) {
            if ($count++ % $step == 0) {
                $show_name = '1';
                $num_vlines++;
            } else {
                $show_name = '0';
            }
            $empty = 0;
            if ($a < 3) {
                $a++;
                //			$chart->addCategory(date('G:i', $i2), //'');
                //				'hoverText=' . date (html_entity_decode ($config['date_format'], ENT_QUOTES, "UTF-8"), $i2) .
                //				';showName=' . $show_name);
            }
            //Add data
            $chart->addChartData($v);
        }
    }
    $chart->setChartParams('yAxisName=' . $unit . ';' . 'animation=0;numVDivLines=' . $num_vlines . ';showShadow=0;showAlternateVGridColor=1;showNames=1;rotateNames=1;' . 'lineThickness=0.1;anchorRadius=0.5;showValues=0;baseFontSize=9;showLimits=0;' . 'showAreaBorder=1;areaBorderThickness=0.1;areaBorderColor=000000' . ($empty == 1 ? ';yAxisMinValue=0;yAxisMaxValue=1' : ''));
    $random_number = uniqid();
    $div_id = 'chart_div_' . $random_number;
    $chart_id = 'chart_' . $random_number;
    $output = '<div id="' . $div_id . '" style="z-index:1;"></div>';
    //$output .= '<script language="JavaScript" src="include/graphs/FusionCharts/FusionCharts.js"></script>';
    $output .= '<script type="text/javascript">
			<!--
			function pie_' . $chart_id . ' () {
				var myChart = new FusionCharts("' . $homeurl . 'include/graphs/FusionCharts/FCF_' . $graph_type . '.swf", "' . $chart_id . '", "' . $width . '", "' . $height . '", "0", "1");
				myChart.setDataXML("' . addslashes($chart->getXML()) . '");
				myChart.addParam("WMode", "Transparent");
				myChart.render("' . $div_id . '");
			}
					pie_' . $chart_id . ' ();
			-->
		</script>';
    return $output;
}