本文整理汇总了PHP中pChart::drawBarGraph方法的典型用法代码示例。如果您正苦于以下问题:PHP pChart::drawBarGraph方法的具体用法?PHP pChart::drawBarGraph怎么用?PHP pChart::drawBarGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pChart
的用法示例。
在下文中一共展示了pChart::drawBarGraph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: bar
function bar($valores, $label, $titulo)
{
$nombre = tempnam('/tmp', 'g') . '.png';
$DataSet = new pData();
foreach ($valores as $ind => $val) {
$DataSet->AddPoint(array($val), 'Serie' . $ind);
$DataSet->SetSerieName($label[$ind], 'Serie' . $ind);
}
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$Test = new pChart(300, 200);
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8);
$Test->setGraphArea(60, 40, 250, 180);
$Test->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, true, 0, 0);
$Test->drawGrid(4, TRUE, 200, 200, 200, 50);
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
//$Test->drawOverlayBarGraph($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8);
$Test->drawLegend(220, 7, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 10);
$Test->drawTitle(10, 22, $titulo, 50, 50, 50, 300);
$Test->Render($nombre);
return $nombre;
}
示例2: drawChart
function drawChart($title, $DataSet, $type, $colors, $legend = false)
{
// Initialise the graph
$Chart = new pChart(1300, 700);
$Chart->setFontProperties("Fonts/tahoma.ttf", 8);
$Chart->setGraphArea(50, 50, 1200, 600);
$Chart->drawGraphArea(255, 255, 255, TRUE);
$Chart->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 0, TRUE);
// Draw the 0 line
$Chart->setFontProperties("Fonts/tahoma.ttf", 6);
$Chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
foreach ($colors as $idx => $color) {
$Chart->setColorPalette($idx, $color[0], $color[1], $color[2]);
}
if ($type == "bar") {
$Chart->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription());
} else {
if ($type == "line") {
$Chart->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
}
}
if ($legend) {
$Chart->drawLegend(465, 40, $DataSet->GetDataDescription(), 255, 255, 255);
}
// Finish the graph
$Chart->setFontProperties("Fonts/tahoma.ttf", 10);
$Chart->drawTitle(60, 22, $title, 50, 50, 50, 530);
$Chart->Stroke();
}
示例3: drawBar
/**
* Draw bar style chart
* @return unknown
*/
protected function drawBar()
{
// prepare font & series
$this->_prepareSerie();
$this->_prepareFont();
// init chart params
$outer_w = $this->w - 5;
// Outer frame witdh
$outer_h = $this->h - 5;
// Outer frame heigth
$inner_w = $this->w - 7;
// Inner frame witdh
$inner_h = $this->h - 7;
// Inner frame heigth
$chart_w = $this->w - 150;
// Chart frame witdh
$chart_h = $this->h - 40;
// Chart frame heigth
$title_w = $this->w - 200;
// Title width
$title_h = 45;
// Title height
$legend_w = $chart_w + 30;
// Legend width
$legend_h = 40;
// Legend height
// chart styles
$grid = isset($this->p['grid']) ? $this->p['grid'] : false;
// fill chart
$this->chart->drawBackground(255, 255, 255);
$this->chart->setFontProperties($this->font, 7);
// set font and size
$this->chart->drawRoundedRectangle(5, 5, $outer_w, $outer_h, 10, 230, 230, 230);
// drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
$this->chart->drawFilledRoundedRectangle(7, 7, $inner_w, $inner_h, 10, 240, 240, 240);
// drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
$this->chart->setGraphArea(90, 40, $chart_w, $chart_h);
// setGraphArea($X1,$Y1,$X2,$Y2)
$this->chart->drawGraphArea(255, 255, 255, TRUE);
// drawGraphArea($R,$G,$B)
$this->chart->drawScale($this->data->GetData(), $this->data->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, $this->margin, $this->skip);
// drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1,$RightScale=FALSE)
$this->data->RemoveSerie('DEFAULT_SCALE');
// clear scale serie for setScale method
// draw grid
if ($grid) {
$this->chart->drawGrid(3, TRUE, 230, 230, 230, 50);
// drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=255)
}
// draw the cubic curve graph
$this->chart->drawBarGraph($this->data->GetData(), $this->data->GetDataDescription(), TRUE);
// add Title
$this->chart->setFontProperties($this->font, 10);
$this->chart->drawTitle(40, 0, $this->title, 50, 50, 50, $title_w, $title_h);
// drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)
// add Legend
$this->chart->setFontProperties($this->font, 8);
$this->chart->drawLegend($legend_w, $legend_h, $this->data->GetDataDescription(), 255, 255, 255);
// drawLegend($description,$R,$G,$B)
}
示例4: writeBarData
function writeBarData($data, $graph)
{
if ($data != "") {
echo "Plottong " . $graph . "\n";
$dataset1 = array();
$dataset2 = array();
$counter = 0;
$toggle = true;
$data = array_reverse($data, TRUE);
ksort($data);
foreach ($data as $key => $value) {
if ($counter % 5 != 0) {
$key = " ";
}
array_push($dataset1, $key);
array_push($dataset2, $value);
$counter++;
}
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($dataset2, "Serie1");
$DataSet->AddPoint($dataset1, "XLabel");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("XLabel");
$DataSet->RemoveSerie("XLabel");
$DataSet->SetSerieName("Membership", "Serie1");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 680, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), 'SCALE_NORMAL', 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(596, 150, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Membership by Month", 50, 50, 50, 585);
$Test->Render("{$graph}-bar.png");
}
}
示例5: generate_image
function generate_image($site_name, $visits)
{
$font = APP_PATH . "libs/pchart/Fonts/tahoma.ttf";
//$font = APP_PATH."includes/pchart/Fonts/DejaVuSans.ttf";
global $lang;
// Dataset definition
$DataSet = new pData();
$names = array();
$points = array();
foreach ($visits as $date => $visit) {
$points[] = $visit;
$text = $lang['days'][date('N', strtotime($date))];
$names[] = $text;
}
$DataSet->AddPoint($points, "Lankytojai");
$DataSet->AddPoint($names, "days");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("days");
$DataSet->SetAbsciseLabelSerie('days');
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties($font, 8);
$Test->setGraphArea(50, 30, 680, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties($font, 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);
// Finish the graph
$Test->setFontProperties($font, 8);
// $Test->drawLegend(100,20,$DataSet->GetDataDescription(),255,255,255);
$Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
$Test->setFontProperties($font, 10);
$Test->drawTitle(50, 22, $site_name, 50, 50, 50, 585);
$path = IMAGE_PATH . "{$site_name}.png";
if (file_exists($path)) {
unlink($path);
}
$Test->Render($path);
return $path;
}
示例6: generate_statistics
//.........这里部分代码省略.........
$counter=0;
foreach ($lbl as $label)
{
$DataSet->SetSerieName($label,"Serie$counter");
$counter++;
}
if ($MyCache->IsInCache("graph".$surveyid,$DataSet->GetData()))
{
$cachefilename=basename($MyCache->GetFileFromCache("graph".$surveyid,$DataSet->GetData()));
}
else
{
$graph = new pChart(1,1);
$graph->setFontProperties($rootdir."/fonts/".$chartfontfile, $chartfontsize);
$legendsize=$graph->getLegendBoxSize($DataSet->GetDataDescription());
if ($legendsize[1]<320) $gheight=420; else $gheight=$legendsize[1]+100;
$graph = new pChart(690+$legendsize[0],$gheight);
$graph->loadColorPalette($homedir.'/styles/'.$admintheme.'/limesurvey.pal');
$graph->setFontProperties($rootdir."/fonts/".$chartfontfile,$chartfontsize);
$graph->setGraphArea(50,30,500,$gheight-60);
$graph->drawFilledRoundedRectangle(7,7,523+$legendsize[0],$gheight-7,5,254,255,254);
$graph->drawRoundedRectangle(5,5,525+$legendsize[0],$gheight-5,5,230,230,230);
$graph->drawGraphArea(255,255,255,TRUE);
$graph->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_START0,150,150,150,TRUE,90,0,TRUE,5,false);
$graph->drawGrid(4,TRUE,230,230,230,50);
// Draw the 0 line
$graph->setFontProperties($rootdir."/fonts/".$chartfontfile,$chartfontsize);
$graph->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the bar graph
$graph->drawBarGraph($DataSet->GetData(),$DataSet->GetDataDescription(),FALSE);
//$Test->setLabel($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie4","1","Important point!");
// Finish the graph
$graph->setFontProperties($rootdir."/fonts/".$chartfontfile, $chartfontsize);
$graph->drawLegend(510,30,$DataSet->GetDataDescription(),255,255,255);
$MyCache->WriteToCache("graph".$surveyid,$DataSet->GetData(),$graph);
$cachefilename=basename($MyCache->GetFileFromCache("graph".$surveyid,$DataSet->GetData()));
unset($graph);
}
} //end if (bar chart)
//Pie Chart
else
{
// this block is to remove the items with value == 0
$i = 0;
while (isset ($gdata[$i]))
{
if ($gdata[$i] == 0)
{
array_splice ($gdata, $i, 1);
array_splice ($lbl, $i, 1);
}
else
{$i++;}
}
$lblout=array();
if ($language=='ar')
{
$lblout=$lbl; //reset text order to original
include_once($rootdir.'/classes/core/Arabic.php');
示例7: foreach
}
if ($barexists || $overlayexists) {
foreach ($plot as $k1 => $v1) {
if ($v1["type"] == "BAR" || $v1["type"] == "STACKEDBAR" || $v1["type"] == "OVERLAYBAR") {
setSerieDrawable($plot, $graphData, $v1["name"] . $k1, TRUE);
}
}
}
$stackeddrawn = true;
if ($stackedexists) {
$graphImage->drawStackedBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
if ($overlayexists) {
$graphImage->drawOverlayBarGraph($graphData->GetData(), $graphData->GetDataDescription(), 90);
} else {
$graphImage->drawBarGraph($graphData->GetData(), $graphData->GetDataDescription());
}
}
break;
case "SCATTER":
if ($scatterdrawn) {
break;
}
$scatterdrawn = true;
$series1 = false;
$series2 = false;
$graphImage->reportWarnings("GD");
$ct = 0;
foreach ($plot as $k1 => $v1) {
if ($v1["type"] == "SCATTER") {
if ($ct == 0) {
示例8: pchartAction
public function pchartAction()
{
// $this->_helper->layout->disableLayout();
$this->_helper->layout->setLayout("layout_admin");
include "pData.class";
include "pChart.class";
$this->view->showArray = $this->testdemoAction();
$showdate = array();
$showreport = array();
foreach ($this->view->showArray as $show) {
array_push($showdate, substr($show['date'], strlen($show['date']) - 4, 4));
array_push($showreport, $show['count']);
}
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array_slice($showreport, 0, 26), "Serie1");
$DataSet->AddPoint(array_slice($showdate, 0, 26), "Serie2");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie2");
$DataSet->SetSerieName("Reports", "Serie1");
$DataSet->SetYAxisName('Report Count');
$DataSet->SetXAxisName('Date');
// Initialise the graph
$Test = new pChart(900, 250);
$Test->setFontProperties("xihei.ttf", 8);
$Test->setGraphArea(50, 30, 780, 200);
$Test->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255);
$Test->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties("xihei.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
// Finish the graph
$Test->setFontProperties("xihei.ttf", 8);
$Test->drawLegend(596, 50, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("xihei.ttf", 10);
$Test->drawTitle(200, 22, "Reports by Day in Jue.", 50, 50, 50, 585);
$Test->Render("Naked1.png");
//=====================================================================================
// Dataset definition
$DataSet2 = new pData();
$DataSet2->AddPoint(array(38, 22, 606), "Serie1");
$DataSet2->AddPoint(array("Male", "Female", "Unkown"), "Serie2");
$DataSet2->AddAllSeries();
$DataSet2->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test2 = new pChart(300, 200);
$Test2->loadColorPalette("softtones.txt");
$Test2->drawFilledRoundedRectangle(7, 7, 293, 193, 5, 255, 255, 255);
$Test2->drawRoundedRectangle(5, 5, 295, 195, 5, 230, 230, 230);
// This will draw a shadow under the pie chart
$Test2->drawFilledCircle(122, 102, 70, 200, 200, 200);
// Draw the pie chart
$Test2->setFontProperties("tahoma.ttf", 8);
$Test2->drawBasicPieGraph($DataSet2->GetData(), $DataSet2->GetDataDescription(), 120, 100, 70, PIE_PERCENTAGE, 255, 255, 218);
$Test2->drawPieLegend(230, 15, $DataSet2->GetData(), $DataSet2->GetDataDescription(), 250, 250, 250);
$Test2->Render("Naked2.png");
//=====================================================================================
// select province
$db = Zend_Registry::get('db');
$selectprovince = $db->select();
$selectprovince->from('consumer', array("province", "count(*) as count"))->where("pest is null")->group("consumer.province")->order("count desc");
$provinceArray = $db->fetchAll($selectprovince);
$this->view->showprovince = '';
$this->view->showprovincecount = '';
$showprovince = array();
$showprovincecount = array();
foreach ($provinceArray as $province) {
if ($province['province'] == null || $province['province'] == '') {
array_push($showprovince, 'Unkown');
} else {
array_push($showprovince, $province['province']);
}
array_push($showprovincecount, $province['count']);
}
// Dataset definition
$DataSet3 = new pData();
$DataSet3->AddPoint(array_slice($showprovincecount, 0, 20), "Serie1");
$DataSet3->AddPoint(array_slice($showprovince, 0, 20), "Serie2");
$DataSet3->AddSerie("Serie1");
$DataSet3->SetAbsciseLabelSerie("Serie2");
$DataSet3->SetSerieName("Spark Count", "Serie1");
$DataSet3->SetYAxisName('Spark Count');
$DataSet3->SetXAxisName('Province');
Zend_Debug::dump($DataSet3->GetDataDescription());
// Initialise the graph
$Test3 = new pChart(900, 250);
$Test3->setFontProperties("xihei.ttf", 8);
$Test3->setGraphArea(50, 30, 780, 200);
$Test3->drawFilledRoundedRectangle(7, 7, 793, 248, 5, 255, 255, 255);
$Test3->drawRoundedRectangle(5, 5, 795, 249, 5, 230, 230, 230);
$Test3->drawGraphArea(255, 255, 255, TRUE);
$Test3->drawScale($DataSet3->GetData(), $DataSet3->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test3->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test3->setFontProperties("xihei.ttf", 6);
//.........这里部分代码省略.........
示例9: componentLineGraph
public function componentLineGraph()
{
$DataSet = new pData();
$maxvals = array();
foreach ($this->datasets as $ds_id => $dataset) {
$DataSet->AddPoint($dataset['values'], "Serie" . $ds_id, array_keys($dataset['values']));
$maxvals[] = max($dataset['values']);
if (isset($dataset['burndown'])) {
$amount = count($dataset['values']) > 1 ? $dataset['burndown']['maxEstimation'] / (count($dataset['values']) - 1) : 0;
for ($i = 0; $i < count($dataset['values']); $i++) {
$burndownValues[] = $dataset['burndown']['maxEstimation'] - $i * $amount;
}
$DataSet->AddPoint($burndownValues, "Burndown" . $ds_id, $dataset['burndown']['maxEstimation']);
}
}
$DataSet->AddAllSeries();
if (isset($this->labels)) {
$DataSet->AddPoint($this->labels, "Labels");
$DataSet->SetAbsciseLabelSerie("Labels");
} else {
$DataSet->SetAbsciseLabelSerie();
}
foreach ($this->datasets as $ds_id => $dataset) {
$DataSet->SetSerieName($dataset['label'], "Serie" . $ds_id);
if (isset($dataset['burndown'])) {
$DataSet->SetSerieName($dataset['burndown']['label'], "Burndown" . $ds_id);
}
}
if (isset($this->values_title)) {
$DataSet->SetYAxisName($this->values_title);
}
if (isset($this->labels_title)) {
$DataSet->SetXAxisName($this->labels_title);
}
// Initialise the graph
$Test = new pChart($this->width, $this->height);
$Test->setFixedScale(0, ceil(max($maxvals) / 5) * 5);
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 8);
if (isset($this->labels_title)) {
$Test->setGraphArea(50, 30, $this->width - 30, $this->height - 45);
} else {
$Test->setGraphArea(50, 30, $this->width - 30, $this->height - 30);
}
$Test->drawFilledRoundedRectangle(2, 2, $this->width - 3, $this->height - 3, 5, 240, 240, 240);
$Test->drawRoundedRectangle(0, 0, $this->width - 1, $this->height - 1, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the cubic curve graph
if (isset($this->style) && $this->style == 'curved') {
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
} elseif (isset($this->style) && $this->style == 'filled_line') {
$Test->drawFilledLineGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50, true);
} elseif (isset($this->style) && $this->style == 'stacked_bar') {
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 50, true);
} elseif (isset($this->style) && $this->style == 'single_bar') {
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
} else {
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
}
if (isset($this->include_plotter) && $this->include_plotter) {
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
}
// Finish the graph
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSans.ttf', 8);
//$Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->drawLegend(55, 35, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties(THEBUGGENIE_MODULES_PATH . 'pchart' . DS . 'fonts' . DS . 'DroidSansBold.ttf', 10);
$Test->drawTitle(50, 22, $this->title, 50, 50, 50, $this->width - 30);
$Test->Stroke();
//("example2.png");
}
示例10: preGraphCreation
/**
* Creates the object and prepares it for rendering.
* Does all the calculation like borders, margins, paddings ....
*
* @return void
*/
private function preGraphCreation()
{
// Initialize the graph
$this->objChart = new pChart($this->intWidth, $this->intHeight);
//set the color palette to be used
foreach ($this->arrDefaultColorPalette as $intKey => $strCurrentColor) {
$arrCurColor = hex2rgb($strCurrentColor);
$this->objChart->setColorPalette($intKey, $arrCurColor[0], $arrCurColor[1], $arrCurColor[2]);
}
//calculate all needed params, draw that funky shit
//the outer bounding and pane - rounded and with sharp corners
$arrBackgroundColor = hex2rgb($this->strBackgroundColor);
if ($this->bitRoundedCorners) {
$this->objChart->drawFilledRoundedRectangle(2, 2, $this->intWidth - 3, $this->intHeight - 3, 5, $arrBackgroundColor[0], $arrBackgroundColor[1], $arrBackgroundColor[2]);
$arrOuterBack = hex2rgb($this->strOuterFrameColor);
$this->objChart->drawRoundedRectangle(0, 0, $this->intWidth - 1, $this->intHeight - 1, 5, $arrOuterBack[0], $arrOuterBack[1], $arrOuterBack[2]);
} else {
$this->objChart->drawFilledRectangle(0, 0, $this->intWidth, $this->intHeight, $arrBackgroundColor[0], $arrBackgroundColor[1], $arrBackgroundColor[2]);
}
//the graph area - x and or y-axis label present?
if ($this->bitRenderLegend) {
$intRightMargin = 10;
} else {
$intRightMargin = 20;
}
$intTopMargin = 15;
$intBottomMargin = 30;
$intLeftMargin = 40;
$intLegendWidth = 0;
if ($this->bitRenderLegend) {
$intLegendWidth = 120;
}
$intWidth = $this->intWidth - $intRightMargin - $intLegendWidth;
$intHeight = $this->intHeight - $intBottomMargin;
$intLeftStart = $intLeftMargin;
$intTopStart = $intTopMargin;
if ($this->strYAxisTitle != "") {
$intLeftStart += 15;
//$intWidth -= 15; //TODO: why not needed?
}
if ($this->strXAxisTitle != "") {
$intHeight -= 15;
}
if ($this->strGraphTitle != "") {
//$intHeight -= 12; //TODO: why not needed???
$intTopStart += 12;
}
if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
$this->objChart->setGraphArea($intLeftStart, $intTopStart, $intWidth, $intHeight);
$arrPaneBackground = hex2rgb($this->strGraphBackgroundColor);
$this->objChart->drawGraphArea($arrPaneBackground[0], $arrPaneBackground[1], $arrPaneBackground[2], true);
}
$arrFontColors = hex2rgb($this->strFontColor);
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 8);
//set up the axis-titles
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR || $this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
if ($this->strXAxisTitle != "") {
$this->objDataset->SetXAxisName($this->strXAxisTitle);
}
if ($this->strYAxisTitle != "") {
$this->objDataset->SetYAxisName($this->strYAxisTitle);
}
}
//the x- and y axis, in- / exclusive margins
if ($this->bitAdditionalDatasetAdded && $this->bitScaleFromAdditionalDataset) {
$this->objChart->drawScale($this->objAdditionalDataset->GetData(), $this->objAdditionalDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_START0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_STACKEDBAR) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_ADDALLSTART0, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, true);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
$this->objChart->drawScale($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), SCALE_NORMAL, $arrFontColors[0], $arrFontColors[1], $arrFontColors[2], TRUE, $this->intXAxisAngle, 1, false);
}
}
}
}
//the background grid
if ($this->intCurrentGraphMode != $this->GRAPH_TYPE_PIE) {
$arrGridColor = hex2rgb($this->strGridColor);
$this->objChart->drawGrid(4, true, $arrGridColor[0], $arrGridColor[1], $arrGridColor[2], 50);
}
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_LINE) {
// Draw the line graph
$this->objChart->drawLineGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription());
//dots in line
$this->objChart->drawPlotGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), 3, 2, 255, 255, 255);
} else {
if ($this->intCurrentGraphMode == $this->GRAPH_TYPE_BAR) {
//the zero-line
$this->objChart->setFontProperties(class_resourceloader::getInstance()->getCorePathForModule("module_system", true) . "/module_system/system" . $this->strFont, 6);
$this->objChart->drawBarGraph($this->objDataset->GetData(), $this->objDataset->GetDataDescription(), TRUE);
//.........这里部分代码省略.........
示例11: getChart
/**
* @author Patrick plichart
* @param string localgraphid an identifier for the graph to be displayed
* @param array $datax a flat sery of x labels
* @param array $setOfySeries an array of y series to be drawn (needs to be consistent with xsery), keys indicates the legend title
* @param string $title the title of the graph
* @param string xAxisLabel label of the x Axis
* @param string yAxisLabel label of the y Axis
* @return string the url of the generated graph
*/
private function getChart($localGraphId, $datax, $setOfySeries, $title, $type = "bar", $xAxisLabel = "", $yAxisLabel = "", $r = "208", $g = "2", $b = "57")
{
// Dataset definition
if (count($datax) == 0) {
throw new \common_exception_NoContent("Empty data set");
}
$dataSet = new \pData();
foreach ($setOfySeries as $legend => $ysery) {
$dataSet->AddPoint($ysery, $legend);
$dataSet->SetSerieName($legend, $legend);
}
$dataSet->AddAllSeries();
$dataSet->AddPoint($datax, "xLabels");
$dataSet->SetYAxisName($yAxisLabel);
$dataSet->SetXAxisName($xAxisLabel);
$dataSet->SetAbsciseLabelSerie("xLabels");
// Initialise the graph
$graph = new \pChart(490, 260);
$graph->createColorGradientPalette($r, $g, $b, $r, $g, $b, 5);
// aa is way too slow here
$graph->Antialias = false;
$graph->setFontProperties(fontName, 8);
$graph->setGraphArea(55, 40, 450, 200);
// draw the background rectangle
$graph->drawFilledRoundedRectangle(7, 7, 655, 253, 5, 240, 240, 240);
$graph->drawRoundedRectangle(5, 5, 655, 225, 5, 230, 230, 230);
$graph->drawGraphArea(255, 255, 255, true);
$graph->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, true, 0, 2, true);
$graph->drawGrid(4, true, 230, 230, 230, 50);
// Draw the 0 line
$graph->setFontProperties(fontName, 6);
$graph->drawTreshold(0, 143, 55, 72, true, true);
// Draw the bar graph
switch ($type) {
case "bar":
$graph->drawBarGraph($dataSet->GetData(), $dataSet->GetDataDescription(), true);
break;
case "line":
$graph->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
$graph->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 3, 2, 255, 255, 255);
break;
}
// Finish the graph
$graph->setFontProperties(fontName, 9);
$graph->drawLegend(50, 220, $dataSet->GetDataDescription(), 254, 254, 254);
$graph->setFontProperties(fontName, 8);
$graph->drawTitle(15, 30, $title, 50, 80, 50);
$url = $this->getUniqueMediaFileName($localGraphId, "png");
$graph->Render(ROOT_PATH . $url);
return ROOT_URL . $url;
}
示例12: main
//.........这里部分代码省略.........
$this->autoRender = false;
//3
App::import('Vendor', 'pData', array('file' => 'pchart' . DS . 'pData.class'));
App::import('Vendor', 'pChart', array('file' => 'pchart' . DS . 'pChart.class'));
//4
$fontFolder = APP . 'vendors' . DS . 'pchart' . DS . 'Fonts';
$fontFolder = '..' . DS . '..' . DS . 'vendors' . DS . 'pchart' . DS . 'Fonts';
// $SchemaFolder = APP.'vendors'.DS.'pchart'.DS.'schema';
//5
// Dataset definition
$DataSet = new pData();
$MaxTons = max($report_day);
$MaxTons = $MaxTons + 100;
foreach ($report_day as $key => $value) {
$MyDay[] = (int) $key;
}
// $this->out(pr($MyDay));
$DataSet->AddPoint($report_day, "Serie1");
// $DataSet->AddPoint('4',"Serie2");
// $DataSet->AddPoint('20',"Serie3");
// $DataSet->AddPoint($MyDay,"Name");
// exit();
// $this->out(pr($DataSet->GetData()));
// $idx=0;
// foreach($MyDay as $key => $value){
// $DataSet->AddPoint($value,"Serie1");
// $DataSet->AddPoint((int)$key,"Name");
// }
// $this->out(pr($MyDay));
// $DataSet->GetData()['0']['Name']=;
// $DataSet->GetData()['0']['Name']=1;
$this->out(pr($DataSet->GetData()));
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$key = $value = null;
$DataSet->SetSerieName("Toneladas", "Serie1");
$DataSet->SetSerieName("Dia", "Serie2");
$DataSet->SetYAxisName("Toneladas Dias");
$DataSet->SetYAxisUnit("Ton");
$DataSet->SetXAxisName("Dias");
$DataSet->SetXAxisFormat("number");
// Initialise the graph
// pr($SchemaFolder);
$Test = new pChart(820, 260);
$Test->setFixedScale(1, $MaxTons, 5, 0, $NumDays, 5);
$Test->setDateFormat("H:m");
$Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
$Test->setColorPalette(0, 115, 173, 207);
$Test->setColorPalette(1, 144, 196, 226);
$Test->setColorPalette(2, 174, 216, 240);
$Test->setColorPalette(3, 64, 140, 195);
$Test->setColorPalette(4, 104, 188, 209);
$Test->setColorPalette(5, 99, 200, 226);
$Test->setColorPalette(6, 82, 124, 148);
$Test->setColorPalette(7, 97, 152, 183);
$Test->setColorPalette(8, 105, 210, 231);
$Test->setColorPalette(9, 167, 219, 216);
$Test->setColorPalette(10, 224, 228, 204);
$Test->setColorPalette(11, 243, 134, 48);
// $Test->loadColorPalette("/tmp/schema/blue.txt",",");
$Test->setGraphArea(100, 30, 790, 200);
// $Test->drawFilledRoundedRectangle(7,7,693,223,5,240,240,240);
$Test->drawRoundedRectangle(5, 5, 810, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
// dibujar la grafica
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the line graph
// Draw the 0 line
$Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE, 80);
// $Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription());
// $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
// $Test->drawXYPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie3");
// $Test->drawXYGraph($DataSet->GetData(),$DataSet->GetDataDescription(),"Serie1","Serie2");
// Finish the graph
$today = date('Y-m-d');
// $Test->setFontProperties($fontFolder.DS."tahoma.ttf",8);
// $Test->drawLegend(820,150,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties($fontFolder . DS . "tahoma.ttf", 10);
if (empty($all) && !empty($KeyArea) && !empty($CurrentMonth)) {
// CurrentMonth Area
$Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$MyMonth} {$CurrentYear}", 50, 50, 50, 585);
$Test->Render("../../app/webroot/img/thumbs/graph_" . $today . "_" . $KeyArea . "_" . $Fraccion . ".png");
}
if ($all == true && $KeyArea == false && $CurrentMonth == false) {
// AllYear
$Test->drawTitle(220, 22, "Toneladas {$CurrentYear}", 50, 50, 50, 585);
$Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png");
}
if ($all == true && $KeyArea > 0 && $CurrentMonth == false) {
// AllYearArea
$Test->drawTitle(220, 22, "Toneladas {$ThisArea[$KeyArea]} {$CurrentYear}", 50, 50, 50, 585);
$Test->Render("../../app/webroot/img/thumbs/graph_" . $CurrentYear . "_" . $KeyArea . ".png");
}
// $Test->drawTitle(220,22,"Toneladas $MyMonth $CurrentYear",50,50,50,585);
// $Test->Render("../../app/webroot/img/thumbs/graph_".$today."_".$KeyArea."_".$Fraccion.".png");
}
示例13: pData
include "../../class/pImage.class.php";
include "../../class/pStock.class.php";
include "../lib/nmcload.php";
$minscale = 0;
$maxscale = 0;
$MyData = new pData();
load_nmc_depth($MyData, 5, $minscale, $maxscale);
//$MyData->AddAllSeries();
$MyData->SetAbsciseLabelSerie("values");
$MyData->SetSerieName("Depth", "Depth");
$MyData->SetSerieName("Orders", "Orders");
$MyData->SetSerieName("totNmc", "totNmc");
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 680, 200);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($MyData->GetData(), $MyData->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties("Fonts/tahoma.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($MyData->GetData(), $MyData->GetDataDescription(), TRUE);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(596, 150, $MyData->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Example 12", 50, 50, 50, 585);
$Test->Render("example12.png");
示例14: gerarGraficoBarras
public function gerarGraficoBarras()
{
if (count($this->_dados[0]) < 1) {
die("Algum dado deve ser passado. <br>Ex. \$grafico->setDados(array(10,20,30));");
}
if (count($this->_dados[0]) != count($this->_tituloItens)) {
die("A quantidade de titulos passados difere da quantidade de valores. Certifique-se de que eles estejam em igual numero.");
}
// Montando plotagens com os arrays de dados passados
$DataSet = new pData();
// Definindo labels dos eixos
if (!empty($this->_tituloEixoX)) {
$DataSet->SetXAxisName($this->_tituloEixoX);
$DataSet->SetYAxisName($this->_tituloEixoY);
}
// Montando plotagens com os arrays de dados passados
for ($i = 0; $i < count($this->_dados); $i++) {
$DataSet->AddPoint($this->_dados[$i], $this->_tituloDados[$i]);
$DataSet->AddSerie($this->_tituloDados[$i]);
//x($this->_tituloItens[$i]);
}
// Definindo labels dos dados
if (count($this->_tituloItens) > 0) {
$DataSet->AddPoint($this->_tituloItens, "labels");
$DataSet->SetAbsciseLabelSerie("labels");
}
// Initialise the graph
$Test = new pChart($this->_larguraGrafico * 2, $this->_alturaGrafico * 2);
$Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 8);
$Test->setGraphArea($this->_margem * 3, $this->_margem * 2, 120 * $this->_larguraGrafico / 100, 130 * $this->_alturaGrafico / 100 - 10);
$Test->drawFilledRoundedRectangle(7, 7, 150 * $this->_larguraGrafico / 100, 150 * $this->_alturaGrafico / 100, 5, $this->_corFundo["r"], $this->_corFundo["g"], $this->_corFundo["b"]);
$Test->drawRoundedRectangle(5, 5, 150 * $this->_larguraGrafico / 100 + 3, 150 * $this->_alturaGrafico / 100 + 3, 5, $this->_corMargem["r"], $this->_corMargem["g"], $this->_corMargem["b"]);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, $this->_corLabels["r"], $this->_corLabels["g"], $this->_corLabels["b"], TRUE, $this->_anguloValores, 0, TRUE);
$Test->drawGrid(4, TRUE);
// Draw the 0 line
$Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 10);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
if ($this->_qtdeSeries <= 1 && $this->_exibirValores == true) {
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), $this->_tituloDados);
}
// Draw the limit graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 100);
// Finish the graph
$Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 8);
$Test->drawLegend(72 * $this->_larguraGrafico / 100, 50, $DataSet->GetDataDescription(), 255, 249, 223, 15, 15, 15);
$Test->setFontProperties(CAMINHO_PCHART_FONT . "/tahoma.ttf", 14);
$Test->drawTitle($this->_larguraGrafico / 2 - 20, 30, $this->_tituloGrafico, $this->_corLabels["r"], $this->_corLabels["g"], $this->_corLabels["b"]);
$Test->Stroke();
}
示例15: pChartBarGrafMonthes
/**
* Гистограмма по месяцам
* @param array $par1
* @param array $par2
* @param array $par3
*/
public function pChartBarGrafMonthes($par1, $par2 = NULL, $par3 = NULL)
{
require_once Yii::getAlias('@app') . '/pChart/pChart/pData.class';
require_once Yii::getAlias('@app') . '/pChart/pChart/pChart.class';
$DataSet = new \pData();
$DataSet->AddPoint([$par1["jan"], $par1["feb"], $par1["mar"], $par1["apr"], $par1["may"], $par1["jun"], $par1["jul"], $par1["aug"], $par1["sep"], $par1["oct"], $par1["nov"], $par1["dec"]], "Serie1");
if ($par2) {
$DataSet->AddPoint([$par2["jan"], $par2["feb"], $par2["mar"], $par2["apr"], $par2["may"], $par2["jun"], $par2["jul"], $par2["aug"], $par2["sep"], $par2["oct"], $par2["nov"], $par2["dec"]], "Serie2");
}
if ($par3) {
$DataSet->AddPoint([$par3["jan"], $par3["feb"], $par3["mar"], $par3["apr"], $par3["may"], $par3["jun"], $par3["jul"], $par3["aug"], $par3["sep"], $par3["oct"], $par3["nov"], $par3["dec"]], "Serie3");
}
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("2014", "Serie1");
if ($par2) {
$DataSet->SetSerieName("2015", "Serie2");
}
if ($par3) {
$DataSet->SetSerieName("March", "Serie3");
}
// Initialise the graph
$Test = new \pChart(340, 160);
$Test->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf'), 8);
$Test->setGraphArea(35, 20, 320, 140);
$Test->drawFilledRoundedRectangle(7, 7, 693, 223, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 695, 225, 5, 230, 230, 230);
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf'), 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), TRUE);
// Finish the graph
$Test->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf'), 8);
$Test->drawLegend(50, 20, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf'), 10);
$Test->drawTitle(0, 22, $par1["name"] . " по месяцам", 50, 50, 50, 310);
$Test->Render(Url::to('@app/web/uploads/' . $par1["name"] . 'monthes.png'));
}