本文整理汇总了PHP中pData::SetXAxisName方法的典型用法代码示例。如果您正苦于以下问题:PHP pData::SetXAxisName方法的具体用法?PHP pData::SetXAxisName怎么用?PHP pData::SetXAxisName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pData
的用法示例。
在下文中一共展示了pData::SetXAxisName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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");
}
示例2: make
public function make($working_path)
{
// This will import the file http://my.domain.com/myData.csv using each column as a serie
if (!$this->plot->valid()) {
$file = $this->plot->name();
$error = $this->plot->error();
$this->log($working_path, "Plot file {$file} is invalid: {$error}");
return 1;
}
$data = new pData();
$columns = array();
$all_columns = array();
$x_column = $this->plot->property('x_column') - 1;
if ($x_column === NULL) {
$x_column = 0;
}
$data_file = $this->plot->data_property('name');
$deliminator = $this->plot->data_property('deliminator');
$has_header = $this->plot->data_property('header') == 'yes';
foreach ($this->plot->columns() as $column => $name) {
if ($column != $x_column + 1) {
$columns[] = $column - 1;
}
$all_columns[] = $column - 1;
}
$data->ImportFromCSV($working_path . $data_file, $deliminator, $all_columns, $has_header);
foreach ($columns as $column) {
$name = $this->plot->column($column + 1);
$data->AddSerie('Serie' . $column);
$data->SetSerieName($name, "Serie" . $column);
}
$max_col = -1;
$max_val = NULL;
foreach ($data->GetData() as $record) {
foreach ($columns as $column) {
$point = $record['Serie' . $column];
if ($max_val === NULL || $point > $max_val) {
$max_val = $point;
$max_col = $column;
}
}
}
$x_label = $this->plot->axis_property('x', 'label');
if ($x_label) {
$data->SetXAxisName($x_label);
} else {
$data->SetXAxisName($this->plot->column($x_column + 1));
}
$x_unit = $this->plot->axis_property('x', 'unit');
if ($x_unit) {
$data->SetXAxisUnit($x_unit);
}
$y_label = $this->plot->axis_property('y', 'label');
reset($columns);
if ($y_label) {
$data->SetYAxisName($y_label);
} else {
$data->SetYAxisName($this->plot->column(current($columns) + 1));
}
$y_unit = $this->plot->axis_property('y', 'unit');
if ($y_unit) {
$data->SetyAxisUnit($y_unit);
}
$width = $this->plot->property('width');
if (!$width) {
$width = 640;
}
$height = $this->plot->property('height');
if (!$height) {
$height = 480;
}
$plot = new pChart($width, $height);
$font_name = $this->plot->property('font-name');
if (!$font_name) {
$font_name = 'tahoma.ttf';
}
$font_name = 'lib/plugins/projects/pchart/fonts/' . $font_name;
$font_size = $this->plot->property('font_size');
if (!$font_size) {
$font_size = 12;
}
$plot->setFontProperties($font_name, $font_size);
$h = $font_size + 10;
$left_margin = 0;
foreach ($data->GetData() as $record) {
$position = imageftbbox($font_size, 0, $font_name, $record['Serie' . $max_col]);
$text_width = $position[2] - $position[0];
if ($text_width > $left_margin) {
$left_margin = $text_width;
}
}
$left_margin += 2 * $h;
$plot->setGraphArea($left_margin, 2 * $h, $width - $h, $height - 2 * $h);
$background = $this->plot->property('background');
if (!$background) {
$background = array('R' => 255, 'G' => 255, 'B' => 255);
} else {
$background = html_color_to_RGB($background);
}
$plot->drawGraphArea($background['R'], $background['G'], $background['B']);
//.........这里部分代码省略.........
示例3: 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);
}
示例4: _getDataObj
private function _getDataObj()
{
//Setup the pData - Object (pChart Framework at http://pchart.sourceforge.net/) to feed the graph
$data = new pData();
$data->AddPoint($this->ordinateSerie, "ORDINATE");
$data->AddSerie("ORDINATE");
$data->SetYAxisName($this->ordinateName);
$data->SetSerieName($this->metricTitle, "ORDINATE");
$data->AddPoint($this->abscissaSerie, "ABSCISSA");
$data->SetAbsciseLabelSerie("ABSCISSA");
$data->SetXAxisName($this->abscissaName);
return $data;
}
示例5: 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");
}
示例6: 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;
}
示例7: array
require 'DB.php';
require 'graphfunc.php';
$name = $_GET['name'];
preg_replace("/[^A-Za-z0-9 ]/", '', $name);
$db = DB::connect("mysql://roland:68volvo@localhost/games");
$sql = "select games.date, elo.elo from elo inner join games on games.gameid = elo.gameid where elo.name = '{$name}' order by elo.eloid asc";
$q = $db->query($sql);
$date = array();
$val = array();
$year = 0;
while ($q->fetchInto($row)) {
if ($year != toYStr($row[0])) {
$date[] = toYStr($row[0]);
} else {
$date[] = "";
}
$year = toYStr($row[0]);
$val[] = $row[1];
}
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($val, "Serie1");
$DataSet->AddPoint($date, "Serie2");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie2");
$DataSet->SetYAxisName("ELO");
$DataSet->SetXAxisName("Game");
drawChart($title, $DataSet, "line", array(array(255, 0, 0)));
示例8: pData
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($myarr, "Serie1");
$DataSet->AddPoint($myarr1, "Serie2");
$DataSet->AddPoint(array(Jan, Feb, Mar, Apr, May), "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);
示例9: 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);
}
}
示例10: 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);
//.........这里部分代码省略.........
示例11: array
/**
* Generates a big graph with the number of best results
* @param array
*/
static function generate_exercise_result_graph($attempts)
{
require_once api_get_path(LIBRARY_PATH).'pchart/pData.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pChart.class.php';
require_once api_get_path(LIBRARY_PATH).'pchart/pCache.class.php';
$exercise_title = strip_tags($attempts['title']);
$attempts = $attempts['data'];
$my_exercise_result_array = $exercise_result = array();
if (empty($attempts)) {
return null;
}
foreach ($attempts as $attempt) {
if (api_get_user_id() == $attempt['exe_user_id']) {
if ($attempt['exe_weighting'] != 0 ) {
$my_exercise_result_array[]= $attempt['exe_result']/$attempt['exe_weighting'];
}
} else {
if ($attempt['exe_weighting'] != 0 ) {
$exercise_result[]= $attempt['exe_result']/$attempt['exe_weighting'];
}
}
}
//Getting best result
rsort($my_exercise_result_array);
$my_exercise_result = 0;
if (isset($my_exercise_result_array[0])) {
$my_exercise_result = $my_exercise_result_array[0] *100;
}
$max = 100;
$pieces = 5 ;
$part = round($max / $pieces);
$x_axis = array();
$final_array = array();
$my_final_array = array();
for ($i=1; $i <=$pieces; $i++) {
$sum = 1;
if ($i == 1) {
$sum = 0;
}
$min = ($i-1)*$part + $sum;
$max = ($i)*$part;
$x_axis[]= $min." - ".$max;
$count = 0;
foreach($exercise_result as $result) {
$percentage = $result*100;
//echo $percentage.' - '.$min.' - '.$max."<br />";
if ($percentage >= $min && $percentage <= $max) {
//echo ' is > ';
$count++;
}
}
//echo '<br />';
$final_array[]= $count;
if ($my_exercise_result >= $min && $my_exercise_result <= $max) {
$my_final_array[] = 1;
} else {
$my_final_array[] = 0;
}
}
//Fix to remove the data of the user with my data
for($i = 0; $i<=count($my_final_array); $i++) {
if (!empty($my_final_array[$i])) {
$my_final_array[$i] = $final_array[$i] + 1; //Add my result
$final_array[$i] = 0;
}
}
$cache = new pCache();
// Dataset definition
$data_set = new pData();
$data_set->AddPoint($final_array,"Serie1");
$data_set->AddPoint($my_final_array,"Serie2");
$data_set->AddPoint($x_axis,"Serie3");
$data_set->AddAllSeries();
$data_set->SetAbsciseLabelSerie('Serie3');
$data_set->SetSerieName(get_lang('Score'),"Serie1");
$data_set->SetSerieName(get_lang('MyResults'),"Serie2");
$data_set->SetXAxisName(get_lang("Score"));
// Initialise the graph
$main_width = 500;
$main_height = 250;
$main_graph = new pChart($main_width,$main_height);
$main_graph->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf',8);
//.........这里部分代码省略.........
示例12: get_teachers_information_graph
/**
* This method return a content html, it's used inside get_block method for showing it inside dashboard interface
* @return string content html
*/
public function get_teachers_information_graph()
{
$teachers = $this->teachers;
$graph = '';
$user_ids = array_keys($teachers);
$a_last_week = get_last_week();
if (is_array($user_ids) && count($user_ids) > 0) {
$data_set = new pData();
foreach ($user_ids as $user_id) {
$teacher_info = api_get_user_info($user_id);
$username = $teacher_info['username'];
$time_by_days = array();
foreach ($a_last_week as $day) {
// day is received as y-m-d 12:00:00
$start_date = api_get_utc_datetime($day);
$end_date = api_get_utc_datetime($day + (3600 * 24 - 1));
$time_on_platform_by_day = Tracking::get_time_spent_on_the_platform($user_id, 'custom', $start_date, $end_date);
$hours = floor($time_on_platform_by_day / 3600);
$min = floor(($time_on_platform_by_day - $hours * 3600) / 60);
$time_by_days[] = $min;
}
$data_set->AddPoint($time_by_days, $username);
$data_set->AddSerie($username);
}
$last_week = date('Y-m-d', $a_last_week[0]) . ' ' . get_lang('To') . ' ' . date('Y-m-d', $a_last_week[6]);
$days_on_week = array();
foreach ($a_last_week as $weekday) {
$days_on_week[] = date('d/m', $weekday);
}
$data_set->AddPoint($days_on_week, "Days");
$data_set->SetXAxisName($last_week);
$data_set->SetYAxisName(get_lang('Minutes'));
$data_set->SetAbsciseLabelSerie("Days");
$graph_id = $this->user_id . 'TeacherConnectionsGraph';
$cache = new pCache();
// the graph id
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data_set->GetData())) {
//if we already created the img
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
} else {
// Initializing the graph
$bg_width = 440;
$bg_height = 350;
$test = new pChart($bg_width + 10, $bg_height + 20);
$test->setFontProperties(api_get_path(LIBRARY_PATH) . 'pchart/fonts/tahoma.ttf', 8);
$test->setGraphArea(65, 30, $bg_width - 70, $bg_height - 50);
$test->drawFilledRoundedRectangle(7, 7, $bg_width, $bg_height, 5, 240, 240, 240);
$test->drawRoundedRectangle(5, 5, $bg_width + 2, $bg_height + 2, 5, 230, 230, 230);
$test->drawGraphArea(255, 255, 255, TRUE);
$test->drawScale($data_set->GetData(), $data_set->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, TRUE);
$test->drawGrid(4, TRUE, 230, 230, 230, 50);
// Drawing lines
//$test->drawLineGraph($data_set->GetData(),$data_set->GetDataDescription());
$test->drawFilledCubicCurve($data_set->GetData(), $data_set->GetDataDescription(), 0.1, 30);
//$test->drawPlotGraph($data_set->GetData(),$data_set->GetDataDescription(),3,2,255,255,255);
// Drawing Legend
$test->setFontProperties(api_get_path(LIBRARY_PATH) . 'pchart/fonts/tahoma.ttf', 8);
$test->drawLegend($bg_width - 80, 20, $data_set->GetDataDescription(), 204, 204, 255);
$test->writeValues($data_set->GetData(), $data_set->GetDataDescription(), array("Days"));
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
ob_start();
$test->Stroke();
ob_end_clean();
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
if (!empty($img_file)) {
$graph = '<img src="' . api_get_path(WEB_ARCHIVE_PATH) . $img_file . '">';
}
} else {
$graph = '<p>' . api_convert_encoding(get_lang('GraphicNotAvailable'), 'UTF-8') . '</p>';
}
return $graph;
}
示例13: pData
}
//Close the connection
fclose($handle);
// Include Global Config
include "../conf/graph_conf.php";
// Standard inclusions
include "{$pChart_path}/pData.class";
include "{$pChart_path}/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($ydata, "Serie1");
$DataSet->AddPoint($xdata, "Serie3");
$DataSet->AddSerie("Serie1");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetYAxisName("Usage");
$DataSet->SetXAxisName("Hour");
$DataSet->SetYAxisUnit("%");
#$DataSet->SetXAxisFormat("date");
// Initialise the graph
$Test = new pChart(900, 225);
$Test->setColorPalette(0, 126, 185, 245);
$Test->setFontProperties("{$font}", 8);
$Test->setGraphArea(75, 35, 890, 190);
#$Test->drawFilledRoundedRectangle(7,7,450,223,5,240,240,240);
#$Test->drawRoundedRectangle(5,5,450,225,5,230,230,230);
$Test->drawGraphArea(255, 255, 255, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 75, 75, 75, TRUE, 0, 2);
$Test->drawGrid(1, TRUE, 240, 240, 240);
#$Test->drawGrid(4,TRUE);
// Draw the 0 line
$Test->setFontProperties("{$font}", 6);
示例14: showGraph
function showGraph($searchInfo = '')
{
$conditions = empty($searchInfo['keywordId']) ? "" : " and s.keyword_id=" . intval($searchInfo['keywordId']);
$conditions .= empty($searchInfo['seId']) ? "" : " and s.searchengine_id=" . intval($searchInfo['seId']);
$sql = "select s.*,se.domain \r\n\t\t\t\t\tfrom searchresults s,searchengines se \r\n\t\t\t\t\twhere s.searchengine_id=se.id \r\n\t\t\t\t\tand time>= " . intval($searchInfo['fromTime']) . " and time<" . intval($searchInfo['toTime']) . " {$conditions} \r\n\t\t\t\t\torder by s.time";
$repList = $this->db->select($sql);
$reportList = array();
$seList = array();
foreach ($repList as $repInfo) {
$var = $repInfo['searchengine_id'] . $repInfo['keyword_id'] . $repInfo['time'];
if (empty($reportList[$var])) {
$reportList[$var] = $repInfo;
} else {
if ($repInfo['rank'] < $reportList[$var]['rank']) {
$reportList[$var] = $repInfo;
}
}
if (empty($seList[$repInfo['searchengine_id']])) {
$seList[$repInfo['searchengine_id']] = $repInfo['domain'];
}
}
asort($seList);
$dataList = array();
$maxValue = 0;
foreach ($reportList as $repInfo) {
$seId = $repInfo['searchengine_id'];
$dataList[$repInfo['time']][$seId] = $repInfo['rank'];
$maxValue = $repInfo['rank'] > $maxValue ? $repInfo['rank'] : $maxValue;
}
// check whether the records are available for drawing graph
if (empty($dataList) || empty($maxValue)) {
$kpText = $_SESSION['lang_code'] == 'ja' ? $_SESSION['text']['common']['No Records Found'] . "!" : "No Records Found!";
$this->showMessageAsImage($kpText);
}
# Dataset definition
$dataSet = new pData();
foreach ($dataList as $dataInfo) {
$i = 1;
foreach ($seList as $seId => $seVal) {
$val = empty($dataInfo[$seId]) ? 0 : $dataInfo[$seId];
$dataSet->AddPoint($val, "Serie" . $i++);
}
}
$i = 1;
foreach ($seList as $seDomain) {
$dataSet->AddSerie("Serie{$i}");
$dataSet->SetSerieName($seDomain, "Serie{$i}");
$i++;
}
$serieCount = count($seList) + 1;
$dataSet->AddPoint(array_keys($dataList), "Serie{$serieCount}");
$dataSet->SetAbsciseLabelSerie("Serie{$serieCount}");
# if language is japanese
if ($_SESSION['lang_code'] == 'ja') {
$fontFile = "fonts/M+1P+IPAG.ttf";
$dataSet->SetXAxisName($_SESSION['text']['common']["Date"]);
$dataSet->SetYAxisName($_SESSION['text']['common']["Rank"]);
} else {
$fontFile = "fonts/tahoma.ttf";
$dataSet->SetXAxisName("Date");
$dataSet->SetYAxisName("Rank");
}
$dataSet->SetXAxisFormat("date");
# Initialise the graph
$chart = new pChart(720, 520);
$chart->setFixedScale($maxValue, 1);
$chart->setFontProperties($fontFile, 8);
$chart->setGraphArea(85, 30, 670, 425);
$chart->drawFilledRoundedRectangle(7, 7, 713, 513, 5, 240, 240, 240);
$chart->drawRoundedRectangle(5, 5, 715, 515, 5, 230, 230, 230);
$chart->drawGraphArea(255, 255, 255, TRUE);
$chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 90, 2);
$chart->drawGrid(4, TRUE, 230, 230, 230, 50);
# Draw the 0 line
$chart->setFontProperties($fontFile, 6);
$chart->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
# Draw the line graph
$chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
$chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 3, 2, 255, 255, 255);
$j = 1;
$chart->setFontProperties($fontFile, 10);
foreach ($seList as $seDomain) {
$chart->writeValues($dataSet->GetData(), $dataSet->GetDataDescription(), "Serie" . $j++);
}
# Finish the graph
$chart->setFontProperties("fonts/tahoma.ttf", 8);
$chart->drawLegend(90, 35, $dataSet->GetDataDescription(), 255, 255, 255);
$chart->setFontProperties($fontFile, 10);
$kpText = $_SESSION['lang_code'] == 'ja' ? $this->spTextKeyword["Keyword Position Report"] : "Keyword Position Report";
$chart->drawTitle(60, 22, $kpText, 50, 50, 50, 585);
$chart->stroke();
}
示例15: pData
/*
Example18 : Missing values
*/
// Standard inclusions
include "src/pData.php";
include "src/pChart.php";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(2, 5, 7, "", "", 5, 6, 4, 8, 4, "", 2, 5, 6, 4, 5, 6, 7, 6), "Serie1");
$DataSet->AddPoint(array(-1, -3, -1, -2, -4, -1, "", -4, -5, -3, -2, -2, -3, -3, -5, -4, -3, -1, ""), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("Raw #1", "Serie1");
$DataSet->SetSerieName("Raw #2", "Serie2");
$DataSet->SetYAxisName("Response time");
$DataSet->SetXAxisName("Sample #ID");
//print_r($DataSet->GetData());
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(55, 30, 585, 185);
$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 line graph
$DataSet->RemoveSerie("Serie2");