public function columnChart($title, $labels, $data, $unit)
 {
     //        debug($title);
     //        debug($labels);
     //        debug($data);
     //        debug($unit);
     //        debug(array_values($data));
     //        return;
     //        if (sizeof($data) == 1){
     //            $data[] = $data[0]+1;
     //            $labels[] = '参照物';
     //        }
     require $this->KoolControlsFolder . "/KoolChart/koolchart.php";
     $chart = new KoolChart("chart");
     $chart->scriptFolder = $this->KoolControlsFolder . "/KoolChart";
     $chart->Title->Text = $title;
     $chart->Width = 820;
     $chart->Height = 500;
     //$chart->BackgroundColor = "#ffffee";
     //        $chart->PlotArea->XAxis->Title = "Quarters";
     if (count($data) == 0) {
         $maxV = 0;
     } else {
         $maxV = max($data);
     }
     $chart->PlotArea->XAxis->Set($labels);
     $chart->PlotArea->YAxis->MinValue = 0;
     $chart->PlotArea->YAxis->MaxValue = $maxV;
     $chart->PlotArea->YAxis->Title = "注册人数 ( .{$unit})";
     $chart->PlotArea->YAxis->LabelsAppearance->DataFormatString = "\$ {0}";
     $chart->PlotArea->YAxis->MajorStep = $maxV < 5 ? $maxV : (int) ($maxV / 5);
     $series = new ColumnSeries();
     $series->Name = "人数";
     $series->TooltipsAppearance->DataFormatString = "\$ {0} {$unit}";
     $series->ArrayData($data);
     $chart->PlotArea->AddSeries($series);
     //        $chart->Render();
     return $chart->Render();
     //        debug($chart);
     //        $series = new ColumnSeries();
     //        $series->Name = "Computers";
     //        $series->TooltipsAppearance->DataFormatString = "$ {0} millions";
     //        $series->ArrayData(array(34, 55, 10, 40));
     //        $chart->PlotArea->AddSeries($series);
     //
     //        $series = new ColumnSeries();
     //        $series->Name = "Tablets & e-readers";
     //        $series->TooltipsAppearance->DataFormatString = "$ {0} millions";
     //        $series->ArrayData(array(56, 23, 56, 80));
     //        $chart->PlotArea->AddSeries($series);
 }
示例#2
0
		<option value='1'>Pie Graph</option>
		<option value='2' >Bar Graph</option>
		<option value='3'selected>Stacked Chart</option>
	</select>

</center>
<div id='_chart'>
	<center>
