本文整理汇总了PHP中PHPlot::SetPlotType方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPlot::SetPlotType方法的具体用法?PHP PHPlot::SetPlotType怎么用?PHP PHPlot::SetPlotType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPlot
的用法示例。
在下文中一共展示了PHPlot::SetPlotType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_case
function test_case($case)
{
global $cases, $test_verbose, $n_tests, $n_pass, $n_fail, $test_save;
$n_tests++;
extract($cases[$case]);
$title = "Test case {$n_tests}: {$data_type} (should match {$like})";
# Make a data array that is valid (but not necessarily reasonable)
# for any data type. One works for all except pie chart.
if (!empty($pie)) {
$plot_type = 'pie';
$data = array(array('', 1), array('', 1), array('', 2));
} else {
$plot_type = 'lines';
# Valid for text-data, data-data, and data-data-error:
$data = array(array('', 1, 2, 2, 2), array('', 2, 4, 1, 1), array('', 3, 5, 2, 2));
}
$p1 = new PHPlot(400, 300);
$p1->SetFailureImage(False);
$p1->SetPrintImage(False);
$p1->SetDataValues($data);
$p1->SetDataType($data_type);
// Alias data type
$p1->SetPlotType($plot_type);
$p1->DrawGraph();
$p1_image = $p1->EncodeImage('raw');
if ($test_save) {
file_put_contents("dta-{$case}a_{$data_type}.png", $p1_image);
}
$p2 = new PHPlot(400, 300);
$p2->SetFailureImage(False);
$p2->SetPrintImage(False);
$p2->SetDataValues($data);
$p2->SetDataType($like);
// Base data type - alias should match this
$p2->SetPlotType($plot_type);
$p2->DrawGraph();
$p2_image = $p2->EncodeImage('raw');
if ($test_save) {
file_put_contents("dta-{$case}b_{$like}.png", $p2_image);
}
if ($p1_image == $p2_image) {
$n_pass++;
if ($test_verbose) {
echo "Pass: {$title}\n";
}
} else {
$n_fail++;
echo "FAIL - Image Mismatch: {$title}\n";
}
}
示例2: graficoBarra
function graficoBarra($data, $archivo = "", $meta_data = array('titulo' => 'Sin Título', 'tituloX' => 'Eje X', 'tituloY' => 'Eje Y', 'color' => 'SkyBlue', 'width' => 800, 'height' => 600, 'angle' => 45), $legend = array("Datos"))
{
# Objeto que crea el gráfico y su tama?o
$plot = new PHPlot($meta_data['width'], $meta_data['height']);
$plot->SetImageBorderType('plain');
# Setea el archivo donde se guarda la imagen generada y no permite la visualización inmediata
$plot->SetPrintImage(false);
$plot->SetFileFormat("jpg");
$plot->SetOutputFile($archivo);
$plot->SetIsInline(true);
# Envio de datos
$plot->SetDataValues($data);
# Tipo de gráfico y datos
$plot->SetDataType("text-data");
$plot->SetPlotType("bars");
# Setiando el True type font
//$plot->SetTTFPath(TTFPath);
//$plot->SetUseTTF(TRUE);
$plot->SetAxisFontSize(2);
$plot->SetVertTickIncrement(7);
//$plot->SetXTickLength(7);
//$plot->SetDataColors($meta_data['color']);
$plot->SetDataColors(array($meta_data['color'], 'red', 'white'));
$plot->SetLegendPixels(1, 1);
$plot->SetLegend($legend);
# Etiquetas del eje Y:
$plot->SetYTitle($meta_data['tituloY']);
$plot->SetYDataLabelPos('plotin');
# Título principal del gráfico:
$plot->SetTitle($meta_data['titulo']);
# Etiquetas eje X:
$plot->SetXTitle($meta_data['tituloX']);
if (isset($meta_data['angle'])) {
$plot->SetXLabelAngle($meta_data['angle']);
} else {
$plot->SetXLabelAngle(45);
}
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
# Método que dibuja el gráfico
$plot->DrawGraph();
$plot->PrintImage();
}
示例3: plotGraph
function plotGraph($data)
{
//Define the object
$plot = new PHPlot();
$example_data = $data;
$plot->SetDataValues($example_data);
$plot->SetDataType('data-data');
//Set titles
$plot->SetTitle("temp and humi");
$plot->SetXTitle('time');
$plot->SetYTitle('Y Data');
$legend = array('temp', 'humi');
$plot->SetLegend($legend);
$plot->SetXDataLabelAngle(90);
//$plot->SetXGridLabelType("time");
$plot->SetXTickLabelPos('xaxis');
$plot->SetXTickPos('plotdown');
$plot->SetXLabelType('time', '%H:%M');
$plot->TuneXAutoTicks(10, 'date');
// $plot->SetXTickIncrement(.5);
//$plot->SetXTickIncrement(60 * 24);
$plot->SetPlotType('lines');
//$plot->SetPlotAreaWorld(strtotime('00:00'), null, strtotime('23:59'), null);
$plot->SetDrawXGrid(true);
//Draw it
$plot->DrawGraph();
}
示例4: renderLot
public function renderLot()
{
$grafico = new PHPlot(800, 600);
$grafico->SetFileFormat("jpg");
$grafico->SetIsInline(True);
#Indicamos o títul do gráfico e o título dos dados no eixo X e Y do mesmo
$grafico->SetTitle($this->data->titulo);
$grafico->SetXTitle($this->data->eixoX);
$grafico->SetYTitle($this->data->eixoY);
#passamos o tipo de gráfico escolhido
if (!$this->data->tipoLot) {
$this->data->tipoLot = 'bars';
}
$grafico->SetPlotType($this->data->tipoLot);
switch ($this->data->tipoLot) {
case 'pie':
$grafico->SetPieLabelType('index', 'custom', 'mycallback');
$grafico->SetDataType('text-data-single');
break;
case 'stackedbars':
$grafico->SetDataType('text-data-yx');
break;
case 'bubbles':
$grafico->SetDataType('data-data-xyz');
break;
}
$grafico->SetLegend($column_names);
#Definimos os dados do gráfico
switch ($this->data->tipoLot) {
case 'pie':
$dados = array(array($this->data->x1, $this->data->y11), array($this->data->x2, $this->data->y21), array($this->data->x3, $this->data->y31), array($this->data->x4, $this->data->y41));
break;
default:
$dados = array(array($this->data->x1, $this->data->y11, $this->data->y12, $this->data->y13), array($this->data->x2, $this->data->y21, $this->data->y22, $this->data->y23), array($this->data->x3, $this->data->y31, $this->data->y32, $this->data->y33), array($this->data->x4, $this->data->y41, $this->data->y42, $this->data->y43));
break;
}
$grafico->SetDataValues($dados);
#Salvamos o gráfico
$caminho = \Manager::getFilesPath();
$fileName = uniqid() . '.jpg';
$grafico->SetOutputFile($caminho . '/' . $fileName);
$grafico->SetIsInline(True);
$grafico->DrawGraph();
#obtemos o endereco do grafico
$this->data->locate = \Manager::getDownloadURL('files', basename($fileName), true);
}
示例5: doGet
public function doGet(WebAppRequest $req, WebAppResponse $res)
{
// Bootstraps Innomatic
require_once 'innomatic/core/InnomaticContainer.php';
$innomatic = InnomaticContainer::instance('innomaticcontainer');
// Sets Innomatic base URL
$baseUrl = '';
$webAppPath = $req->getUrlPath();
if (!is_null($webAppPath) && $webAppPath != '/') {
$baseUrl = $req->generateControllerPath($webAppPath, true);
}
$innomatic->setBaseUrl($baseUrl);
$innomatic->setInterface(InnomaticContainer::INTERFACE_WEB);
$home = WebAppContainer::instance('webappcontainer')->getCurrentWebApp()->getHome();
$innomatic->bootstrap($home, $home . 'core/conf/innomatic.ini');
$id = basename($req->getParameter('id'));
//$id = basename($_GET['id']);
$args = unserialize(file_get_contents(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id));
require_once 'phplot/PHPlot.php';
$graph = new PHPlot($args['width'], $args['height']);
$graph->SetIsInline('1');
//$graph->SetDataColors( array("blue",'white'),array("black") );
//$graph->$line_style = array('dashed','dashed','solid','dashed','dashed','solid');
// Base
$graph->SetDataValues($args['data']);
$graph->SetPlotType($args['plottype']);
// Appearance
$graph->SetPointShape($args['pointshape']);
$graph->SetPointSize($args['pointsize']);
$graph->SetTitle($args['title']);
// Color
$graph->SetBackgroundColor($args['backgroundcolor']);
$graph->SetGridColor($args['gridcolor']);
if (count($args['legend'])) {
$graph->SetLegend($args['legend']);
}
$graph->SetLineWidth($args['linewidth']);
$graph->SetTextColor($args['textcolor']);
$graph->SetDataColors(array(array(145, 165, 207), array(114, 167, 112), array(71, 85, 159), array(175, 83, 50), array(247, 148, 53), array(240, 231, 125), array(154, 204, 203), array(201, 164, 196)), 'black');
//$graph->data_color = array( array(145,165,207), array(114,167,112), array(71,85,159), array(175,83,50), array(247,148,53), array(240,231,125), array(154,204,203), array(201,164,196) );
//array('blue','green','yellow','red','orange');
$graph->DrawGraph();
unlink(InnomaticContainer::instance('innomaticcontainer')->getHome() . 'core/temp/phplot/' . $id);
}
示例6: testBars
function testBars()
{
# PHPlot Example: Bar chart, 3 data sets, unshaded
$data = array(array('Jan', 40, 2, 4), array('Feb', 30, 3, 4), array('Mar', 20, 4, 4), array('Apr', 10, 5, 4), array('May', 3, 6, 4), array('Jun', 7, 7, 4), array('Jul', 10, 8, 4), array('Aug', 15, 9, 4), array('Sep', 20, 5, 4), array('Oct', 18, 4, 4), array('Nov', 16, 7, 4), array('Dec', 14, 3, 4));
$plot = new PHPlot(800, 600);
$plot->SetIsInline(true);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Unshaded Bar Chart with 3 Data Sets');
# No 3-D shading of the bars:
$plot->SetShading(0);
# Make a legend for the 3 data sets plotted:
$plot->SetLegend(array('Engineering', 'Manufacturing', 'Administration'));
# Turn off X tick labels and ticks because they don't apply here:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();
}
示例7: make_plot
function make_plot($plot_type, $data_type, $nx, $ny)
{
$plot = new PHPlot(1280, 1024);
$plot->SetPrintImage(False);
$plot->SetFailureImage(False);
$plot->SetDataType($data_type);
$plot->SetDataValues(make_data_array($plot_type, $data_type, $nx, $ny, 100));
$plot->SetPlotType($plot_type);
$plot->SetTitle("Serialize/Unserialize Tests\n{$plot_type} - {$data_type}");
$plot->SetXTickIncrement(5);
$plot->SetYTickIncrement(10);
$plot->SetPlotBorderType('full');
$plot->SetDrawXGrid(True);
$plot->SetDrawYGrid(True);
$plot->SetXTitle('X Axis Title');
$plot->SetYTitle('Y Axis Title');
# Select data labels or tick labels based on data type:
if ($data_type == 'data-data') {
$plot->SetXDataLabelPos('none');
$plot->SetXTickLabelPos('plotdown');
$plot->SetXTickPos('plotdown');
} elseif ($data_type == 'text-data') {
$plot->SetXDataLabelPos('plotdown');
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
} elseif ($data_type == 'data-data-yx') {
$plot->SetYDataLabelPos('none');
$plot->SetYTickLabelPos('plotleft');
$plot->SetYTickPos('plotleft');
} elseif ($data_type == 'text-data-yx') {
$plot->SetYDataLabelPos('plotleft');
$plot->SetYTickLabelPos('none');
$plot->SetYTickPos('none');
}
return $plot;
}
示例8: array
}
if (count($data_array) < 2) {
//don't bother trying to make a graph, if no users.
exit;
}
//Set some data
if ($graph_type == 1) {
//text-data (no time)
$example_data = array($data_array, $data_array);
} else {
//data-data (any extra entries are time).
$example_data = array($data_array);
}
$graph->SetDataValues($example_data);
//Error_Reporting(0);
$graph->SetPlotType($graph_type_str);
$graph->SetLabelScalePosition(1.27);
$graph->SetLegend($legend_array);
if ($graph_type == 2) {
$graph->SetYLabel($element);
$graph->SetXLabel($cw['users']);
} else {
$graph->SetLegendPixels(1, 1, "");
}
//$graph->SetTitle("$element per user");
//Draw it
$graph->DrawGraph();
//list things to change on the graph
} else {
print_header($cw['graphs']);
if (isset($graph_selected) && $graph_selected == 1) {
示例9: PHPlot
include "../phplot.php";
$graph = new PHPlot(600, 400);
$graph->SetPrintImage(0);
//Don't draw the image yet
$graph->SetDataType("data-data-error");
//Must be called before SetDataValues
$graph->SetNewPlotAreaPixels(90, 40, 540, 190);
$graph->SetDataValues($example_data);
$graph->SetXGridLabelType("time");
$graph->SetXDataLabelAngle(90);
$graph->SetXLabel("");
$graph->SetYLabel("Price");
$graph->SetVertTickIncrement(20);
$graph->SetHorizTickIncrement(2679000);
$graph->SetXTimeFormat("%b %y");
$graph->SetPlotType("lines");
$graph->SetErrorBarShape("line");
$graph->SetPointShape("halfline");
$graph->SetYScaleType("log");
$graph->SetLineWidth(1);
$graph->SetPlotAreaWorld(883634400, 1, 915095000, 140);
$graph->DrawGraph();
//Now do the second chart on the image
unset($example_data);
$graph->SetPrintImage(1);
//Now draw the image
$graph->SetYScaleType("linear");
include "./data_date.php";
$graph->SetDataType("data-data");
//Must be called before SetDataValues
$graph->SetDataValues($example_data);
示例10: array
# PHPlot / contrib / color_range : Example
# $Id$
# This is a bar chart with a color gradient for the bars in each group.
require_once 'phplot.php';
require_once 'color_range.php';
$bars_per_group = 10;
$x_values = 4;
mt_srand(1);
$data = array();
for ($i = 0; $i < $x_values; $i++) {
$row = array($i);
for ($j = 0; $j < $bars_per_group; $j++) {
$row[] = mt_rand(0, 100);
}
$data[] = $row;
}
$p = new PHPlot(800, 600);
$p->SetTitle('Example - Bar Chart with gradient colors');
$p->SetDataType('text-data');
$p->SetDataValues($data);
$p->SetPlotAreaWorld(0, 0, $x_values, 100);
# This isn't necessary, as we do know how many data sets (bars_per_group):
$n_data = count_data_sets($data, 'text-data');
# Make a gradient color map:
$colors = color_range($p->SetRGBColor('SkyBlue'), $p->SetRGBColor('DarkGreen'), $n_data);
$p->SetDataColors($colors);
$p->SetXTickLabelPos('none');
$p->SetXTickPos('none');
$p->SetPlotType('bars');
$p->DrawGraph();
示例11: fgetcsv
}
// Read and check the file header.
$row = fgetcsv($f);
if ($row === FALSE || $row[0] != 'Date' || $row[1] != 'Open' || $row[2] != 'High' || $row[3] != 'Low' || $row[4] != 'Close') {
fwrite(STDERR, "Incorrect header in: {$filename}\n");
return FALSE;
}
// Read the rest of the file and convert.
while ($d = fgetcsv($f)) {
$data[] = array('', strtotime($d[0]), $d[1], $d[2], $d[3], $d[4]);
}
fclose($f);
return $data;
}
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetTitle("Candlesticks Financial Plot (data-data)\nMSFT Q1 2009");
$plot->SetDataType('data-data');
$plot->SetDataValues(read_prices_data_data(DATAFILE));
$plot->SetPlotType('candlesticks');
$plot->SetDataColors(array('SlateBlue', 'black', 'SlateBlue', 'black'));
$plot->SetXLabelAngle(90);
$plot->SetXLabelType('time', '%Y-%m-%d');
$plot->SetXTickIncrement(7 * 24 * 60 * 60);
// 1 week interval
if (method_exists($plot, 'TuneYAutoRange')) {
$plot->TuneYAutoRange(0);
}
// Suppress Y zero magnet (PHPlot >= 6.0.0)
$plot->DrawGraph();
示例12: array
<?php
# PHPlot Example: Linepoints plot with Data Value Labels
require_once 'phplot.php';
$data = array(array('1995', 135), array('1996', ''), array('1997', ''), array('1998', ''), array('1999', ''), array('2000', 225), array('2001', ''), array('2002', ''), array('2003', 456), array('2004', 420), array('2005', 373), array('2006', 300), array('2007', 255), array('2008', 283));
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
// Improves presentation in the manual
$plot->SetPlotType('linepoints');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetTitle("US Federal Emergency Food Assistance, 1995 - 2008\n" . "(in \$ millions)");
# Turn on Y data labels:
$plot->SetYDataLabelPos('plotin');
# Turn on X data label lines (drawn from X axis up to data point):
$plot->SetDrawXDataLabelLines(True);
# With Y data labels, we don't need Y ticks, Y tick labels, or grid lines.
$plot->SetYTickLabelPos('none');
$plot->SetYTickPos('none');
$plot->SetDrawYGrid(False);
# X tick marks are meaningless with this data:
$plot->SetXTickPos('none');
$plot->SetXTickLabelPos('none');
$plot->DrawGraph();
示例13: array
<?php
include DIR_WS_CLASSES . 'phplot.php';
$stats = array();
$banner_stats_query = tep_db_query("select dayofmonth(banners_history_date) as name, banners_shown as value, banners_clicked as dvalue from " . TABLE_BANNERS_HISTORY . " where banners_id = '" . $banner_id . "' and to_days(now()) - to_days(banners_history_date) < " . $days . " order by banners_history_date");
while ($banner_stats = tep_db_fetch_array($banner_stats_query)) {
$stats[] = array($banner_stats['name'], $banner_stats['value'], $banner_stats['dvalue']);
}
if (sizeof($stats) < 1) {
$stats = array(array(date('j'), 0, 0));
}
$graph = new PHPlot(200, 220, 'images/graphs/banner_infobox-' . $banner_id . '.' . $banner_extension);
$graph->SetFileFormat($banner_extension);
$graph->SetIsInline(1);
$graph->SetPrintImage(0);
$graph->draw_vert_ticks = 0;
$graph->SetSkipBottomTick(1);
$graph->SetDrawXDataLabels(0);
$graph->SetDrawYGrid(0);
$graph->SetPlotType('bars');
$graph->SetDrawDataLabels(1);
$graph->SetLabelScalePosition(1);
$graph->SetMarginsPixels(15, 15, 15, 30);
$graph->SetTitleFontSize('4');
$graph->SetTitle('TEXT_BANNERS_LAST_3_DAYS');
$graph->SetDataValues($stats);
$graph->SetDataColors(array('blue', 'red'), array('blue', 'red'));
$graph->DrawGraph();
$graph->PrintImage();
示例14: PHPlot
}
////////////////////////////////////////////////
//Required Settings
include "../phplot.php";
$graph = new PHPlot($xsize_in, $ysize_in);
$graph->SetDataType($which_data_type);
// Must be first thing
$graph->SetDataValues($data);
//Optional Settings (Don't need them)
// $graph->SetTitle("This is a\n\rmultiple line title\n\rspanning three lines.");
$graph->SetTitle($title);
$graph->SetXTitle($xlbl, $which_xtitle_pos);
$graph->SetYTitle($ylbl, $which_ytitle_pos);
$graph->SetLegend(array("A", "Bee", "Cee", "Dee"));
$graph->SetFileFormat($which_fileformat);
$graph->SetPlotType($which_plot_type);
$graph->SetUseTTF($which_use_ttf);
$graph->SetYTickIncrement($which_yti);
$graph->SetXTickIncrement($which_xti);
$graph->SetXTickLength($which_xtl);
$graph->SetYTickLength($which_ytl);
$graph->SetXTickCrossing($which_xtc);
$graph->SetYTickCrossing($which_ytc);
$graph->SetXTickPos($which_xtick_pos);
$graph->SetYTickPos($which_ytick_pos);
$graph->SetShading($which_shading);
$graph->SetLineWidth($which_line_width);
$graph->SetErrorBarLineWidth($which_errorbar_line_width);
$graph->SetDrawDashedGrid($which_dashed_grid);
switch ($which_draw_grid) {
case 'x':
示例15: array
<?php
# $Id$
# Test: Stacked area
require_once 'phplot.php';
# This is based on area1 with adjusted numbers.
$data = array(array('1960', 30, 10, 6, 38, 14, 2), array('1970', 20, 17, 9, 32, 2, 20), array('1980', 20, 14, 12, 27, 2, 25), array('1990', 5, 26, 15, 26, 18, 10), array('2000', 28, 0, 18, 16, 33, 5));
$plot = new PHPlot(800, 600);
$plot->SetPlotType('stackedarea');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
$plot->SetTitle('Candy Sales by Flavor');
$plot->SetPlotAreaWorld(NULL, 0, NULL, 110);
$plot->SetYTickIncrement(10);
$plot->SetYTitle('% of Total');
$plot->SetXTitle('Year');
$plot->SetDataColors(array('red', 'green', 'blue', 'yellow', 'cyan', 'magenta'));
$plot->SetLegend(array('Cherry', 'Lime', 'Lemon', 'Banana', 'Apple', 'Berry'));
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
$plot->DrawGraph();