本文整理汇总了PHP中pData::SetXAxisUnit方法的典型用法代码示例。如果您正苦于以下问题:PHP pData::SetXAxisUnit方法的具体用法?PHP pData::SetXAxisUnit怎么用?PHP pData::SetXAxisUnit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pData
的用法示例。
在下文中一共展示了pData::SetXAxisUnit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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']);
//.........这里部分代码省略.........
示例2: pData
// Standard inclusions
include "../lib/pData.php";
include "../lib/pChart.php";
// Dataset definition
$DataSet = new pData();
$DataSet->AddPoint(array(9, 9, 9, 10, 10, 11, 12, 14, 16, 17, 18, 18, 19, 19, 18, 15, 12, 10, 9), "Serie1");
$DataSet->AddPoint(array(10, 11, 11, 12, 12, 13, 14, 15, 17, 19, 22, 24, 23, 23, 22, 20, 18, 16, 14), "Serie2");
$DataSet->AddPoint(array(4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22), "Serie3");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie3");
$DataSet->SetAbsciseLabelSerie("Serie3");
$DataSet->SetSerieName("January", "Serie1");
$DataSet->SetSerieName("February", "Serie2");
$DataSet->SetYAxisName("Temperature");
$DataSet->SetYAxisUnit("°C");
$DataSet->SetXAxisUnit("h");
// Initialise the graph
$Test = new pChart(700, 230);
$Test->drawGraphAreaGradient(132, 173, 131, 50, TARGET_BACKGROUND);
$Test->setFontProperties("../Fonts/tahoma.ttf", 8);
$Test->setGraphArea(120, 20, 675, 190);
$Test->drawGraphArea(213, 217, 221, FALSE);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, 0, 2, TRUE);
$Test->drawGraphAreaGradient(163, 203, 167, 50);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// Draw the bar chart
$Test->drawStackedBarGraph($DataSet->GetData(), $DataSet->GetDataDescription(), 70);
// Draw the title
$Title = " Average Temperatures during\r\n the first months of 2008 ";
$Test->drawTextBox(0, 0, 50, 230, $Title, 90, 255, 255, 255, ALIGN_BOTTOM_CENTER, TRUE, 0, 0, 0, 30);
// Draw the legend
示例3: 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);
}
示例4: cartesianChart
function cartesianChart($type, $x, $y, $w, $h, $imgname = '', $config = array())
{
$w -= 4;
$h -= 4;
$settings = array('FontName' => 'tahoma.ttf', 'FontSize' => 8, 'LegendFontSize' => 8, 'LegendFontName' => 'tahoma.ttf', 'Logo' => '', 'LogoTransparency' => 20, 'XAxisFormat' => 'number', 'XAxisUnit' => '', 'YAxisFormat' => 'number', 'YAxisUnit' => '', 'XLogo' => 0, 'YLogo' => 0, 'Xlabel' => 'x label', 'XAngle' => 0, 'Ylabel' => 'y label', 'Legend' => '', 'Textbox' => '', 'TextboxFontSize' => 8, 'TextboxFontName' => 'tahoma.ttf', 'ImgR' => 132, 'ImgG' => 173, 'ImgB' => 131, 'Decay' => 80, 'BGR' => 163, 'BGG' => 203, 'BGB' => 167, 'Decay2' => 80, 'Filled' => '', 'DataR' => 191, 'DataG' => 120, 'DataB' => 71, 'LBR' => 226, 'LBG' => 228, 'LBB' => 230, 'LR' => 0, 'LG' => 0, 'LB' => 0);
// Get the custom settings
if (is_array($config)) {
foreach ($config as $key => $val) {
$settings[$key] = $val;
}
}
$DataSet = new pData();
$DataSet->AddPoint($y, "Serie1");
$DataSet->AddPoint($x, "Serie2");
$DataSet->AddAllSeries();
$DataSet->RemoveSerie("Serie2");
$DataSet->SetAbsciseLabelSerie("Serie2");
$DataSet->SetSerieName($settings['Legend'], "Serie1");
$DataSet->SetYAxisName($settings['Ylabel']);
$DataSet->SetXAxisName($settings['Xlabel']);
$DataSet->SetXAxisFormat($settings['XAxisFormat']);
if (strlen($settings['XAxisUnit'])) {
$DataSet->SetXAxisUnit($settings['XAxisUnit']);
}
if (strlen($settings['YAxisUnit'])) {
$DataSet->SetYAxisUnit($settings['YAxisUnit']);
}
$DataSet->SetYAxisFormat($settings['YAxisFormat']);
// Initialise the graph
$Test = new pChart($w, $h);
$Test->drawGraphAreaGradient($settings['ImgR'], $settings['ImgG'], $settings['ImgB'], $settings['Decay'], TARGET_BACKGROUND);
$FontSize = $settings['FontSize'];
$FontName = $this->_ext_path . "/fonts/" . $settings['FontName'];
$Test->setFontProperties($FontName, $FontSize);
//Calc Textbox Height
if (strlen($settings['Textbox'])) {
$TextboxFontSize = $settings['TextboxFontSize'];
$TextboxFontName = $this->_ext_path . "/fonts/" . $settings['TextboxFontName'];
$Position = imageftbbox($TextboxFontSize, 0, $TextboxFontName, $settings['Textbox']);
$TextboxHeight = $Position[1] - $Position[7] + 8;
} else {
$TextboxHeight = 0;
}
// Maximize The graph area
//on Y axis
if ($settings['XAxisFormat'] == 'time') {
$xdata = "99:99:99";
$Position = imageftbbox($FontSize, 0, $FontName, $xdata);
$WXmax = $Position[2] - $Position[0];
$TextHeightX = $Position[1] - $Position[7];
} elseif ($settings['XAxisFormat'] == 'date') {
$xdata = "99/99/9999";
$Position = imageftbbox($FontSize, 0, $FontName, $xdata);
$WXmax = $Position[2] - $Position[0];
$TextHeightX = $Position[1] - $Position[7];
} else {
$WXmax = 0;
foreach ($x as $xdata) {
$xdata .= $settings['XAxisUnit'];
$Position = imageftbbox($FontSize, 0, $FontName, $xdata);
$TextWidth = $Position[2] - $Position[0];
$TextHeightX = $Position[1] - $Position[7];
$WXmax = $TextWidth > $WXmax ? $TextWidth : $WXmax;
}
}
if ($settings['XAngle'] > 0) {
$sin = abs(sin(deg2rad($settings['XAngle'])));
$cos = abs(cos(deg2rad($settings['XAngle'])));
$HXmax = $WXmax * $sin + $TextHeightX * $cos;
} else {
$HXmax = $TextHeightX;
}
//on Y axis...
if ($settings['YAxisFormat'] == 'time') {
$ydata = "99:99:99";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$WYmax = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
} elseif ($settings['YAxisFormat'] == 'date') {
$ydata = "99/99/9999";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$WYmax = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
} else {
$WYmax = 0;
foreach ($y as $ydata) {
$ydata .= $settings['YAxisUnit'];
//echo $ydata."<br>";
$Position = imageftbbox($FontSize, 0, $FontName, $ydata);
$TextWidth = $Position[2] - $Position[0];
$TextHeightY = $Position[1] - $Position[7];
$WYmax = $TextWidth > $WYmax ? $TextWidth : $WYmax;
}
}
$Test->setGraphArea($WYmax + $TextHeightY + 35, 20, $w - 25, $h - $HXmax - $TextHeightX - $TextboxHeight - 20);
//$Test->setGraphArea(60,20,$w-25,($settings['XAngle']==0)?$h-70:$h-100);
$Test->drawScale($DataSet->GetData(), $DataSet->GetDataDescription(), SCALE_ADDALL, 213, 217, 221, TRUE, $settings['XAngle'], 0, TRUE);
$Test->drawGraphAreaGradient($settings['BGR'], $settings['BGG'], $settings['BGB'], $settings['Decay2']);
$Test->drawGrid(4, TRUE, 230, 230, 230, 20);
// This will put the picture "logo.png" with transparency
//.........这里部分代码省略.........