<?php 
include "connection.php";
connect();
$classification = "Weighing OPT";
$KoolControlsFolder = "KoolControls";
//Relative path to "KoolPHPSuite/KoolControls" folder
require $KoolControlsFolder . "/KoolChart/koolchart.php";
$chart = new KoolChart("chart");
$chart->scriptFolder = $KoolControlsFolder . "/KoolChart";
$chart->Title->Text = "Weighing OPT Statistics";
$chart->Width = 680;
$chart->Height = 480;
$chart->Legend->Appearance->Position = "top";
$chart->PlotArea->XAxis->Title = "SITIOS";
$sql = "SELECT * from sitio";
$r1 = mysql_query($sql) or die(mysql_error());
$total_sitio = mysql_num_rows($r1);
while ($row = mysql_fetch_array($r1)) {
    list($a, $b, $c) = $row;
    $chart->PlotArea->XAxis->Set(array("{$b}"));
    //for counting total Babies
    $sql3 = "SELECT * from population where sitio ='{$b}' and classification='{$classification} '";
    $r3 = mysql_query($sql3) or die(mysql_error());
示例#3
0
$series = new ScatterSeries("Actual");
$series->Appearance->BackgroundColor = "orange";
$series->LabelsAppearance->DataFormatString = "({0},{1})";
$series->TooltipsAppearance->DataFormatString = "({0},{1})";
$series->AddItem(new ScatterItem(11, 13));
$series->AddItem(new ScatterItem(13, 12));
$series->AddItem(new ScatterItem(15, 20));
$series->AddItem(new ScatterItem(22, 30));
$series->AddItem(new ScatterItem(25, 15));
$series->AddItem(new ScatterItem(30, 40));
$series->AddItem(new ScatterItem(32, 25));
$series->AddItem(new ScatterItem(90, 80));
$series->AddItem(new ScatterItem(70, 65));
$series->AddItem(new ScatterItem(90, 75));
$chart_scatter->PlotArea->AddSeries($series);
$chart_column_line = new KoolChart("chart_column_line");
$chart_column_line->scriptFolder = $KoolControlsFolder . "/KoolChart";
$chart_column_line->Height = 550;
$chart_column_line->Width = 600;
$chart_column_line->Title->Text = "Chart with Line and Column Series";
$chart_column_line->Legend->Appearance->Visible = false;
$chart_column_line->PlotArea->XAxis->Title = "";
$chart_column_line->PlotArea->XAxis->Color = "black";
$chart_column_line->PlotArea->XAxis->MajorGridLines->Color = "#b4b4b4";
$chart_column_line->PlotArea->XAxis->MinorGridLines->Color = "#d2d2d2";
$chart_column_line->PlotArea->XAxis->Set(array("Q1", "Q2", "Q3", "Q4", "Q5"));
$chart_column_line->PlotArea->YAxis->Title = "";
$chart_column_line->PlotArea->YAxis->MinorTickSize = 0;
$chart_column_line->PlotArea->YAxis->MaxValue = 100;
$chart_column_line->PlotArea->YAxis->MinValue = 0;
$chart_column_line->PlotArea->YAxis->MajorStep = 10;
示例#4
0
$chart->PlotArea->XAxis->Title = "";
$chart->PlotArea->XAxis->MajorTickSize = 2;
$chart->PlotArea->YAxis->Title = "";
$chart->PlotArea->YAxis->MaxValue = 50;
$chart->PlotArea->YAxis->MinValue = -30;
$chart->PlotArea->YAxis->MajorStep = 10;
$chart->PlotArea->YAxis->MinorStep = 2;
$series = new BarSeries();
$series->Appearance->BackgroundColor = "#399C48";
$series->ArrayData(array(25, -12, 39));
$chart->PlotArea->AddSeries($series);
$series = new BarSeries();
$series->Appearance->BackgroundColor = "#28A1DA";
$series->ArrayData(array(-15, 38, -11));
$chart->PlotArea->AddSeries($series);
$chart_scatter = new KoolChart("chart_scatter");
$chart_scatter->scriptFolder = $KoolControlsFolder . "/KoolChart";
$chart_scatter->Title->Text = "ScatterLine with negative values";
$chart_scatter->Width = 500;
$chart_scatter->Legend->Appearance->Visible = false;
$chart_scatter->PlotArea->XAxis->Title = "";
$chart_scatter->PlotArea->XAxis->MaxValue = 100;
$chart_scatter->PlotArea->XAxis->MinValue = -60;
$chart_scatter->PlotArea->XAxis->MajorStep = 20;
$chart_scatter->PlotArea->XAxis->MinorStep = 4;
$chart_scatter->PlotArea->YAxis->Title = "";
$chart_scatter->PlotArea->YAxis->MaxValue = 60;
$chart_scatter->PlotArea->YAxis->MinValue = -60;
$chart_scatter->PlotArea->YAxis->MajorStep = 10;
$chart_scatter->PlotArea->YAxis->MinorStep = 2;
$series = new ScatterLineSeries();
示例#5
0
        $_item->BackgroundColor = "#022";
    } elseif ($color == 6) {
        $_item->BackgroundColor = "#ef2";
    } elseif ($color = 7) {
        $_item->BackgroundColor = "#2f1";
    } elseif ($color == 8) {
        $_item->BackgroundColor = "#2e1";
    } elseif ($color == 9) {
        $_item->BackgroundColor = "#e02";
    }
    $_series->AddItem($_item);
}
$chart->PlotArea->AddSeries($_series);
echo $chart->Render();
echo "<hr/>";
$chart2 = new KoolChart("chart2");
$chart2->scriptFolder = $KoolControlsFolder . "/KoolChart";
$chart2->Width = 400;
$chart2->Height = 400;
$chart2->Title->Text = "Total Male and Female";
$sql = "SELECT * from population where gender='Male' and classification='{$classification} '";
$sql2 = "SELECT * from population where gender='Female' and classification='{$classification} '";
$r1 = mysql_query($sql) or die(mysql_error());
$r2 = mysql_query($sql2) or die(mysql_error());
$total_male = mysql_num_rows($r1);
$total_female = mysql_num_rows($r2);
$_series = new PieSeries("Genders");
$_series->LabelsAppearance->DataFormatString = "{0}%";
$_item = new PieItem($total_male, "Male" . "(" . $total_male . ")");
$_item->BackgroundColor = "#777";
$_item->Exploded = true;