本文整理汇总了PHP中pData::GetData方法的典型用法代码示例。如果您正苦于以下问题:PHP pData::GetData方法的具体用法?PHP pData::GetData怎么用?PHP pData::GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pData
的用法示例。
在下文中一共展示了pData::GetData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: writeData
function writeData($data, $graph)
{
if ($data != "") {
echo "Plottong " . $graph . "\n";
$dataset1 = array();
$dataset2 = array();
foreach ($data as $key => $value) {
array_push($dataset1, $key);
array_push($dataset2, $value);
}
$DataSet = new pData();
$DataSet->AddPoint($dataset2, "Serie1");
$DataSet->AddPoint($dataset1, "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
$Test = new pChart(380, 200);
$Test->drawFilledRoundedRectangle(7, 7, 373, 193, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, 375, 195, 5, 230, 230, 230);
// Draw the pie chart
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawPieGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 150, 90, 110, TRUE, TRUE, 50, 20, 5);
$Test->drawPieLegend(310, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), 250, 250, 250);
$Test->Render("{$graph}-pie.png");
}
}
示例2: 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)
}
示例3: pData
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(1, 4, 3, 2, 3, 3, 2, 1, 0, 7, 4, 3, 2, 3, 3, 5, 1, 0, 7), "Serie1");
$DataSet->AddPoint(array(1, 4, 2, 6, 2, 3, 0, 1, 5, 1, 2, 4, 5, 2, 1, 0, 6, 4, 2), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(50, 30, 585, 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);
$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 cubic curve graph
$Test->drawFilledCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 50);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(600, 30, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(50, 22, "Example 7", 50, 50, 50, 585);
$Test->Render("example7.png");
示例4: draw
/**
* Рисует график по переданным данным
*
* @param array $points
* @return string путь к файлу графика
*/
private function draw(array $points)
{
$errLevel = error_reporting();
error_reporting(0);
$newsList = $this->dataProvider->getNewsList();
$classLoader = new CPChart();
$DataSet = new pData();
foreach ($points as $news_id => $set) {
$DataSet->AddPoint($set, "news" . $news_id);
$DataSet->SetSerieName($newsList[$news_id], "news" . $news_id);
}
$DataSet->AddAllSeries();
$DataSet->AddPoint(array_values($this->dataProvider->getDates()), "dates");
$DataSet->SetAbsciseLabelSerie('dates');
// Initialise the graph
$chart = new pChart(700, 250);
$chart->setFontProperties($classLoader->Cpath("Fonts/tahoma.ttf"), 7);
$chart->setGraphArea(60, 30, 570, 200);
$chart->drawFilledRoundedRectangle(7, 7, 693, 253, 5, 240, 240, 240);
$chart->drawRoundedRectangle(5, 5, 695, 255, 5, 230, 230, 230);
$chart->drawGraphArea(255, 255, 255, true);
$data = $DataSet->GetData();
if (!empty($data)) {
$chart->drawScale($data, $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, true, 45, 2, true, 3);
$chart->drawGrid(4, true, 230, 230, 230, 50);
$chart->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
// Finish the graph
$chart->setFontProperties($classLoader->Cpath("Fonts/tahoma.ttf"), 8);
$chart->drawLegend(590, 20, $DataSet->GetDataDescription(), 255, 255, 255);
}
// Restore reporting level
error_reporting($errLevel);
return $this->render($chart, $points);
}
示例5: _showGraph_pChart
public function _showGraph_pChart($buscarBarra)
{
// Dataset definition
$DataSet = new pData();
if ($buscarBarra == "semana") {
$semana = array("1era Semana", "2da Semana", "3era Semana", "4ta Semana");
$cantidadSemanal = array(2, 4, 5, 6);
$DataSet->AddPoint($semana, "Serie1");
$DataSet->AddPoint($cantidadSemanal, "Serie2");
// Initialise the graph
define("WIDTH", 500);
define("HEIGHT", 500);
$Test = new pChart(WIDTH, HEIGHT);
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30);
$Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230);
} elseif ($buscarBarra == "mes") {
$mensual = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Setiembre", "Octubre");
$cantidadMensual = array(4, 6, 11, 23, 9, 2, 30, 20, 12, 45);
$DataSet->AddPoint($mensual, "Serie1");
$DataSet->AddPoint($cantidadMensual, "Serie2");
// Initialise the graph
define("WIDTH", 700);
define("HEIGHT", 500);
$Test = new pChart(WIDTH, HEIGHT);
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->setGraphArea(40, 30, WIDTH - 30, HEIGHT - 30);
$Test->drawFilledRoundedRectangle(7, 7, WIDTH - 7, HEIGHT - 7, 5, 240, 240, 240);
$Test->drawRoundedRectangle(5, 5, WIDTH - 5, HEIGHT - 5, 5, 230, 230, 230);
$Test->setColorPalette(0, 224, 100, 46);
}
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie1");
$DataSet->SetSerieName("Productos Comprados", "Serie2");
// Initialise the graph
$Test->drawGraphArea(255, 255, 255, TRUE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 2, TRUE);
$Test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$Test->setFontProperties("../font/arial.ttf", 6);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the bar graph
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Set labels
$Test->setFontProperties("../font/arial.ttf", 7);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie2");
// Finish the graph
$Test->setFontProperties("../font/arial.ttf", 8);
$Test->drawLegend(WIDTH / 5, 25, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("../font/arial.ttf", 10);
$Test->drawTitle(WIDTH - 200, 22, "Estadistica de Barra de Grafico", 50, 50, 50, 185);
$Test->Render("../img/imagenBarra_pChart.png");
}
示例6: generateGraph
function generateGraph($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to)
{
$myarr = graphTests($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to);
$myarr1 = graphErrs($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to);
$myarr2 = graphLbls($year, $month, $quarter, $biAnn, $dev, $patna, $duration, $from, $to);
// Standard inclusions
include "pChart/pChart/pData.class";
include "pChart/pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($myarr, "Serie1");
$DataSet->AddPoint($myarr1, "Serie2");
$DataSet->AddPoint($myarr2, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("Test Resulting trends", "Serie1");
$DataSet->SetSerieName("Errors in tests", "Serie2");
$DataSet->SetYAxisName("Tests");
// $DataSet->SetYAxisFormat("time");
$DataSet->SetXAxisName("months");
// Initialise the graph
$Test = new pChart(750, 330);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(85, 30, 650, 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);
$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 line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(90, 35, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "Test Summary", 50, 50, 50, 585);
$Test->Render("mpdf.png");
}
示例7: pChart
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->setGraphArea(120, 20, 675, 190);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Draw the title
$Title = " Average Temperatures during\r\n the first months of 2008 ";
$Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
// Draw the legend
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(610, 10, $DataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
// Render the picture
$Test->addBorder(2);
$Test->Render("example23.png");
示例8: line
function line($valores, $titulo, $label = array())
{
$nombre = tempnam('/tmp', 'g') . '.png';
$DataSet = new pData();
$ind = 1;
$DataSet->AddPoint($valores, 'Serie' . $ind);
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName($titulo, 'Serie' . $ind);
if (count($label) > 0) {
$ID = 0;
foreach ($label as $val) {
$DataSet->Data[$ID]["Name"] = $val;
$ID++;
}
}
$Test = new pChart(300, 200);
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8);
$Test->setGraphArea(70, 30, 280, 170);
$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->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->setFontProperties(APPPATH . 'libraries/pChart/Fonts/tahoma.ttf', 8);
$Test->drawLegend(200, 9, $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;
}
示例9: index
function index()
{
$this->load->model('charge_model');
$revenue = $this->charge_model->GetRevenueByDay($this->user->Get('client_id'));
$data = array();
if ($this->config->item('show_dashboard_chart') !== 'no' and !empty($revenue) and count($revenue) > 1) {
$series = array();
foreach ($revenue as $day) {
$series[] = $day['revenue'];
$series2[] = date("M j", strtotime($day['day']));
}
include APPPATH . 'libraries/pchart/pData.class';
include APPPATH . 'libraries/pchart/pChart.class';
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($series, "Revenue");
$DataSet->AddPoint($series2, "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
$DataSet->RemoveSerie("Serie2");
$DataSet->SetXAxisName('Date');
$DataSet->SetYAxisName('Revenue');
//$DataSet->SetXAxisFormat('date');
// Initialise the graph
$Test = new pChart(1000, 260);
$Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 10);
$Test->setGraphArea(90, 30, 960, 200);
$Test->drawGraphArea(252, 252, 252);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2);
$Test->drawGrid(4, TRUE, 230, 230, 230, 255);
// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Finish the graph
$Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 8);
$Test->drawLegend(45, 35, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties(APPPATH . 'libraries/pchart/Arial.ttf', 10);
//$Test->drawTitle(60,22,"Last 30 Days",50,50,50,585);
$Test->Render(BASEPATH . '../writeable/rev_chart_' . $this->user->Get('client_id') . '.png');
} else {
$data['no_chart'] = 'true';
}
// get log
$this->load->model('log_model');
$log = $this->log_model->GetClientLog($this->user->Get('client_id'));
$data['log'] = $log;
$this->load->view(branded_view('cp/dashboard'), $data);
}
示例10: 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;
}
示例11: generateGraph
/**
* Create graph (a .png file)
*
* @param string $file
*/
public function generateGraph($file)
{
$patientValues = Storage::getInstance()->getPatientsData($file);
/*
* pGraph work
*/
$dataSet = new pData();
if (!empty($patientValues)) {
$dataSet->AddPoint(array_keys($patientValues[$file]), 'label');
$dataSet->SetAbsciseLabelSerie('label');
$serie1 = array_values($patientValues[$file]);
$average = round(array_sum($serie1) / count($serie1), 2);
$dataSet->AddPoint($serie1, "Serie1");
$dataSet->AddSerie("Serie1");
// Initialise the graph
$graph = new MyHorBar(450, 600);
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 8);
$graph->setGraphArea(120, 60, 410, 550);
$graph->drawFilledRoundedRectangle(7, 7, 443, 593, 5, 240, 240, 240);
$graph->drawRoundedRectangle(5, 5, 443, 595, 5, 230, 230, 230);
$graph->drawGraphArea(255, 255, 255, true);
$graph->drawHorScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, true, 0, 2, true);
$graph->drawHorGrid(10, true, 230, 230, 230, 50);
// Draw the 0 line
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 6);
$graph->drawTreshold($average, 143, 55, 72, true, false, 2, null, 90);
// Draw the bar graph
$graph->drawHorBarGraph($dataSet->GetData(), $dataSet->GetDataDescription(), false);
// Finish the graph
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10);
$graph->drawLegend(15, 15, $dataSet->GetDataDescription(), 255, 255, 255);
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10);
$graph->drawTitle(170, 27, $file, 50, 50, 50, -1);
} else {
$graph = new pChart(450, 150);
$graph->setGraphArea(120, 60, 410, 100);
$graph->drawFilledRoundedRectangle(7, 7, 443, 143, 5, 240, 240, 240);
$graph->drawRoundedRectangle(5, 5, 443, 145, 5, 230, 230, 230);
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 10);
$graph->drawTitle(170, 27, $file, 50, 50, 50, -1);
$graph->setFontProperties($this->fontsPath . '/tahoma.ttf', 36);
$graph->drawTitle(125, 90, 'No data!', 245, 50, 50, -1);
}
$graph->Render(WWW_DIR . '/images/graphs/' . $file . '.png');
}
示例12: PieChart
/**
* Create a PieChart
*
* @param array $data associative array contianing label and values
*/
protected function PieChart($data)
{
$DataSet = new pData();
$Canvas = new GDCanvas(400, 200, false);
$Chart = new PieChart(400, 200, $Canvas);
$Chart->setFontProperties(dirname(__FILE__) . '/pchart/Fonts/DroidSans.ttf', 8);
$DataSet->AddPoints(array_values($data), 'Serie1');
$DataSet->AddPoints(array_keys($data), 'Serie2');
$DataSet->AddAllSeries();
$DataSet->SetAbscissaLabelSeries("Serie2");
$Chart->drawBasicPieGraph($DataSet->getData(), $DataSet->GetDataDescription(), 120, 100, 60, PIE_PERCENTAGE);
$Chart->drawPieLegend(230, 15, $DataSet->GetData(), $DataSet->GetDataDescription(), new Color(250));
header('Content-Type: image/png');
$Chart->Render('');
}
示例13: pChart
$DataSet->AddPoint(array("Jan", "Feb", "Mar", "Apr", "May", "Jun"), "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("Company A", "Serie1");
$DataSet->SetSerieName("Company B", "Serie2");
$DataSet->SetYAxisName("Product sales");
$DataSet->SetYAxisUnit("k");
$DataSet->SetSerieSymbol("Serie1", "Sample/Point_Asterisk.gif");
$DataSet->SetSerieSymbol("Serie2", "Sample/Point_Cd.gif");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(65, 30, 650, 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 title
$Test->setFontProperties("Fonts/pf_arma_five.ttf", 6);
$Title = "Comparative product sales for company A & B ";
$Test->drawTextBox(65, 30, 650, 45, $Title, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Draw the legend
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(80, 60, $DataSet->GetDataDescription(), 255, 255, 255);
// Render the chart
$Test->Render("example22.png");
示例14: pData
include "../lib/pChart.php";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(1, 4, -3, 2, -3, 3, 2, 1, 0, 7, 4), "Serie1");
$DataSet->AddPoint(array(3, 3, -4, 1, -2, 2, 1, 0, -1, 6, 3), "Serie2");
$DataSet->AddPoint(array(4, 1, 2, -1, -4, -2, 3, 2, 1, 2, 2), "Serie3");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetSerieName("March", "Serie3");
// 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_ADDALL, 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->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 100);
// 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, "Example 20", 50, 50, 50, 585);
$Test->Render("example20.png");
示例15: generate_statistics
//.........这里部分代码省略.........
else
{
$gheight=320;
$fontsize=8;
$legendtop=0.07;
$setcentrey=0.5;
}
// Create bar chart for Multiple choice
if ($qtype == "M" || $qtype == "P")
{
//new bar chart using data from array $grawdata which contains percentage
$DataSet = new pData;
$counter=0;
$maxyvalue=0;
foreach ($grawdata as $datapoint)
{
$DataSet->AddPoint(array($datapoint),"Serie$counter");
$DataSet->AddSerie("Serie$counter");
$counter++;
if ($datapoint>$maxyvalue) $maxyvalue=$datapoint;
}
if ($maxyvalue<10) {++$maxyvalue;}
$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);