本文整理汇总了PHP中PHPlot::SetDataValues方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPlot::SetDataValues方法的具体用法?PHP PHPlot::SetDataValues怎么用?PHP PHPlot::SetDataValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPlot
的用法示例。
在下文中一共展示了PHPlot::SetDataValues方法的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: 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);
}
示例5: 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();
}
示例6: 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;
}
示例7: eval
eval("\$data[\$i] = \$data_row{$i}; ");
}
} else {
foreach ($data_row0 as $key => $val) {
$data[$key] = array($data_row0[$key], $data_row1[$key], $data_row2[$key], $data_row3[$key], $data_row4[$key]);
}
}
}
}
////////////////////////////////////////////////
//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);
示例8: PHPlot
$allDaysKey++;
//print"<font color=red>$prevDay=$mkday</font><br>";
}
$prevDay = $mkday;
$prevDOfMonth = $DayOfMonth;
}
if ($debug) {
print_r($allDays);
}
if ($debug) {
print "I" . $maxValue . "I";
}
include "../include/phplot/phplot.php";
$graph = new PHPlot(600, 300);
$graph->SetDataType("text-data");
$graph->SetDataValues($allDays);
$graph->SetYTickIncrement();
$graph->y_tick_increment = ceil(@$graph->y_tick_increment);
$graph->SetXLabelType("time");
$graph->SetXTimeFormat("%b %d");
if ($incoming == '2') {
$graph->SetLegend(array("Outgoing"));
$graph->SetDataColors(array('green'));
} elseif ($incoming == '3') {
$graph->SetLegend(array("Incoming"));
$graph->SetDataColors(array('orange'));
} else {
$graph->SetLegend(array("All", "Outgoing", "Incoming"));
}
$graph->SetYTitle("Quantity of calls");
$graph->SetPlotType("bars");
示例9: draw
/**
* Adds raw image data of the graph to the output.
* @param $opts FormOptions
*/
public function draw( FormOptions $opts ) {
global $wgTranslatePHPlotFont, $wgLang;
$width = $opts->getValue( 'width' );
$height = $opts->getValue( 'height' );
// Define the object
$plot = new PHPlot( $width, $height );
list( $legend, $resData ) = $this->getData( $opts );
$count = count( $resData );
$skip = intval( $count / ( $width / 60 ) - 1 );
$i = $count;
foreach ( $resData as $date => $edits ) {
if ( $skip > 0 ) {
if ( ( $count - $i ) % $skip !== 0 ) $date = '';
}
if ( strpos( $date, ';' ) !== false ) {
list( , $date ) = explode( ';', $date, 2 );
}
array_unshift( $edits, $date );
$data[] = $edits;
$i--;
}
$font = FCFontFinder::find( $wgLang->getCode() );
if ( $font ) {
$plot->SetDefaultTTFont( $font );
} else {
$plot->SetDefaultTTFont( $wgTranslatePHPlotFont );
}
$plot->SetDataValues( $data );
if ( $legend !== null ) {
$plot->SetLegend( $legend );
}
$numberFont = FCFontFinder::find( 'en' );
$plot->setFont( 'x_label', $numberFont, 8 );
$plot->setFont( 'y_label', $numberFont, 8 );
$yTitle = wfMsg( 'translate-stats-' . $opts['count'] );
// Turn off X axis ticks and labels because they get in the way:
$plot->SetYTitle( $yTitle );
$plot->SetXTickLabelPos( 'none' );
$plot->SetXTickPos( 'none' );
$plot->SetXLabelAngle( 45 );
$max = max( array_map( 'max', $resData ) );
$max = self::roundToSignificant( $max, 1 );
$max = round( $max, intval( -log( $max, 10 ) ) );
$yTick = 10;
while ( $max / $yTick > $height / 20 ) {
$yTick *= 2;
}
// If we have very small case, ensure that there is at least one tick
$yTick = min( $max, $yTick );
$yTick = self::roundToSignificant( $yTick );
$plot->SetYTickIncrement( $yTick );
$plot->SetPlotAreaWorld( null, 0, null, $max );
$plot->SetTransparentColor( 'white' );
$plot->SetBackgroundColor( 'white' );
// Draw it
$plot->DrawGraph();
}
示例10: Title
$plot->SetFontTTF('x_title', $font, 14);
$plot->SetFontTTF('y_title', $font, 10);
# Disable auto-output:
$plot->SetPrintImage(0);
$title = "Test {$n_plots} Plots with TTF Title (sequence {$title_sequence})";
$y1 = $title_space;
// Top of plot area
for ($i = 0; $i < $n_plots; $i++) {
if ($i == $title_sequence) {
$plot->SetTitle($title);
}
$y2 = $y1 + $height_of_each_plot;
// Bottom of plot area
# fwrite(STDERR, "Plot $i area: min=(80, $y1) : max=(740, $y2)\n");
$plot->SetPlotAreaPixels(80, $y1, 740, $y2);
$plot->SetDataType('text-data');
$plot->SetDataValues($report[$i]);
$plot->SetPlotAreaWorld(NULL, 0, NULL, $max_x);
$plot->SetDataColors(array('blue'));
$plot->SetXTickLabelPos('none');
$plot->SetXDataLabelPos('plotdown');
$plot->SetXTickPos('plotdown');
$plot->SetYTickIncrement(1);
$plot->SetXTitle("Chart {$i} X Values");
$plot->SetYTitle("Chart {$i} Y Values");
$plot->SetPlotType('bars');
$plot->DrawGraph();
$y1 = $y2 + $space_below_plots;
// Start next plot below last plot
}
$plot->PrintImage();
示例11: array
$cumulateddata = array();
$max = 1;
foreach ($stats->getTimestats($term, $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['settings']['searchtermselectmonthcount']) as $month) {
$bardata[] = array(date('M', mktime(0, 0, 0, $month['m'], 1, 2010)) . "\n" . $month['count'], $month['count']);
if ($month['count'] > $max) {
$max = $month['count'];
}
}
$title = $I18N->Msg('a587_stats_searchterm_timestats_title', empty($term) ? $I18N->Msg('a587_stats_searchterm_timestats_title0_all') : $I18N->Msg('a587_stats_searchterm_timestats_title0_single', $term), intval($_GET['monthcount']));
if (rex_lang_is_utf8()) {
$title = utf8_decode($title);
}
// draw bars
$plot = new PHPlot(700, 240);
$plot->SetImageBorderType('none');
$plot->SetTransparentColor('white');
$plot->SetMarginsPixels(NULL, NULL, 26, NULL);
# Make sure Y axis starts at 0:
$plot->SetPlotAreaWorld(NULL, 0, NULL, NULL);
$len = strlen('' . $max);
$plot->SetYTickIncrement(max(1, ceil($max / pow(10, $len - 1)) * pow(10, $len - 2)));
# Main plot title:
$plot->SetTitle($title);
$plot->SetFont('title', 3);
// draw bars
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($bardata);
$plot->SetDataColors(array('#14568a', '#2c8ce0', '#dfe9e9'));
$plot->SetShading(ceil(48 / $REX['ADDON']['rexsearch_plugins'][$parent][$mypage]['settings']['searchtermselectmonthcount']));
$plot->DrawGraph();
示例12: PHPlot
<?php
//Include the code
include "../phplot.php";
//Define the object
$graph = new PHPlot();
//Define some data
include "./data.php";
$graph->SetDataValues($example_data);
//Don't print until we say so
$graph->SetPrintImage(0);
//Draw it
$graph->DrawGraph();
//Define some colors
$ndx_color = $graph->SetIndexColor("blue");
$ndx_color1 = $graph->SetIndexColor("orange");
//The image data colors are now ndx_data_color[]
$graph->DrawDashedLine(250, $graph->plot_area[1], 250, 250, 4, 0, $graph->ndx_data_color[0]);
$graph->DrawDashedLine($graph->xtr(5), $graph->ytr(12), $graph->xtr(20), $graph->ytr(42), 5, 3, $ndx_color);
$graph->DrawDashedLine($graph->plot_area[0], 250, $graph->plot_area[2], 250, 2, 0, $ndx_color1);
$graph->DrawDashedLine($graph->plot_area[0], 251, $graph->plot_area[2], 251, 2, 0, $ndx_color1);
//Now print the image
$graph->PrintImage();
示例13: array
<?php
# $Id$
# Testing PHPlot - Bad data range with SetPlotAreaWorld - baseline/master
# Other scripts set $spaw and $subtitle and then include this script.
require 'phplot.php';
if (empty($spaw)) {
$spaw = array(20, 20, 200, 200);
}
// Args to SetPlotAreaWorld
if (empty($subtitle)) {
$subtitle = 'Baseline(no error)';
}
// Subtitle for plot
$plot = new PHPlot();
$plot->SetTitle("SetPlotAreaWorld(" . implode(', ', $spaw) . ")\n{$subtitle}");
$plot->SetDataType('data-data');
$plot->SetDataValues(array(array('', 25, 25), array('', 195, 195)));
$plot->SetPlotType('lines');
call_user_func_array(array($plot, 'SetPlotAreaWorld'), $spaw);
$plot->DrawGraph();
示例14: PHPlot
<?php
# $Id$
# From: PHPlot Quickstart - 1
//Include the code
require_once 'phplot.php';
//Define the object
$plot = new PHPlot();
//Define some data
$example_data = array(array('a', 3), array('b', 5), array('c', 7), array('d', 8), array('e', 2), array('f', 6), array('g', 7));
$plot->SetDataValues($example_data);
//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
//Draw it
$plot->DrawGraph();
示例15: 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);
}