本文整理汇总了PHP中pChart::drawPlotGraph方法的典型用法代码示例。如果您正苦于以下问题:PHP pChart::drawPlotGraph方法的具体用法?PHP pChart::drawPlotGraph怎么用?PHP pChart::drawPlotGraph使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pChart
的用法示例。
在下文中一共展示了pChart::drawPlotGraph方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createGraphToFile
/**
* Генерация графика
* @param DataSet $DataSet
* @param String $GraphTitle
* @param String $safeToFile
*/
function createGraphToFile($DataSet, $GraphTitle, $safeToFile, $scaleFormat)
{
// Rotrate
$rotate = 30;
// Initialise the graph
$GraphImage = new pChart(594, 344);
$GraphImage->setDateFormat($scaleFormat);
// $GraphImage->loadColorPalette(DIR_FONT.'/tones-3.txt');
$GraphImage->setFontProperties(DIR_FONT . "/segoepr.ttf", 8);
$GraphImage->setGraphArea(80, 50, 580, 300);
$GraphImage->drawFilledRectangle(3, 3, 590, 340, 240, 240, 240);
$GraphImage->drawRectangle(0, 0, 593, 343, 230, 230, 230);
$GraphImage->drawGraphArea(255, 255, 255, TRUE);
$GraphImage->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, $rotate, 0, FALSE);
$GraphImage->drawGrid(4, TRUE, 230, 230, 230, 50);
// Draw the 0 line
$GraphImage->setFontProperties(DIR_FONT . "/segoepr.ttf", 6);
$GraphImage->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Просто пунктирная линия
// Draw the cubic curve graph
$GraphImage->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
// Draw the line graph
//$GraphImage->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
$GraphImage->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 2, 255, 255, 255);
// Finish the graph
$GraphImage->setFontProperties(DIR_FONT . "/segoepr.ttf", 12);
$GraphImage->drawTitle(60, 32, $GraphTitle, 50, 50, 50, 600);
//$GraphImage->Render(DIR_CACHE . './' . $safeToFile . '.png');
$GraphImage->Stroke();
}
示例2: 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");
}
示例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:
$Test->drawRoundedRectangle(1,1,699,399,5,33,33,33);
$Test->drawRoundedRectangle(2,2,698,398,5,33,33,33);
$Test->drawRoundedRectangle(3,3,697,397,5,33,33,33);
*/
$Test->drawGraphArea(150,150,150);
$nb_joueurs_graph = ($nb_joueurs - $nb_joueurs % 10) + 10;
$Test->setFixedScale($nb_joueurs_graph,0,$nb_joueurs_graph/5,0,38,1);
$Test->drawScale($DataSet->GetData(),$DataSet->GetDataDescription(),SCALE_NORMAL,20,20,20,TRUE,0,2);
$Test->drawGrid(4,FALSE,0,0,0);
// Draw the 0 line
$Test->setFontProperties("../lib/Fonts/tahoma.ttf",6);
$Test->drawTreshold(0,143,55,72,TRUE,TRUE);
// Draw the line graph
//$Test->setLineStyle(3);
$Test->drawLineGraph($DataSet->GetData(),$DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(),$DataSet->GetDataDescription(),2,0,255,0,0);
//$Test->writeValues($DataSet->GetData(),$DataSet->GetDataDescription(),"SerieClassement");
// Finish the graph
$Test->setFontProperties("../lib/Fonts/tahoma.ttf",8);
//$Test->drawLegend(75,35,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties("../lib/Fonts/tahoma.ttf",10);
$Test->drawTitle(60,22,"Evolution du classement ".$type." de ".$pseudo,50,50,50,585);
$Test->Stroke();
?>
示例5: 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();
}
示例6: grapher
//.........这里部分代码省略.........
$main_day[date('d-m-Y', $data['login'])] += float_format(($data['logout'] - $data['login']) / 60, 0);
if ($i > 500) {
break;
}
$i++;
}
switch ($type) {
case 'day':
$main_date = $main_day;
break;
case 'month':
$main_date = $main_month_year;
break;
case 'year':
$main_date = $main_year;
break;
}
// the nice graphics :D
$labels = array_keys($main_date);
if (count($main_date) == 1) {
$labels = $labels[0];
$main_date = $main_date[$labels];
}
$data_set = new pData();
$data_set->AddPoint($main_date, 'Q');
if (count($main_date)!= 1) {
$data_set->AddPoint($labels, 'Date');
}
$data_set->AddAllSeries();
$data_set->RemoveSerie('Date');
$data_set->SetAbsciseLabelSerie('Date');
$data_set->SetYAxisName(get_lang('Minutes', ''));
$graph_id = api_get_user_id().'AccessDetails'.api_get_course_id().$start_date.$end_date.$type;
$data_set->AddAllSeries();
$cache = new pCache();
// the graph id
$data = $data_set->GetData();
if ($cache->IsInCache($graph_id, $data_set->GetData())) {
//if (0) {
//if we already created the img
// echo 'in cache';
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
} else {
// if the image does not exist in the archive/ folder
// Initialise the graph
$test = new pChart(760, 230);
//which schema of color will be used
$quant_resources = count($data[0]) - 1;
// Adding the color schemma
$test->loadColorPalette(api_get_path(LIBRARY_PATH).'pchart/palette/default.txt');
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8);
$test->setGraphArea(70, 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($data_set->GetData(), $data_set->GetDataDescription(), SCALE_START0, 150, 150, 150, TRUE, 0, 0);
$test->drawGrid(4, TRUE, 230, 230, 230, 50);
$test->setLineStyle(2);
// Draw the 0 line
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 6);
$test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
if (count($main_date) == 1) {
//Draw a graph
echo '<strong>'.$labels.'</strong><br/>';
$test->drawBarGraph($data_set->GetData(), $data_set->GetDataDescription(), TRUE);
} else {
//Draw the line graph
$test->drawLineGraph($data_set->GetData(), $data_set->GetDataDescription());
$test->drawPlotGraph($data_set->GetData(), $data_set->GetDataDescription(), 3, 2, 255, 255, 255);
}
// Finish the graph
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 8);
$test->setFontProperties(api_get_path(LIBRARY_PATH).'pchart/fonts/tahoma.ttf', 10);
$test->drawTitle(60, 22, get_lang('AccessDetails'), 50, 50, 50, 585);
//------------------
//echo 'not in cache';
$cache->WriteToCache($graph_id, $data_set->GetData(), $test);
ob_start();
$test->Stroke();
ob_end_clean();
$img_file = $cache->GetHash($graph_id, $data_set->GetData());
}
$foo_img = '<img src="'.api_get_path(WEB_ARCHIVE_PATH).$img_file.'">';
return $foo_img;
} else {
$foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8');
return $foo_img;
}
}
示例7: 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");
}
示例8: pChart
$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(90, 90, 90, 90, TARGET_BACKGROUND);
$Test->setFixedScale(0, 40, 4);
// Graph area setup
$Test->setFontProperties("../Fonts/pf_arma_five.ttf", 6);
$Test->setGraphArea(60, 40, 680, 200);
$Test->drawGraphArea(200, 200, 200, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_NORMAL, 200, 200, 200, TRUE, 0, 2);
$Test->drawGraphAreaGradient(40, 40, 40, -50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 10);
// Draw the line chart
$Test->setShadowProperties(3, 3, 0, 0, 0, 30, 4);
$Test->drawCubicCurve($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->clearShadow();
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 3, 0, -1, -1, -1, TRUE);
// Write the title
$Test->setFontProperties("../Fonts/MankSans.ttf", 18);
$Test->setShadowProperties(1, 1, 0, 0, 0);
$Test->drawTitle(0, 0, "Average temperatures", 255, 255, 255, 700, 30, TRUE);
$Test->clearShadow();
// Draw the legend
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->drawLegend(610, 5, $DataSet->GetDataDescription(), 0, 0, 0, 0, 0, 0, 255, 255, 255, FALSE);
// Render the picture
$Test->Render("example25.png");
示例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: build
public function build()
{
require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pData.php';
require_once PCHART_BASE_DIR . DIRECTORY_SEPARATOR . 'pChart.php';
$dataSet = new pData();
foreach ($this->lines as $name => $ordinateValues) {
if (count($ordinateValues) != count($this->absciseValues)) {
throw new Exception('Count of line "' . $name . '" ordinate points "' . count($ordinateValues) . '" mismatch to abscise points "' . count($this->absciseValues) . '"');
}
$dataSet->AddPoint($ordinateValues, $name);
}
$dataSet->AddPoint($this->absciseValues, 'Abscise');
$dataSet->AddAllSeries();
$dataSet->RemoveSerie('Abscise');
$dataSet->SetAbsciseLabelSerie('Abscise');
foreach ($this->lines as $name => $ordinateValues) {
$dataSet->SetSerieName($name, $name);
}
$dataSet->SetYAxisUnit($this->ordinateStepTitle);
$dataSet->SetXAxisUnit($this->absciseStepTitle);
$chart = new pChart($this->maxWidth, $this->maxHeight);
$chart->drawGraphAreaGradient(132, 153, 172, 50, TARGET_BACKGROUND);
// Graph area setup
$chart->setFontProperties(PCHART_FONTS_DIR . DIRECTORY_SEPARATOR . 'tahoma.ttf', 10);
$chart->setGraphArea($this->graphMargins[0], $this->graphMargins[1], $this->maxWidth - $this->graphMargins[2], $this->maxHeight - $this->graphMargins[3]);
$chart->drawGraphArea(213, 217, 221, FALSE);
$ordinateScaleMargin = ($this->getMaxOrdinateValue() - $this->getMinOrdinateValue()) / $this->ordinateDevisions;
$chart->setFixedScale($this->getMinOrdinateValue() - $ordinateScaleMargin, $this->getMaxOrdinateValue() + $ordinateScaleMargin, $this->ordinateDevisions);
$chart->drawScale($dataSet->GetData(), $dataSet->GetDataDescription(), SCALE_NORMAL, 213, 217, 221, TRUE, 0, 2);
$chart->drawGraphAreaGradient(162, 183, 202, 50);
$chart->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the line chart
// $chart->setShadowProperties(1, 1, 0, 0, 0, 30, 4);
$chart->drawLineGraph($dataSet->GetData(), $dataSet->GetDataDescription());
$chart->clearShadow();
$chart->drawPlotGraph($dataSet->GetData(), $dataSet->GetDataDescription(), 5, 3, -1, -1, -1, TRUE);
// Draw the legend
$chart->drawLegend($this->maxWidth - $this->graphMargins[2] + 10, $this->graphMargins[1], $dataSet->GetDataDescription(), 236, 238, 240, 52, 58, 82);
// Draw chart title
if ($this->chartTitle) {
$chart->drawTextBox(0, $this->maxHeight - 20, $this->maxWidth, $this->maxHeight, $this->chartTitle, 0, 255, 255, 255, ALIGN_RIGHT, TRUE, 0, 0, 0, 30);
}
// Render the picture
$chart->addBorder(2);
$chart->Render($this->outputFilepath);
}
示例11: 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'));
}
示例12: drawLine
/**
* Draw line style chart
* @return unknown
*/
protected function drawLine()
{
// prepare font & series
$this->_prepareSerie();
$this->_prepareFont();
// init chart params
$outer_w = $this->w - 5;
// Outer frame witdh
$outer_h = $this->h - 5;
// Outer frame heigth
$inner_w = $this->w - 7;
// Inner frame witdh
$inner_h = $this->h - 7;
// Inner frame heigth
$chart_w = $this->w - 150;
// Chart frame witdh
$chart_h = $this->h - 40;
// Chart frame heigth
$title_w = $this->w - 200;
// Title width
$title_h = 45;
// Title height
$legend_w = $chart_w + 30;
// Legend width
$legend_h = 40;
// Legend height
// chart styles
$grid = isset($this->p['grid']) ? $this->p['grid'] : false;
$plot = isset($this->p['plot']) ? $this->p['plot'] : false;
$curve = isset($this->p['curve']) ? $this->p['curve'] : false;
$filled = isset($this->p['filled']) ? $this->p['filled'] : false;
// fill chart
$this->chart->drawBackground(255, 255, 255);
$this->chart->setFontProperties($this->font, 7);
// set font and size
$this->chart->drawRoundedRectangle(5, 5, $outer_w, $outer_h, 10, 230, 230, 230);
// drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
$this->chart->drawFilledRoundedRectangle(7, 7, $inner_w, $inner_h, 10, 240, 240, 240);
// drawRoundedRectangle($X1,$Y1,$X2,$Y2,$Radius,$R,$G,$B)
$this->chart->setGraphArea(70, 40, $chart_w, $chart_h);
// setGraphArea($X1,$Y1,$X2,$Y2)
$this->chart->drawGraphArea(255, 255, 255, TRUE);
// drawGraphArea($R,$G,$B)
$this->chart->drawScale($this->data->GetData(), $this->data->GetDataDescription(), SCALE_NORMAL, 150, 150, 150, TRUE, 0, 2, $this->margin, $this->skip);
// drawScale($Data,$DataDescription,$ScaleMode,$R,$G,$B,$DrawTicks=TRUE,$Angle=0,$Decimals=1,$WithMargin=FALSE,$SkipLabels=1,$RightScale=FALSE)
$this->data->RemoveSerie('DEFAULT_SCALE');
// clear scale serie for setScale method
// draw grid
if ($grid) {
$this->chart->drawGrid(3, TRUE, 230, 230, 230, 50);
// drawGrid($LineWidth,$Mosaic=TRUE,$R=220,$G=220,$B=220,$Alpha=255)
}
// draw the 0 line
//$this->chart->setFontProperties($this->font,6);
//$this->chart->drawTreshold(0,143,55,72,TRUE,TRUE);
// draw the cubic curve graph
if ($curve) {
$this->chart->drawCubicCurve($this->data->GetData(), $this->data->GetDataDescription());
if ($filled) {
$this->chart->drawFilledCubicCurve($this->data->GetData(), $this->data->GetDataDescription(), 0.1, 50);
// filled cubic curve graph
}
// draw the line graph
} else {
$this->chart->drawLineGraph($this->data->GetData(), $this->data->GetDataDescription());
if ($filled) {
$this->chart->drawFilledLineGraph($this->data->GetData(), $this->data->GetDataDescription(), 50);
}
}
// plot style point
if ($plot) {
$this->chart->drawPlotGraph($this->data->GetData(), $this->data->GetDataDescription(), 3, 2, 255, 255, 255, true);
// drawPlotGraph(&$Data,&$DataDescription,$BigRadius=5,$SmallRadius=2,$R2=-1,$G2=-1,$B2=-1,$Shadow=FALSE)
}
// add Title
$this->chart->setFontProperties($this->font, 10);
$this->chart->drawTitle(40, 0, $this->title, 50, 50, 50, $title_w, $title_h);
// drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)
// add Legend
$this->chart->setFontProperties($this->font, 8);
$this->chart->drawLegend($legend_w, $legend_h, $this->data->GetDataDescription(), 255, 255, 255);
// drawLegend($description,$R,$G,$B)
}
示例13: pData
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array($data1, $data2, $data3, $data4, $data5), "Serie1");
$DataSet->AddPoint(array("January", "February", "March", "April", "May", "June"), "Serie2");
$DataSet->AddAllSeries();
$DataSet->SetAbsciseLabelSerie("Serie2");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->setGraphArea(60, 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(), 5, 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 area
$Test->drawArea($DataSet->GetData(), "Serie1", "Serie3", 239, 238, 227, 50);
// Draw the line graph
$DataSet->RemoveSerie("Serie1");
$DataSet->RemoveSerie("Serie3");
$Test->drawLineGraph($DataSet->AddPoint(array($data1, $data2, $data3, $data4, $data5), "Serie1"), $DataSet->GetDataDescription(), 0.1);
$Test->drawPlotGraph($DataSet->AddPoint(array($data1, $data2, $data3, $data4, $data5), "Serie1"), $DataSet->GetDataDescription(), 0, 2, 3, 24, 30);
// Finish the graph
$Test->setFontProperties("Fonts/tahoma.ttf", 8);
$Test->drawLegend(65, 35, $DataSet->GetDataDescription(), 250, 250, 250);
$Test->setFontProperties("Fonts/tahoma.ttf", 10);
$Test->drawTitle(60, 22, "Reporting Rate", 50, 50, 50, 585);
$Test->Render("example45.png");
示例14: pChart
$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);
$Test->drawTreshold(0, 143, 55, 72, TRUE, TRUE);
// Draw the line graph
$Test->drawLineGraph($DataSet->GetData(), $DataSet->GetDataDescription());
$Test->drawPlotGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 0.1, 0);
// Finish the graph
$Test->setFontProperties("{$font}", 8);
#$Test->drawLegend(90,35,$DataSet->GetDataDescription(),255,255,255);
$Test->setFontProperties("{$font}", 11);
$Test->drawTitle(325, 25, "CPU", 75, 75, 75, 585);
$Test->Stroke();
?>
示例15: 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;
}