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); }
$r5 = mysql_query($sql5) or die(mysql_error()); $sitio_female[] = mysql_num_rows($r5); } $chart->PlotArea->YAxis->Title = "Population"; $chart->PlotArea->YAxis->LabelsAppearance->DataFormatString = "{0}"; $series = new BarSeries(); $series->Stacked = TRUE; $series->Name = "Male"; $series->TooltipsAppearance->DataFormatString = " There is {0} Male Weighing OPT(s) on {1}"; for ($x = 1; $x <= $total_sitio; $x++) { $series->ArrayData(array($sitio_male[$x - 1])); } $chart->PlotArea->AddSeries($series); $series = new BarSeries(); $series->Stacked = TRUE; $series->Name = "Female"; $series->TooltipsAppearance->DataFormatString = " There is {0} Female Weighing OPT(s) on {1}"; for ($x = 1; $x <= $total_sitio; $x++) { $series->ArrayData(array($sitio_female[$x - 1])); } $chart->PlotArea->AddSeries($series); echo $chart->Render(); $sql2 = "SELECT * from population where classification='{$classification} '"; $r2 = mysql_query($sql2) or die(mysql_error()); $total_population = mysql_num_rows($r2); echo "<b style='color:#444'>Total Population of {$classification} is : {$total_population}</b>"; ?> </div> </body> </html>
$chart_column_line->PlotArea->YAxis->Color = "black"; $chart_column_line->PlotArea->YAxis->MajorGridLines->Color = "#b4b4b4"; $chart_column_line->PlotArea->YAxis->MinorGridLines->Color = "#d2d2d2"; $series = new ColumnSeries(); $series->Appearance->BackgroundColor = "#5CB8E3"; $series->ArrayData(array(20, 30, 40, 70, 50)); $chart_column_line->PlotArea->AddSeries($series); $series = new LineSeries(); $series->Appearance->BackgroundColor = "green"; $series->ArrayData(array(76, 15, 60, 35, 80)); $chart_column_line->PlotArea->AddSeries($series); ?> <form id="form1" method="post"> <div> <?php echo $chart_scatter->Render(); ?> </div> <div> <?php echo $chart_column_line->Render(); ?> </div> <div><i>* <u>Note</u>:</i>Generate your own chart with <a style="color:#B8305E;" target="_blank" href="http://codegen.koolphp.net/generate_koolchart.php">Code Generator</a></div> </form>
$series = new ScatterLineSeries(); $series->Appearance->BackgroundColor = "orange"; $series->LabelsAppearance->DataFormatString = "{0},{1}"; $series->LabelsAppearance->Position = "Above"; $series->TooltipsAppearance->DataFormatString = "{0},{1}"; $series->TooltipsAppearance->BackgroundColor = "orange"; $series->AddItem(new ScatterItem(-33, 15)); $series->AddItem(new ScatterItem(-5, 48)); $series->AddItem(new ScatterItem(60, -42)); $chart_scatter->PlotArea->AddSeries($series); ?> <form id="form1" method="post"> <div> <?php echo $chart->Render(); ?> </div> <div> <?php echo $chart_scatter->Render(); ?> </div> <div><i>* <u>Note</u>:</i>Generate your own chart with <a style="color:#B8305E;" target="_blank" href="http://codegen.koolphp.net/generate_koolchart.php">Code Generator</a></div> </form>
$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; $_series->AddItem($_item); $_item = new PieItem($total_female, "Female" . "(" . $total_female . ")"); $_item->BackgroundColor = "#333333"; $_series->AddItem($_item); $chart2->PlotArea->AddSeries($_series); echo $chart2->Render(); ?> </div> </body> </html>