本文整理汇总了PHP中pData::AddSerie方法的典型用法代码示例。如果您正苦于以下问题:PHP pData::AddSerie方法的具体用法?PHP pData::AddSerie怎么用?PHP pData::AddSerie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pData
的用法示例。
在下文中一共展示了pData::AddSerie方法的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: makeGraph
function makeGraph($values, $labels)
{
$values[] = '0';
$labels[] = '';
// Standard inclusions
include_once "charts/pChart.class";
include_once "charts/pData.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($values, "Serie2");
$DataSet->AddPoint($labels, "Xlabel");
$DataSet->AddSerie("Serie2");
$DataSet->SetAbsciseLabelSerie('Xlabel');
$DataSet->SetSerieName("No Of Births", "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, 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->drawOverlayBarGraph($DataSet->GetData(), $DataSet->GetDataDescription());
// 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, "Change in name popularity", 50, 50, 50, 585);
ob_start();
$Test->Stroke();
$img = ob_get_clean();
$img = base64_encode($img);
return $img;
}
示例3: 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']);
//.........这里部分代码省略.........
示例4: 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');
}
示例5: createPieChart
/**
* Creates a new pie-chart. Pass the values as the first param. If
* you want to use a legend and / or Colors use the second and third param.
* Make sure the array have the same number of elements, ohterwise they won't
* be uses.
* A sample-code could be:
* $objChart = new class_graph();
* $objChart->setStrGraphTitle("Test Pie Chart");
*
* //simple array
* $objChart->createPieChart(array(2,6,7,3), array("val 1", "val 2", "val 3", "val 4"));
*
* //datapoints array
* $objDataPoint1 = new class_graph_datapoint(1);
* $objDataPoint2 = new class_graph_datapoint(2);
* $objDataPoint3 = new class_graph_datapoint(4);
* $objDataPoint4 = new class_graph_datapoint(5);
*
* //set action handler example
* $objDataPoint1->setObjActionHandler("<javascript code here>");
* $objDataPoint1->getObjActionHandlerValue("<value_object> e.g. some json");
*
* $objGraph->createPieChart(array($objDataPoint1, $objDataPoint2, $objDataPoint3, $objDataPoint4) , array("val 1", "val 2", "val 3", "val 4"), "serie 1");
*
*
* @param array $arrValues - an array with simple values or an array of data points (class_graph_datapoint).
* The advantage of a data points are that action handlers can be defined for each data point which will be executed when clicking on the data point in the chart.
* @param array $arrLegends
*
* @throws class_exception
* @return void
*/
public function createPieChart($arrValues, $arrLegends)
{
$arrDataPoints = class_graph_commons::convertArrValuesToDataPointArray($arrValues);
if ($this->intCurrentGraphMode > 0) {
throw new class_exception("Chart already initialized", class_exception::$level_ERROR);
}
$this->intCurrentGraphMode = $this->GRAPH_TYPE_PIE;
$strSerieName = generateSystemid();
$this->objDataset->AddPoint(class_graph_commons::getDataPointFloatValues($arrDataPoints), $strSerieName);
$this->objDataset->AddSerie($strSerieName);
$strSerieName = generateSystemid();
foreach ($arrLegends as &$strValue) {
$strValue = $this->stripLegend($strValue);
}
$this->objDataset->AddPoint($arrLegends, $strSerieName);
$this->objDataset->AddSerie($strSerieName);
$this->objDataset->SetAbsciseLabelSerie($strSerieName);
}
示例6: prepareData
function prepareData($scaleX, $scaleY, $SQL, $scaleType)
{
global $conn;
$DataSet = new pData();
$result = pg_query($conn, $SQL);
if (!$result) {
echo "An error occured.\n";
}
while ($row = pg_fetch_row($result)) {
$DataSet->AddPoint($row[1], "Serie2");
$DataSet->AddPoint(mktime(0, 0, 0, substr($row[0], 5, 2), substr($row[0], 8, 2), substr($row[0], 0, 4)), "Serie1");
}
$DataSet->SetAbsciseLabelSerie("Serie1");
$DataSet->AddSerie("Serie2");
$DataSet->SetYAxisName($scaleY);
$DataSet->SetXAxisFormat($scaleType);
return $DataSet;
}
示例7: draw
/**
* The function to draw the spectrum
*/
public function draw()
{
$arrSpec = $this->spectrumUi->spectrum;
$data = new pData();
//-- Provide data --
$arrLabels = array();
foreach ($arrSpec as $entry) {
$strAnnot = $entry[$this->spectrumUi->annotationproperty];
$dblInt = $entry[$this->spectrumUi->intensityproperty];
$dblMass = $entry[$this->spectrumUi->massproperty];
if (!is_null($strAnnot) && $strAnnot !== '') {
$arrLabels[] = array($dblMass, $strAnnot);
}
$data->AddPoint($dblInt);
$data->AddPoint($dblMass, 'Serie2');
}
$data->AddSerie('Serie1');
$data->SetAbsciseLabelSerie('Serie2');
$data->SetSerieName('Intensities', 'Serie1');
$data->SetSerieName('Masses', 'Serie2');
$chart = new PChartExt($this->width, $this->height);
$chart->setColorPalette(0, $this->colorgraph[0], $this->colorgraph[1], $this->colorgraph[2]);
$chart->setFontProperties(dirname(__FILE__) . '/pchart/tahoma.ttf', 8);
$chart->setGraphArea(50, 60, $this->width - 50, $this->height - 30);
$chart->setLineStyle(1);
$chart->drawBackground($this->colorbg[0], $this->colorbg[1], $this->colorbg[2]);
$chart->drawScale($data->GetData(), $data->GetDataDescription(), SCALE_NORMAL, $this->colorscale[0], $this->colorscale[1], $this->colorscale[2], true, 0, 0, false, count($arrSpec) / 10);
$chart->drawPeaks($data->GetData(), $data->GetDataDescription());
$chart->drawTitle(50, 22, $this->title, $this->colortitle[0], $this->colortitle[1], $this->colortitle[2], 585);
//-- Draw labels --
foreach ($arrLabels as $label) {
$chart->setAnnotation($data->GetData(), $data->GetDataDescription(), 'Serie1', $label[0], $label[1], 255, 255, 255);
}
//-- Render spectrum --
$toFile = $this->spectrumUi->tofile;
if (!is_null($toFile) && $toFile !== '') {
$chart->Render($toFile);
//To file
} else {
$chart->Stroke();
//Directly to ui
}
}
示例8: 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;
}
示例9: pData
if ($gameid != $lastid) {
$lastid = $gameid;
$idx++;
}
$x[$player][] = $idx;
$y[$player][] = $elo;
$allx[] = $idx;
$ally[] = $elo;
}
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint($allx, "allx");
$DataSet->AddSerie("allx");
$DataSet->AddPoint($ally, "ally");
$DataSet->AddSerie("ally");
foreach ($names as $name) {
$DataSet->AddPoint($x[$name], $name . "x");
$DataSet->AddSerie($name . "x");
$DataSet->AddPoint($y[$name], $name . "y");
$DataSet->AddSerie($name . "y");
}
//$DataSet->SetYAxisName("ELO");
//$DataSet->SetXAxisName("Game");
$colors = array();
$ratio = 0;
$gold = 0.618033988749895;
for ($i = 0; $i < count($names); $i++) {
$ratio += $gold;
示例10: round
$_rank = $val[3] - $last_rank;
$last_points = $points[] = $last_points + round($_points / $val[4]);
$last_rank = $rank[] = $last_rank + round($_rank / $val[4]);
}
$data_count++;
});
$performance = number_format(round(($points[count($points) - 1] / $points[0] - 1) * 100, 2), 2, ',', '');
// Dataset definition
// File
$FileName = './tmp/' . md5($user['name']) . ".png";
// Graph
$DataSet = new pData();
$DataSet->AddPoint($points, "points");
$DataSet->AddPoint($rank, "rank");
$DataSet->AddPoint($time, "time");
$DataSet->AddSerie("points");
$DataSet->SetAbsciseLabelSerie();
$DataSet->SetSerieName("Punkte", "points");
$DataSet->SetSerieName("Rank", "rank");
$DataSet->SetYAxisName("Punkte");
$DataSet->SetAbsciseLabelSerie("time");
//$DataSet->SetXAxisFormat("date");
// Cache definition
$Cache = new pCache('../charts/Cache/');
if ($use_cache && !$Cache->GetFromCache(md5($user['name']), $DataSet->GetData(), $FileName) or !$use_cache) {
// Initialise the graph
$Test = new pChart(715, 230);
$Test->setDateFormat('d.m H:i');
$Test->setFontProperties("../charts/Fonts/tahoma.ttf", 8);
$Test->setGraphArea(60, 30, 650, 150);
$Test->drawFilledRoundedRectangle(7, 7, 708, 223, 5, 240, 240, 240);
示例11:
$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, 3);
$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 area
$DataSet->RemoveSerie("Serie4");
$Test->drawArea($DataSet->GetData(), "Serie1", "Serie2", 239, 238, 227, 50);
$DataSet->RemoveSerie("Serie3");
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
// Draw the line graph
$Test->setLineStyle(1, 6);
$DataSet->RemoveAllSeries();
$DataSet->AddSerie("Serie3");
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Write values on Serie3
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->writeValues($DataSet->GetData(), $DataSet->GetDataDescription(), "Serie3");
// Finish the graph
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(590, 90, $DataSet->GetDataDescription(), 255, 255, 255);
$Test->setFontProperties("../Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "example 15", 50, 50, 50, 585);
// Add an image
$Test->drawFromPNG("../Sample/logo.png", 584, 35);
// Render the chart
$Test->Render("example15.png");
示例12: showGraph
function showGraph($searchInfo = '')
{
$conditions = empty($searchInfo['keywordId']) ? "" : " and s.keyword_id=" . $searchInfo['keywordId'];
$conditions .= empty($searchInfo['seId']) ? "" : " and s.searchengine_id=" . $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>= {$searchInfo['fromTime']} and time<{$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();
foreach ($reportList as $repInfo) {
$seId = $repInfo['searchengine_id'];
$dataList[$repInfo['time']][$seId] = $repInfo['rank'];
}
# 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}");
$dataSet->SetXAxisName("Date");
$dataSet->SetYAxisName("Rank");
$dataSet->SetXAxisFormat("date");
# Initialise the graph
$chart = new pChart(720, 520);
$chart->setFontProperties("fonts/tahoma.ttf", 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("fonts/tahoma.ttf", 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("fonts/tahoma.ttf", 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("fonts/tahoma.ttf", 10);
$chart->drawTitle(60, 22, "Keyword Position Report", 50, 50, 50, 585);
$chart->stroke();
}
示例13: foreach
$serversColumnID = $globalstatistics->getColumnID('Servers');
foreach (DataGenerator::generateCustomChartData($globalstatistics, $playersColumnID, HOURS) as $data) {
$epoch = $data[0];
$value = $data[1];
$playersX[] = $value;
}
foreach (DataGenerator::generateCustomChartData($globalstatistics, $serversColumnID, HOURS) as $data) {
$epoch = $data[0];
$value = $data[1];
$serversX[] = $value;
}
// Add the data to the graph
$dataSet->AddPoint($playersX, 'Serie1');
$dataSet->AddPoint($serversX, 'Serie2');
// Create the series
$dataSet->AddSerie('Serie1');
$dataSet->AddSerie('Serie2');
$dataSet->SetSerieName('Players', 'Serie1');
$dataSet->SetSerieName('Servers', 'Serie2');
$dataSet->SetYAxisName('');
// Add all of the series
$dataSet->AddAllSeries();
// Set us up the bomb
$graph = new pChart(REAL_IMAGE_WIDTH, REAL_IMAGE_HEIGHT);
$graph->setFontProperties('tahoma.ttf', 8);
$graph->setGraphArea(60, 30, REAL_IMAGE_WIDTH - 20, REAL_IMAGE_HEIGHT - 30);
$graph->drawFilledRoundedRectangle(7, 7, REAL_IMAGE_WIDTH - 7, REAL_IMAGE_HEIGHT - 7, 5, 240, 240, 240);
$graph->drawRoundedRectangle(5, 5, REAL_IMAGE_WIDTH - 5, REAL_IMAGE_HEIGHT - 5, 5, 230, 230, 230);
$graph->drawGraphArea(250, 250, 250, true);
$graph->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, true, 0, 0);
// $graph->drawGrid(4, true, 230, 230, 230, 100);
示例14: pData
// Create Graph Dataset and set axis attributes
$graphData = new pData();
$graphData->setYAxisName($ytitle);
$graphData->AddPoint($xlabels, "xaxis");
//$graphData->SetSerieName("xaxis","xaxis");
$graphData->SetAbsciseLabelSerie("xaxis");
$graphData->setXAxisName($xtitle);
// Add each series of plot values to dataset, but Reportico will
// duplicate series were the same data are displayed in different forms
// so only add each unique series once
$seriesadded = array();
foreach ($plot as $k => $v) {
$series = $v["name"] . $k;
$graphData->AddPoint($v["data"], $series);
$graphData->SetSerieName($v["legend"], $series);
$graphData->AddSerie($series);
}
/*
switch ( $xgriddisplay )
{
case "all":
$graph->xgrid->Show(true,true);
break;
case "major":
$graph->xgrid->Show(true,false);
break;
case "minor":
$graph->xgrid->Show(false,true);
break;
case "none":
default:
示例15: pData
<?php
/*
Example22 : Customizing plot graphs
*/
// Standard inclusions
include "pChart/pData.class";
include "pChart/pChart.class";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(60, 70, 90, 110, 100, 90), "Serie1");
$DataSet->AddPoint(array(40, 50, 60, 80, 70, 60), "Serie2");
$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);