本文整理汇总了PHP中pChart::drawBackground方法的典型用法代码示例。如果您正苦于以下问题:PHP pChart::drawBackground方法的具体用法?PHP pChart::drawBackground怎么用?PHP pChart::drawBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pChart
的用法示例。
在下文中一共展示了pChart::drawBackground方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: drawPie
/**
* Draw pie chart
* @return unknown
*/
protected function drawPie()
{
// 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
$pie_x = intval(($this->w - 150) / 2);
// Pie witdh
$pie_y = intval(($this->h - 10) / 2);
// Pie heigth
$pie_r = intval($pie_x - 50);
// Pie radius
$title_w = $this->w - 200;
// Title width
$title_h = 50;
// Title height
$legend_w = $this->w - 120;
// Legend width
$legend_h = 50;
// Legend height
// chart styles
$flat = isset($this->p['flat']) ? $this->p['flat'] : 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)
// draw the pie chart
$this->chart->setFontProperties($this->font, 8);
// flat pie
if ($flat) {
$this->chart->drawFlatPieGraphWithShadow($this->data->GetData(), $this->data->GetDataDescription(), $pie_x, $pie_y, $pie_r, PIE_PERCENTAGE, 10);
// 3d pie
} else {
$this->chart->drawPieGraph($this->data->GetData(), $this->data->GetDataDescription(), $pie_x, $pie_y, $pie_r, PIE_PERCENTAGE, TRUE, 50, 20, 5, 1);
}
$this->chart->drawPieLegend($legend_w, $legend_h, $this->data->GetData(), $this->data->GetDataDescription(), 250, 250, 250);
// 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)
}
示例2: generateGraphImage
protected function generateGraphImage($finalData, $hourflag, $title = 'Sticky Charts', $x_axis_format = 'date')
{
$path = $this->config->item('csv_upload_path');
if (!empty($finalData['data'])) {
$DataSet = new pData();
$in = 0;
foreach ($finalData['data'] as $seriesData) {
$in++;
$seriesIndex = 'Serie' . $in;
$DataSet->AddPoint($seriesData['data'], $seriesIndex);
$DataSet->SetSerieName($seriesData['name'], $seriesIndex);
$DataSet->AddSerie($seriesIndex);
}
$xAxisArray = array();
$in++;
$seriesIndex = 'Serie' . $in;
$catCount = count($finalData['cat']);
if ($catCount <= 10) {
$DataSet->SetXAxisFormat($x_axis_format);
}
foreach ($finalData['cat'] as $catD) {
if ($catCount > 10) {
$xAxisArray[] = '';
} else {
$xAxisArray[] = strtotime($catD);
}
}
$DataSet->SetYAxisFormat("number");
$DataSet->AddPoint($xAxisArray, $seriesIndex);
$DataSet->SetAbsciseLabelSerie($seriesIndex);
$DataSet->SetYAxisName($finalData['y_title']);
$DataSet->SetXAxisName($finalData['x_title']);
// Initialise the graph
$Test = new pChart(985, 458);
$Test->drawBackground(247, 226, 180);
$Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 8);
$Test->setGraphArea(40, 30, 950, 400);
$Test->drawGraphArea(109, 110, 114, false);
$Test->drawGrid(4, false, 0, 0, 0, 50);
$Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 6);
// Draw the line graph
if ($title == 'Violation Report') {
//!$hourflag &&
$sCount = count($finalData['data']);
if ($sCount > 0) {
for ($m = 0; $m < $sCount; $m++) {
$color = Color_handler::get_next($m);
$rgb = $color->get_rgb();
$Test->setColorPalette($m, $rgb['r'], $rgb['g'], $rgb['b']);
}
}
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 0, 0, 0, TRUE, 0, 0, TRUE);
$Test->drawBarGraph($DataSet->GetData(), $DataSet->GetDataDescription());
} else {
$sCount = count($finalData['data']);
if ($sCount > 0) {
for ($m = 0; $m < $sCount; $m++) {
$color = Color_handler::get_next($m % 3);
$rgb = $color->get_rgb();
$Test->setColorPalette($m, $rgb['r'], $rgb['g'], $rgb['b']);
}
}
$Test->setLineStyle(2);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 0, 0, 0, TRUE, 0, 2);
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 2);
}
// Finish the graph
$Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 8);
$Test->setFontProperties(APPPATH . '3rdparty/pchart/Fonts/tahoma.ttf', 10);
$imgName = uniqid('graph_') . '.png';
$Test->Render($path . $imgName);
return upload_to_amazon_graphImage($imgName, $path);
}
}
示例3: elseif
//---------------------------- pict1c
} elseif ($objtype == "pict1c") {
// Settings
$wid = 60;
$hei = 60;
// light/black
if ($black == 1) {
$cbg = 0;
} else {
$cbg = 255;
}
// Object + GraphArea
$Test = new pChart($wid, $hei);
$Test->setGraphArea(0, 0, $wid, $hei);
// Background
$Test->drawBackground($cbg, $cbg, $cbg);
// Draw body
$Test->drawFilledRoundedRectangle(0, 0, 60, 60, 8, $caR, $caG, $caB);
// body
// Draw label
$Test->setFontProperties("./pChart/Fonts/pictogramz.ttf", 44);
$Test->drawTextBox(10, 20, 50, 40, "O", 0, 250, 250, 250, ALIGN_CENTER, FALSE, -1, -1, -1, 100);
// end of pict1c
//---------------------------- Error mess object
} else {
}
// end of ($objtype == "...")
//---------------------------- Final
Header("Content-type:image/png");
imagepng($Test->Picture);
$db->Disconnect();
示例4: date
array_unshift($skill_change, $row['skill_change']);
if ($i == 1 || $i == round($rowcnt / 2) || $i == $rowcnt) {
array_unshift($date, date("M-j", $row['ts']));
$last_time = $row['ts'];
} else {
array_unshift($date, '');
}
}
$cache_image = IMAGE_PATH . "/progress/trend_{$player}_{$last_time}.png";
if (file_exists($cache_image)) {
header('Content-type: image/png');
readfile($cache_image);
exit;
}
$Chart = new pChart(400, 200);
$Chart->drawBackground($bg_color['red'], $bg_color['green'], $bg_color['blue']);
$Chart->setGraphArea(40, 28, 339, 174);
$Chart->drawGraphAreaGradient(40, 40, 40, -50);
if (count($date) < 2) {
$Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 11);
$Chart->drawTextBox(100, 90, 180, 110, "Not Enough Session Data", 0, 0, 0, 0, ALIGN_LEFT, FALSE, 255, 255, 255, 0);
} else {
$DataSet = new pData();
$DataSet->AddPoint($skill, 'SerieSkill');
$DataSet->AddPoint($skill_change, 'SerieSession');
$DataSet->AddPoint($date, 'SerieDate');
$DataSet->AddSerie('SerieSkill');
$DataSet->SetAbsciseLabelSerie('SerieDate');
$DataSet->SetSerieName('Skill', 'SerieSkill');
$DataSet->SetSerieName('Session', 'SerieSession');
$Chart->setFontProperties(IMAGE_PATH . '/sig/font/DejaVuSans.ttf', 7);
示例5: createChart
function createChart(&$info, &$cfg)
{
$backgndColor = array('R' => 255, 'G' => 255, 'B' => 254);
$chartCfg = new stdClass();
$chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600;
$chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50;
$chartCfg->border = new stdClass();
$chartCfg->border->width = 1;
$chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->graphArea = new stdClass();
$chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221);
$chartCfg->graphArea->beginX = property_exists($cfg, 'beginX') ? $cfg->beginX : 40;
$chartCfg->graphArea->beginY = property_exists($cfg, 'beginY') ? $cfg->beginY : 100;
$chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX;
$chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY;
$chartCfg->scale = new stdClass();
// 20100914 - franciscom
// After reading documentation
// drawScale
// Today there is four way of computing scales :
//
// - Getting Max & Min values per serie : ScaleMode = SCALE_NORMAL
// - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_START0
// - Getting the series cumulative Max & Min values : ScaleMode = SCALE_ADDALL
// - Like the previous one but setting the min value to 0 : ScaleMode = SCALE_ADDALLSTART0
//
// This will depends on the kind of graph you are drawing, today only the stacked bar chart
// can use the SCALE_ADDALL mode.
// Drawing graphs were you want to fix the min value to 0 you must use the SCALE_START0 option.
//
$chartCfg->scale->mode = SCALE_ADDALLSTART0;
$chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->scale->drawTicks = TRUE;
$chartCfg->scale->angle = $cfg->scale->legendXAngle;
$chartCfg->scale->decimals = 1;
$chartCfg->scale->withMargin = TRUE;
$chartCfg->legend = new stdClass();
$chartCfg->legend->X = $chartCfg->XSize - 80;
$chartCfg->legend->Y = 15;
$chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240);
$chartCfg->title = new stdClass();
$chartCfg->title->value = $cfg->chartTitle;
$chartCfg->title->X = 2 * $chartCfg->graphArea->beginX;
$chartCfg->title->Y = $chartCfg->legend->Y;
$chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255);
$Test = new pChart($chartCfg->XSize, $chartCfg->YSize);
$Test->reportWarnings("GD");
$Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']);
$Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']);
$Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY);
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
if ($info->canDraw) {
$DataSet = new pData();
foreach ($info->chart_data as $key => $values) {
$id = $key + 1;
$DataSet->AddPoint($values, "Serie{$id}");
$DataSet->SetSerieName($info->series_label[$key], "Serie{$id}");
}
$DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName);
$DataSet->AddAllSeries();
$DataSet->RemoveSerie($info->xAxis->serieName);
$DataSet->SetAbsciseLabelSerie($info->xAxis->serieName);
$chartData = $DataSet->GetData();
$chartLegend = $DataSet->GetDataDescription();
foreach ($info->series_color as $key => $hexrgb) {
$rgb = str_split($hexrgb, 2);
$Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions);
$Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin);
$Test->drawStackedBarGraph($chartData, $chartLegend, 70);
// Draw the legend
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']);
$Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']);
} else {
$chartCfg->title->value .= '/' . lang_get('no_data_available');
}
$Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']);
$Test->Stroke();
}
示例6: pChart
/**
* Рисуем графики с помощью библиотеки pChart
* @param object $model
* @param integer $max_id
* @param integer $x
* @param integer $y
* @param integer $y2
*/
public function pChart($model, $max_id, $x, $y, $y2 = NULL)
{
/* Include the pData class */
require_once Yii::getAlias('@app') . '/pChart/pChart/pData.class';
require_once Yii::getAlias('@app') . '/pChart/pChart/pCache.class';
require_once Yii::getAlias('@app') . '/pChart/pChart/pChart.class';
//создаем объект данных
$myData = new \pData();
if (!$y2) {
$datas = $model::find()->select([$x, $y])->andWhere("id > {$max_id} - 7")->all();
} else {
$datas = $model::find()->select([$x, $y, $y2])->andWhere("id > {$max_id} - 7")->all();
}
foreach ($datas as $key => $data) {
$myData->AddPoint($data->{$x}, $x);
$myData->AddPoint($data->{$y}, $y);
if ($y2 != NULL) {
$myData->AddPoint($data->{$y2}, $y2);
}
}
//устанавливаем точки с датами
//на ось абсцисс
$myData->SetAbsciseLabelSerie($x);
//помечаем данные как предназначеные для
//отображения
$myData->AddSerie($y);
$myData->AddSerie($y2);
//устанавливаем имена
$myData->SetSerieName($y);
$myData->SetSerieName($y2);
//создаем график шириной и высотой px
$graph = new \pChart(340, 130);
//устанавливаем шрифт и размер шрифта
$graph->setFontProperties(Yii::getAlias('@app') . '/pChart/Fonts/tahoma.ttf', true, 8);
//координаты левой верхней вершины и правой нижней
//вершины графика
$graph->setGraphArea(35, 20, 330, 110);
//добавляем бэкграунд
$graph->drawBackground(255, 0, 0);
$graph->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
//рисуем заполненный четырехугольник
$graph->drawFilledRoundedRectangle(7, 7, 993, 493, 5, 240, 240, 240);
//теперь незаполненный для эффекта тени
$graph->drawRoundedRectangle(5, 5, 995, 495, 5, 0, 200, 0);
//прорисовываем фон графика
$graph->drawGraphArea(200, 255, 255, TRUE);
//устанавливаем данные для графиков
$graph->drawScale($myData->GetData(), $myData->GetDataDescription(), SCALE_NORMAL, 10, 10, 10, true, 0, 2);
//рисуем сетку для графика
$graph->drawGrid(4, TRUE, 200, 230, 230, 50);
//прорисовываем линейные графики
$graph->drawLineGraph($myData->GetData(), $myData->GetDataDescription());
// рисуем точки на графике
$graph->drawPlotGraph($myData->GetData(), $myData->GetDataDescription(), 3, 2, 255, 255, 255);
// пишем в подвале некоторый текст
$graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
$graph->drawTextBox(805, 470, 990, 480, "{$x}", 0, 150, 150, 150, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
$graph->drawTextBox(10, 470, 140, 480, "{$y}", 0, 250, 250, 250, ALIGN_CENTER, TRUE, -1, -1, -1, 30);
//ложим легенду
$graph->drawLegend(90, 35, $myData->GetDataDescription(), 255, 255, 255);
//Пишем заголовок
$graph->setFontProperties(Url::to('@app/pChart/Fonts/tahoma.ttf', true), 8);
$graph->drawTitle(480, 22, "График", 50, 50, 50, -1, -1, true);
//выводим в браузер
$graph->Render(Url::to('@app/web/uploads/' . $y . '.png'));
}
示例7: createChart
function createChart(&$info, &$cfg)
{
$backgndColor = array('R' => 255, 'G' => 255, 'B' => 254);
$chartCfg = new stdClass();
$chartCfg->XSize = $info->canDraw ? $cfg->XSize : 600;
$chartCfg->YSize = $info->canDraw ? $cfg->YSize : 50;
$chartCfg->border = new stdClass();
$chartCfg->border->width = 1;
$chartCfg->border->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->graphArea = new stdClass();
$chartCfg->graphArea->color = array('R' => 213, 'G' => 217, 'B' => 221);
$chartCfg->graphArea->beginX = 40;
$chartCfg->graphArea->beginY = 40;
$chartCfg->graphArea->endX = $chartCfg->XSize - $chartCfg->graphArea->beginX;
$chartCfg->graphArea->endY = $chartCfg->YSize - $chartCfg->graphArea->beginY;
$chartCfg->scale = new stdClass();
$chartCfg->scale->mode = SCALE_ADDALL;
$chartCfg->scale->color = array('R' => 0, 'G' => 0, 'B' => 0);
$chartCfg->scale->drawTicks = TRUE;
$chartCfg->scale->angle = $cfg->scale->legendXAngle;
$chartCfg->scale->decimals = 1;
$chartCfg->scale->withMargin = TRUE;
$chartCfg->legend = new stdClass();
$chartCfg->legend->X = $chartCfg->XSize - 80;
$chartCfg->legend->Y = 15;
$chartCfg->legend->color = array('R' => 236, 'G' => 238, 'B' => 240);
$chartCfg->title = new stdClass();
$chartCfg->title->value = $cfg->chartTitle;
$chartCfg->title->X = 2 * $chartCfg->graphArea->beginX;
$chartCfg->title->Y = $chartCfg->legend->Y;
$chartCfg->title->color = array('R' => 0, 'G' => 0, 'B' => 255);
$Test = new pChart($chartCfg->XSize, $chartCfg->YSize);
$Test->drawBackground($backgndColor['R'], $backgndColor['G'], $backgndColor['B']);
$Test->drawGraphArea($chartCfg->graphArea->color['R'], $chartCfg->graphArea->color['G'], $chartCfg->graphArea->color['B']);
$Test->setGraphArea($chartCfg->graphArea->beginX, $chartCfg->graphArea->beginY, $chartCfg->graphArea->endX, $chartCfg->graphArea->endY);
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
if ($info->canDraw) {
$DataSet = new pData();
foreach ($info->chart_data as $key => $values) {
$id = $key + 1;
$DataSet->AddPoint($values, "Serie{$id}");
$DataSet->SetSerieName($info->series_label[$key], "Serie{$id}");
}
$DataSet->AddPoint($info->xAxis->values, $info->xAxis->serieName);
$DataSet->AddAllSeries();
$DataSet->RemoveSerie($info->xAxis->serieName);
$DataSet->SetAbsciseLabelSerie($info->xAxis->serieName);
$chartData = $DataSet->GetData();
$chartLegend = $DataSet->GetDataDescription();
foreach ($info->series_color as $key => $hexrgb) {
$rgb = str_split($hexrgb, 2);
$Test->setColorPalette($key, hexdec($rgb[0]), hexdec($rgb[1]), hexdec($rgb[2]));
}
// $Test->setFixedScale($info->scale->minY,$info->scale->maxY,$info->scale->divisions);
$Test->drawScale($chartData, $chartLegend, $chartCfg->scale->mode, $chartCfg->scale->color['R'], $chartCfg->scale->color['G'], $chartCfg->scale->color['B'], $chartCfg->scale->drawTicks, $chartCfg->scale->angle, $chartCfg->scale->decimals, $chartCfg->scale->withMargin);
$Test->drawStackedBarGraph($chartData, $chartLegend, 70);
// Draw the legend
$Test->setFontProperties(config_get('charts_font_path'), config_get('charts_font_size'));
$Test->drawLegend($chartCfg->legend->X, $chartCfg->legend->Y, $chartLegend, $chartCfg->legend->color['R'], $chartCfg->legend->color['G'], $chartCfg->legend->color['B']);
$Test->addBorder($chartCfg->border->width, $chartCfg->border->color['R'], $chartCfg->border->color['G'], $chartCfg->border->color['B']);
} else {
$chartCfg->title->value .= '/' . lang_get('no_data_available');
}
$Test->drawTitle($chartCfg->title->X, $chartCfg->title->Y, $chartCfg->title->value, $chartCfg->title->color['R'], $chartCfg->title->color['G'], $chartCfg->title->color['B']);
$Test->Stroke();
}