本文整理汇总了PHP中ezcGraphLineChart类的典型用法代码示例。如果您正苦于以下问题:PHP ezcGraphLineChart类的具体用法?PHP ezcGraphLineChart怎么用?PHP ezcGraphLineChart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ezcGraphLineChart类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetFontForElementWithRendering
public function testSetFontForElementWithRendering()
{
$chart = new ezcGraphLineChart();
$chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
$chart->options->font->path = $this->basePath . 'font.ttf';
$chart->legend->font->path = $this->basePath . 'font2.ttf';
$chart->render(500, 200);
$this->assertEquals($this->basePath . 'font.ttf', $chart->options->font->path, 'General font face should be the old one.');
$this->assertEquals($this->basePath . 'font.ttf', $chart->title->font->path, 'Font face for X axis should be the old one.');
$this->assertTrue($chart->legend->font instanceof ezcGraphFontOptions, 'No fontOptions object was created.');
$this->assertEquals($this->basePath . 'font2.ttf', $chart->legend->font->path, 'Font face for legend has not changed.');
}
示例2: testRenderTextTopMargin
public function testRenderTextTopMargin()
{
$chart = new ezcGraphLineChart();
$chart->data['sample'] = new ezcGraphArrayDataSet(array('foo' => 1, 'bar' => 10));
$chart->title = 'Title of a chart';
$chart->title->position = ezcGraph::TOP;
$chart->title->margin = 5;
$mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawText'));
// Y-Axis
$mockedRenderer->expects($this->at(0))->method('drawText')->with($this->equalTo(new ezcGraphBoundings(6, 6, 494, 14)), $this->equalTo('Title of a chart'), $this->equalTo(ezcGraph::CENTER | ezcGraph::MIDDLE));
$chart->renderer = $mockedRenderer;
$chart->render(500, 200);
}
示例3: testAxisSpaceConfiguration
/**
* @dataProvider getAxisConfiguration
*/
public function testAxisSpaceConfiguration(ezcGraphAxisLabelRenderer $xRenderer, ezcGraphAxisLabelRenderer $yRenderer, $xSpace, $ySpace, $outerSpace, $xAlign, $yAlign)
{
$filename = $this->tempDir . __FUNCTION__ . '_' . self::$i . '.svg';
$chart = new ezcGraphLineChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->xAxis->axisLabelRenderer = $xRenderer;
$chart->xAxis->axisSpace = $xSpace;
$chart->xAxis->outerAxisSpace = $outerSpace;
$chart->xAxis->position = $xAlign;
$chart->yAxis->axisLabelRenderer = $yRenderer;
$chart->yAxis->axisSpace = $ySpace;
$chart->yAxis->outerAxisSpace = $outerSpace;
$chart->yAxis->position = $yAlign;
$chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 250, 'sample 2' => 250, 'sample 3' => 0, 'sample 4' => 0, 'sample 5' => 500, 'sample 6' => 500));
$chart->render(560, 250, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '_' . self::$i . '.svg');
}
示例4: ezcGraphLineChart
<?php
require_once 'tutorial_insert_data.php';
// Receive data from database
$db = ezcDbInstance::get();
$query = $db->createSelectQuery();
$query->select('hits')->from('browser_hits');
$statement = $query->prepare();
$statement->execute();
// Create chart from data
$chart = new ezcGraphLineChart();
$chart->title = 'Browser statistics';
$chart->options->fillLines = 220;
$chart->data['browsers'] = new ezcGraphDatabaseDataSet($statement);
$chart->data['average'] = new ezcGraphDataSetAveragePolynom($chart->data['browsers']);
$chart->render(400, 150, 'tutorial_single.svg');
示例5: testStrToTimeLabelConvertionRendering
public function testStrToTimeLabelConvertionRendering()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$chart = new ezcGraphLineChart();
$chart->data['some data'] = new ezcGraphArrayDataSet(array('1.1.2001' => 12, '1.1.2002' => 324, '1.1.2003' => 238, '1.1.2004' => 123));
$chart->data['some data']->symbol = ezcGraph::DIAMOND;
$chart->render(500, 200, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例6: testRenderCompleteLineChart2
public function testRenderCompleteLineChart2()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$chart = new ezcGraphLineChart();
date_default_timezone_set('MET');
$chart->data['Statistical data'] = new ezcGraphArrayDataSet(array('Jun 2006' => 1300000, 'May 2006' => 1200000, 'Apr 2006' => 1100000, 'Mar 2006' => 1100000, 'Feb 2006' => 1000000, 'Jan 2006' => 965000));
$chart->data['Statistical data']->symbol = ezcGraph::BULLET;
$chart->data['polynom order 2'] = new ezcGraphDataSetAveragePolynom($chart->data['Statistical data'], 2);
$chart->xAxis = new ezcGraphChartElementNumericAxis();
try {
$chart->render(500, 200, $filename);
} catch (ezcGraphDatasetAverageInvalidKeysException $e) {
return true;
}
$this->fail('Expected ezcGraphDatasetAverageInvalidKeysException.');
}
示例7: testRenderCompleteLineChart
public function testRenderCompleteLineChart()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$chart = new ezcGraphLineChart();
$chart->data['Sinus'] = new ezcGraphNumericDataSet(-180, 180, create_function('$x', 'return 10 * sin( deg2rad( $x ) );'));
$chart->data['Cosinus'] = new ezcGraphNumericDataSet(-180, 180, create_function('$x', 'return 5 * cos( deg2rad( $x ) );'));
$chart->xAxis = new ezcGraphChartElementNumericAxis();
$chart->render(500, 200, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例8: graph_bydate
function graph_bydate($p_metrics, $p_labels, $p_title, $p_graph_width = 300, $p_graph_height = 380)
{
$t_graph_font = graph_get_font();
error_check(is_array($p_metrics) ? count($p_metrics) : 0, lang_get('by_date'));
if (plugin_config_get('eczlibrary') == ON) {
$t_metrics = array();
$t_dates = array_shift($p_metrics);
//[0];
$t_cnt = count($p_metrics);
foreach ($t_dates as $i => $val) {
//$t_metrics[$val]
for ($j = 0; $j < $t_cnt; $j++) {
$t_metrics[$j][$val] = $p_metrics[$j][$i];
}
}
$graph = new ezcGraphLineChart();
$graph->background->color = '#FFFFFF';
$graph->xAxis = new ezcGraphChartElementNumericAxis();
for ($k = 0; $k < $t_cnt; $k++) {
$graph->data[$k] = new ezcGraphArrayDataSet($t_metrics[$k]);
$graph->data[$k]->label = $p_labels[$k + 1];
}
$graph->xAxis->labelCallback = 'graph_date_format';
$graph->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
$graph->xAxis->axisLabelRenderer->angle = -45;
$graph->legend->position = ezcGraph::BOTTOM;
$graph->legend->background = '#FFFFFF80';
$graph->driver = new ezcGraphGdDriver();
//$graph->driver->options->supersampling = 1;
$graph->driver->options->jpegQuality = 100;
$graph->driver->options->imageFormat = IMG_JPEG;
$graph->title = $p_title . ' ' . lang_get('by_date');
$graph->options->font = $t_graph_font;
$graph->renderToOutput($p_graph_width, $p_graph_height);
} else {
$graph = new Graph($p_graph_width, $p_graph_height);
$graph->img->SetMargin(40, 140, 40, 100);
if (ON == plugin_config_get('jpgraph_antialias')) {
$graph->img->SetAntiAliasing();
}
$graph->SetScale('linlin');
$graph->SetMarginColor('white');
$graph->SetFrame(false);
$graph->title->Set($p_title . ' ' . lang_get('by_date'));
$graph->title->SetFont($t_graph_font, FS_BOLD);
$graph->legend->Pos(0.01, 0.05, 'right', 'top');
$graph->legend->SetShadow(false);
$graph->legend->SetFillColor('white');
$graph->legend->SetLayout(LEGEND_VERT);
$graph->legend->SetFont($t_graph_font);
$graph->yaxis->scale->ticks->SetDirection(-1);
$graph->yaxis->SetFont($t_graph_font);
$graph->yaxis->scale->SetAutoMin(0);
if (FF_FONT2 <= $t_graph_font) {
$graph->xaxis->SetLabelAngle(60);
} else {
$graph->xaxis->SetLabelAngle(90);
# can't rotate non truetype fonts
}
$graph->xaxis->SetLabelFormatCallback('graph_date_format');
$graph->xaxis->SetFont($t_graph_font);
/* $t_line_colours = plugin_config_get( 'jpgraph_colors' );
$t_count_colours = count( $t_line_colours );*/
$t_lines = count($p_metrics) - 1;
$t_line = array();
for ($i = 1; $i <= $t_lines; $i++) {
$t_line[$i] = new LinePlot($p_metrics[$i], $p_metrics[0]);
//$t_line[$i]->SetColor( $t_line_colours[$i % $t_count_colours] );
$t_line[$i]->SetCenter();
$t_line[$i]->SetLegend($p_labels[$i]);
$graph->Add($t_line[$i]);
}
if (helper_show_query_count()) {
$graph->subtitle->Set(db_count_queries() . ' queries (' . db_time_queries() . 'sec)');
$graph->subtitle->SetFont($t_graph_font, FS_NORMAL, 8);
}
$graph->Stroke();
}
}
示例9: testRotatedAxisLabel
public function testRotatedAxisLabel()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$graph = new ezcGraphLineChart();
$graph->palette = new ezcGraphPaletteBlack();
$graph->data['sample1'] = new ezcGraphArrayDataSet(array(1, 4, 6, 8, 2));
$graph->data['sample1']->symbol = ezcGraph::SQUARE;
$graph->data['sample2'] = new ezcGraphArrayDataSet(array(4, 6, 8, 2, 1));
$graph->data['sample2']->symbol = ezcGraph::BOX;
$graph->xAxis->label = "Some axis label";
$graph->xAxis->labelRotation = 90;
$graph->render(560, 250, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例10: testReRenderChart
public function testReRenderChart()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$barChart = new ezcGraphLineChart();
$barChart->data['test'] = new ezcGraphArrayDataSet(array(5, 23, 42));
$color = $barChart->data['test']->color->default;
$barChart->render(400, 200, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
// Render a second time with a new dataset, and expect the same result
$barChart->data['test'] = new ezcGraphArrayDataSet(array(5, 23, 42));
$barChart->data['test']->color = $color;
$barChart->render(400, 200, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例11: testRenderWithZeroAxisSpace
public function testRenderWithZeroAxisSpace()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$labelCount = 20;
$data = $this->getRandomData($labelCount, 500, 2000, 23);
$chart = new ezcGraphLineChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->data['sample'] = new ezcGraphArrayDataSet($data);
// Set manual label count
$chart->xAxis->labelCount = 21;
$chart->xAxis->axisLabelRenderer = new ezcGraphAxisRotatedLabelRenderer();
$chart->xAxis->axisLabelRenderer->angle = 45;
$chart->xAxis->axisSpace = 0.1;
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart->yAxis->axisSpace = 0;
$chart->render(500, 200, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例12: testShortAxis
public function testShortAxis()
{
$filename = $this->tempDir . __FUNCTION__ . '.svg';
$graph = new ezcGraphLineChart();
$graph->palette = new ezcGraphPaletteBlack();
$graph->legend->position = ezcGraph::BOTTOM;
$graph->data['sample'] = new ezcGraphArrayDataSet(array(1, 4, 6, 8, 2));
$graph->renderer = new ezcGraphRenderer3d();
$graph->renderer->options->axisEndStyle = ezcGraph::NO_SYMBOL;
$graph->renderer->options->shortAxis = true;
$graph->render(560, 250, $filename);
$this->compare($filename, $this->basePath . 'compare/' . __CLASS__ . '_' . __FUNCTION__ . '.svg');
}
示例13: header
<?php
require 'ezc-setup.php';
header('Content-Type: image/svg+xml');
list($domains, $ips) = (require 'data-graph1.php');
$chart = new ezcGraphLineChart();
$chart->title = 'PHP Usage Statistics';
$chart->palette = new ezcGraphPaletteTango();
$chart->options->fillLines = 230;
$chart->legend->title = "Legend";
$chart->xAxis->font->maxFontSize = 12;
$chart->yAxis->font->maxFontSize = 12;
$chart->title->font->maxFontSize = 20;
$chart->data['domains'] = new ezcGraphArrayDataSet($domains);
$chart->data['domains']->label = 'Domains';
$chart->data['ips'] = new ezcGraphArrayDataSet($ips);
$chart->data['ips']->label = 'IP addresses';
$chart->driver = new ezcGraphSvgDriver();
$chart->render(600, 400, 'php://output');
示例14: ezcGraphLineChart
<?php
require_once 'tutorial_autoload.php';
$wikidata = (include 'tutorial_wikipedia_data.php');
$graph = new ezcGraphLineChart();
$graph->title = 'Wikipedia articles';
// Add data
foreach ($wikidata as $language => $data) {
$graph->data[$language] = new ezcGraphArrayDataSet($data);
}
$graph->yAxis->min = 0;
// Use a different axis for the norwegian dataset
$graph->additionalAxis['norwegian'] = $nAxis = new ezcGraphChartElementNumericAxis();
$nAxis->position = ezcGraph::BOTTOM;
$nAxis->chartPosition = 1;
$nAxis->min = 0;
$graph->data['Norwegian']->yAxis = $nAxis;
// Still use the marker
$graph->additionalAxis['border'] = $marker = new ezcGraphChartElementNumericAxis();
$marker->position = ezcGraph::LEFT;
$marker->chartPosition = 1 / 3;
$graph->render(400, 150, 'tutorial_line_chart_additional_axis.svg');
示例15: testRenderTextBoxesFromBottom
public function testRenderTextBoxesFromBottom()
{
$chart = new ezcGraphLineChart();
$chart->palette = new ezcGraphPaletteBlack();
$chart->xAxis->axisLabelRenderer = new ezcGraphAxisNoLabelRenderer();
$chart->yAxis->axisLabelRenderer = new ezcGraphAxisBoxedLabelRenderer();
$chart->yAxis->position = ezcGraph::BOTTOM;
$chart->data['sampleData'] = new ezcGraphArrayDataSet(array('sample 1' => 234, 'sample 2' => 21, 'sample 3' => 324, 'sample 4' => 120, 'sample 5' => 1));
$mockedRenderer = $this->getMock('ezcGraphRenderer2d', array('drawText'));
$mockedRenderer->expects($this->at(0))->method('drawText')->with($this->equalTo(new ezcGraphBoundings(102.0, 150.0, 138.0, 178.0), 1.0), $this->equalTo('0'), $this->equalTo(ezcGraph::MIDDLE | ezcGraph::RIGHT));
$mockedRenderer->expects($this->at(4))->method('drawText')->with($this->equalTo(new ezcGraphBoundings(102.0, 22.0, 138.0, 50.0), 1.0), $this->equalTo('400'), $this->equalTo(ezcGraph::MIDDLE | ezcGraph::RIGHT));
$chart->renderer = $mockedRenderer;
$chart->render(500, 200);
}