本文整理汇总了PHP中PHPlot::SetYLabelType方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPlot::SetYLabelType方法的具体用法?PHP PHPlot::SetYLabelType怎么用?PHP PHPlot::SetYLabelType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPlot
的用法示例。
在下文中一共展示了PHPlot::SetYLabelType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
# $Id$
# Test types of label formatting 4 (time, data:0:prefix+suffix)
require_once 'phplot.php';
$data = array();
$t = mktime(12, 0, 0, 6, 1, 2000);
for ($i = 0; $i < 12; $i++) {
$data[] = array('', $t, $i * 13.4);
$t += 60 * 60 * 24;
}
$p = new PHPlot(800, 600);
$p->SetTitle("Label Format 4");
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
$p->SetXTickIncrement(60 * 60 * 24);
$p->SetYTickIncrement(10);
$p->SetPlotType('lines');
$p->SetXLabelType('time', '%m/%d');
$p->SetXTitle("X: time MM/DD");
$p->SetYLabelType('data', 0, '$', '#');
$p->SetYTitle("Y: data, prec=0, prefix=\$, suffix=#");
$p->DrawGraph();
#fwrite(STDERR, print_r($p, True));
示例2: cos
# Y2 = cos(x)
$end = M_PI * 2.0;
$delta = $end / 20.0;
$data = array();
for ($x = 0; $x <= $end; $x += $delta) {
$data[] = array('', $x, sin($x), cos($x));
}
$plot = new PHPlot(800, 600);
$plot->SetImageBorderType('plain');
$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
# Main plot title:
$plot->SetTitle('Line Plot, Sin and Cos');
# Make a legend for the 2 functions:
$plot->SetLegend(array('sin(t)', 'cos(t)'));
# Select a plot area and force ticks to nice values:
$plot->SetPlotAreaWorld(0, -1, 6.8, 1);
# Even though the data labels are empty, with numeric formatting they
# will be output as zeros unless we turn them off:
$plot->SetXDataLabelPos('none');
$plot->SetXTickIncrement(M_PI / 8.0);
$plot->SetXLabelType('data');
$plot->SetPrecisionX(3);
$plot->SetYTickIncrement(0.2);
$plot->SetYLabelType('data');
$plot->SetPrecisionY(1);
# Draw both grids:
$plot->SetDrawXGrid(True);
$plot->SetDrawYGrid(True);
$plot->DrawGraph();
示例3: guifi_stats_chart07
function guifi_stats_chart07()
{
include drupal_get_path('module', 'guifi') . '/contrib/phplot/phplot.php';
$gDirTTFfonts = drupal_get_path('module', 'guifi') . '/contrib/fonts/';
if (isset($_GET['width'])) {
$gwidth = $_GET['width'];
} else {
$gwidth = 500;
}
if (isset($_GET['height'])) {
$gheight = $_GET['height'];
} else {
$gheight = 450;
}
$today = getdate();
$year = $today[year];
$month = $today[mon];
$month = $month - 12;
$n = 0;
$tot = 0;
if ($month < 1) {
$year = $year - 1;
$month = 12 + $month;
}
$datemin = mktime(0, 0, 0, $month, 1, $year);
if (isset($_GET['zone'])) {
$zone_id = $_GET['zone'];
if ($zone_id == "0") {
$zone_id = "0";
}
//"3671";
} else {
$zone_id = "0";
}
$avalue = array();
$adata = array();
for ($i = 0; $i < 10; $i++) {
$adata[] = array(0, 0);
}
$vsql = "select sum(if(timestamp_created >= " . $datemin . ",1,0)) as num, count(*) as total, zone_id\n from {guifi_location}\n where status_flag='Working' ";
if ($zone_id != "0") {
$achilds = guifi_zone_childs($zone_id);
$v = "";
foreach ($achilds as $key => $child) {
if ($v == "") {
$v .= "zone_id=" . $child;
} else {
$v .= " or zone_id=" . $child;
}
}
$vsql .= "AND (" . $v . ") ";
}
$vsql .= "GROUP BY zone_id ";
$result = db_query($vsql);
while ($record = db_fetch_object($result)) {
if ($record->total >= 20) {
$vn = $record->num / $record->total * 100;
$vmin = 0;
for ($i = 1; $i < 10; $i++) {
if ($adata[$vmin][1] > $adata[$i][1]) {
$vmin = $i;
}
}
if ($vn > $adata[$vmin][1]) {
$adata[$vmin][0] = $record->zone_id;
$adata[$vmin][1] = $vn;
}
}
}
for ($i = 0; $i < 10; $i++) {
if ($adata[$i][1] != 0) {
$avalue[$adata[$i][0]] = $adata[$i][1];
}
}
arsort($avalue);
foreach ($avalue as $key => $value) {
if ($value != 0) {
$data[] = array(substr(guifi_get_zone_name($key), 0, 20) . " �", $value);
}
}
$shapes = array('none');
$plot = new PHPlot($gwidth, $gheight);
$plot->SetPlotAreaWorld(0, 0, NULL, NULL);
$plot->SetFileFormat('png');
$plot->SetDataType("text-data");
$plot->SetDataValues($data);
$plot->SetPlotType("bars");
$plot->SetXTickIncrement(1);
$plot->SetSkipBottomTick(TRUE);
$plot->SetSkipLeftTick(TRUE);
$plot->SetTickLength(0);
//$plot->SetXTickPos('none');
$plot->SetYDataLabelPos('plotin');
$plot->SetYLabelType('data', 0);
$plot->SetTickColor('grey');
$plot->SetTTFPath($gDirTTFfonts);
$plot->SetFontTTF('title', 'Vera.ttf', 12);
$plot->SetFontTTF('x_label', 'Vera.ttf', 8);
if (isset($_GET['title'])) {
$plot->SetTitle("guifi.net \n" . t($_GET['title']));
//.........这里部分代码省略.........
示例4: PHPlot
# Specify the font argument as NULL or '' to use the generic one.
$plot->DrawText('', 0, $worst_x, $worst_y - 10, $red, 'Bad News!', 'center', 'bottom');
}
# Begin main processing:
# Fill the data array:
$data = get_data();
# Find the best and worst months:
get_best_worst($data, $best_index, $best_sales, $worst_index, $worst_sales);
# Create the PHPlot object, set title, plot type, data array type, and data:
$plot = new PHPlot(800, 600);
$plot->SetTitle('Monthly Widget Sales');
$plot->SetPlotType('bars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data);
# Borders are needed for the manual:
$plot->SetImageBorderType('plain');
# Select X data labels (not tick labels):
$plot->SetXTickPos('none');
$plot->SetXTickLabelPos('none');
$plot->SetXDataLabelPos('plotdown');
# Format Y labels as "$nM" with no decimals, steps of 5:
$plot->SetYLabelType('data', 0, '$', 'M');
$plot->SetYTickIncrement(5.0);
# Force the bottom of the plot to be at Y=0, and omit
# the bottom "$0M" tick label because it looks odd:
$plot->SetPlotAreaWorld(NULL, 0);
$plot->SetSkipBottomTick(True);
# Establish the drawing callback to do the annotation:
$plot->SetCallback('draw_all', 'annotate_plot', $plot);
# Draw the graph:
$plot->DrawGraph();
示例5: my_format
<?php
# $Id$
# Test types of label formatting 2 (custom, data:3)
require_once 'phplot.php';
function my_format($val, $arg)
{
$m = (int) ($val / 60);
$h = (int) ($m / 60);
$m %= 60;
return sprintf("%dH%dM", $h, $m);
}
$data = array();
for ($i = 0; $i < 10; $i++) {
$data[] = array('', 4000 * $i, 1234 * $i);
}
$p = new PHPlot(800, 600);
$p->SetTitle("Label Format Test 2");
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
$p->SetXTickIncrement(2000);
$p->SetYTickIncrement(1000);
$p->SetPlotType('lines');
$p->SetXLabelType('custom', 'my_format');
$p->SetXTitle("X: custom H:M");
$p->SetYLabelType('data', 3);
$p->SetYTitle("Y: data, prec=3");
$p->DrawGraph();
示例6: PHPlot
$prevDOfMonth = $DayOfMonth;
}
//if($debug) print_r($allDays);
//if($debug) print("I".$maxValue."I");
include "../include/phplot/phplot.php";
$graph = new PHPlot(600, 300);
if (isset($Columns) && $Columns > 30) {
$graph->SetYTitle("Duration days hours:minutes:seconds");
$graph->SetYTimeFormat("%e %H:%M:%S");
} else {
$graph->SetYTitle("Duration hours:minutes:seconds");
$graph->SetYTimeFormat("%H:%M:%S");
}
$graph->SetDataType("text-data");
$graph->SetDataValues($allDays);
$graph->SetYLabelType("time");
$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->SetPlotType("bars");
// Turn off X tick labels and ticks because they don't apply here:
$graph->SetXTickLabelPos('none');
$graph->SetXTickPos('none');
示例7: array
<?php
# $Id$
# Test types of label formatting 1 (data:2, printf:%e)
require_once 'phplot.php';
$data = array();
for ($i = 0; $i < 10; $i++) {
$data[] = array('', 500 * $i, 1234 * $i);
}
$p = new PHPlot(800, 600);
$p->SetTitle("Label Format Test 1");
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
$p->SetXTickIncrement(1000);
$p->SetYTickIncrement(1000);
$p->SetPlotType('lines');
$p->SetXTitle("X: data, prec=2");
$p->SetXLabelType('data', 2);
$p->SetYTitle("Y: printf %8.2e");
$p->SetYLabelType('printf', '%8.2e');
$p->DrawGraph();
示例8: array
<?php
# $Id$
# Test types of label formatting 5 - obsolete data_units_text
require_once 'phplot.php';
require_once 'config.php';
// Uses TTF for variety
$data = array();
for ($i = 0; $i < 10; $i++) {
$data[] = array('', 500 * $i, 1234 * $i);
}
$p = new PHPlot(800, 600);
$p->SetDefaultTTFont($phplot_test_ttfdir . $phplot_test_ttfonts['serif']);
$p->SetTitle("Label Format 5 with data_units_text=% suffix (obso)");
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetXDataLabelPos('none');
$p->SetXTickIncrement(1000);
$p->SetYTickIncrement(1000);
# Make the labels bigger:
$p->SetFont('x_label', '', 9);
$p->SetFont('y_label', '', 9);
$p->SetPlotType('lines');
$p->data_units_text = '%';
$p->SetXLabelType('data', 1, '', '#');
$p->SetXTitle('X: data(prec=1), suffix=# and %');
$p->SetYLabelType('data', 1);
$p->SetYTitle('Y: data(prec=1), suffix=%');
$p->DrawGraph();
#fwrite(STDERR, print_r($p, True));
示例9:
$plot->SetPlotType('stackedbars');
$plot->SetDataType('text-data');
$plot->SetDataValues($data1);
$plot->SetYTitle($y_title1);
# Set and position legend #1:
$plot->SetLegend($legend1);
$plot->SetLegendPixels(5, 30);
# Set margins to leave room for plot 2 Y title on the right.
$plot->SetMarginsPixels(120, 120);
# Specify Y range of these data sets:
$plot->SetPlotAreaWorld(NULL, 0, NULL, 5000);
$plot->SetYTickIncrement(500);
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');
# Format Y tick labels as integers, with thousands separator:
$plot->SetYLabelType('data', 0);
$plot->DrawGraph();
# Plot 2
$plot->SetDrawPlotAreaBackground(False);
// Cancel background
$plot->SetDrawYGrid(False);
// Cancel grid, already drawn
$plot->SetPlotType('linepoints');
$plot->SetDataValues($data2);
# Set Y title for plot #2 and position it on the right side:
$plot->SetYTitle($y_title2, 'plotright');
# Set and position legend #2:
$plot->SetLegend($legend2);
$plot->SetLegendPixels(690, 30);
# Specify Y range of this data set:
$plot->SetPlotAreaWorld(NULL, 0, NULL, 50);
示例10:
$plot->SetTitle("Multiple Plots, X,Y label format\n{$subtitle}");
$plot->SetPlotType('linepoints');
$plot->SetDataValues($data);
$plot->SetDataType('data-data');
$plot->SetYDataLabelPos('plotin');
// Enable both X tick and X data labels, but with data labels above.
$plot->SetXDataLabelPos('plotup');
$plot->SetXTickLabelPos('plotdown');
$plot->SetPlotBorderType('full');
// Plot #1:
$plot->SetPlotAreaPixels(NULL, 80, NULL, 305);
if (isset($fmt[1]['x'])) {
$plot->SetXLabelType('printf', $fmt[1]['x']);
}
if (isset($fmt[1]['y'])) {
$plot->SetYLabelType('printf', $fmt[1]['y']);
}
if (isset($fmt[1]['xd'])) {
$plot->SetXDataLabelType('printf', $fmt[1]['xd']);
}
if (isset($fmt[1]['yd'])) {
$plot->SetYDataLabelType('printf', $fmt[1]['yd']);
}
$plot->DrawGraph();
// Plot #2:
$plot->SetPlotAreaPixels(NULL, 345, NULL, 570);
if (isset($fmt[2]['x'])) {
$plot->SetXLabelType('printf', $fmt[2]['x']);
}
if (isset($fmt[2]['y'])) {
$plot->SetYLabelType('printf', $fmt[2]['y']);
示例11: array
for ($i = 0; $i <= $n_pts; $i++) {
// 1 extra point to return to 0
$data[] = array('', $theta, $r * sin($theta));
$theta += $d_theta;
}
$p = new PHPlot(800, 600);
$p->SetTitle($title . $suffix);
$p->SetDataType('data-data');
$p->SetDataValues($data);
$p->SetImageBorderType('solid');
$p->SetYDataLabelPos('plotin');
if (isset($yd_angle)) {
$p->SetYDataLabelAngle($yd_angle);
}
if (isset($y_type)) {
$p->SetYLabelType($y_type, $y_type_arg);
}
if (isset($yd_type)) {
$p->SetYDataLabelType($yd_type, $yd_type_arg);
}
if (isset($y_label_font)) {
if (isset($y_label_font_ttfsize)) {
$p->SetFontTTF('y_label', $y_label_font, $y_label_font_ttfsize);
} else {
$p->SetFontGD('y_label', $y_label_font);
}
}
$p->SetXLabelType('data', 3);
$p->SetPlotType($plot_type);
if (isset($dvl_angle)) {
$p->data_value_label_angle = $dvl_angle;
示例12: round
if ($v > 0) {
$p64 = (int) round($v * 64);
$factor = gcd($p64, 64);
$numerator = $p64 / $factor;
$denominator = 64 / $factor;
$result .= $space_between . $numerator . '/' . $denominator;
}
return $result;
}
$data = array();
$nx = 32;
for ($x = 0; $x <= $nx; $x++) {
$y = sin(2 * $x * M_PI / $nx);
$data[] = array('', $x, $y);
}
if (!method_exists('PHPlot', 'TuneXAutoTicks')) {
echo "Skipping test because it requires TuneXAutoTicks()\n";
exit(2);
// Exit code for 'skip'
}
$plot = new PHPlot(800, 600);
$plot->SetTitle('Powers of 2 X Tick Increment, Fractional Y Tick Labels');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotType('lines');
# Set minimum 25 ticks, binary mode steps.
$plot->TuneYAutoTicks(25, 'binary');
$plot->SetYLabelType('custom', 'fract_label');
# Use binary ticks on X too:
$plot->TuneXAutoTicks(NULL, 'binary');
$plot->DrawGraph();
示例13:
$p->SetXDataLabelAngle($tp['xd_angle']);
}
if (isset($tp['x_type'])) {
$p->SetXLabelType($tp['x_type'], $tp['x_type_arg']);
}
if (isset($tp['xd_type'])) {
$p->SetXDataLabelType($tp['xd_type'], $tp['xd_type_arg']);
}
if (isset($tp['xt_pos'])) {
$p->SetXTickLabelPos($tp['xt_pos']);
}
if (isset($tp['xd_pos'])) {
$p->SetXDataLabelPos($tp['xd_pos']);
}
# Options: Y
if (isset($tp['y_angle'])) {
$p->SetYLabelAngle($tp['y_angle']);
}
if (isset($tp['yd_angle'])) {
$p->SetYDataLabelAngle($tp['yd_angle']);
}
if (isset($tp['y_type'])) {
$p->SetYLabelType($tp['y_type'], $tp['y_type_arg']);
}
if (isset($tp['yd_type'])) {
$p->SetYDataLabelType($tp['yd_type'], $tp['yd_type_arg']);
}
if (isset($tp['yt_pos'])) {
$p->SetYTickLabelPos($tp['yt_pos']);
}
$p->DrawGraph();
示例14: PHPlot
$title = "Test Attribute Resets:\n";
if (empty($test_resets)) {
$title .= 'Baseline - red border, formatted labels';
} else {
$title .= 'Reset to no border, no label formatting';
}
$plot = new PHPlot(400, 400);
$plot->SetTitle($title);
$plot->SetPlotType('lines');
$plot->SetDataType('data-data');
$plot->SetDataValues($data);
$plot->SetPlotAreaWorld(-1000, 0);
$plot->SetXDataLabelPos('none');
$plot->SetXTickIncrement(500);
$plot->SetXLabelType('data', 0, '', 'M');
$plot->SetYTickIncrement(200000);
$plot->SetYLabelType('data', 2);
$plot->SetImageBorderType('raised');
$plot->SetImageBorderColor('red');
$plot->SetDrawXGrid(False);
$plot->SetDrawYGrid(False);
# Set $test_resets=True and include this file to test resets:
if (!empty($test_resets)) {
# Reset to no border:
$plot->SetImageBorderType('none');
# Reset X to no formatting using empty string:
$plot->SetXLabelType('');
# Reset Y to no formatting using no argument:
$plot->SetYLabelType();
}
$plot->DrawGraph();
示例15: array
# <=12 13-17 17-28 30-39 40-54 >=55
$data = array(array('Cherry', 1, 1, 2, 2, 4, 3, 3, 4, 3, 5, 5, 6, 6), array('Apple', 2, 1, 9, 2, 7, 3, 4, 4, 7, 5, 3, 6, 7), array('Pear', 3, '', 2, 2, 2, 3, 3, 4, 4, 5, 3, 6, 2), array('Grape', 4, 1, 8, 2, 5, 3, 5, 4, 6, 5, 3, 6, 4), array('Kiwi', 5, '', 0, 2, 3, 3, 4, 4, 4, 5, 5, 6, 2), array('Banana', 6, 1, 5, 2, 4, 3, 6, 4, 3, 5, 3, 6, 4));
$plot = new PHPlot(600, 600);
$plot->SetTitle("Flavor Preference By Age Group");
$plot->SetDataType('data-data-xyz');
$plot->SetDataValues($data);
$plot->SetPlotType('bubbles');
$plot->SetDataColors('yellow');
// Use same color for all data sets
$plot->SetDrawPlotAreaBackground(True);
$plot->SetPlotBgColor('plum');
$plot->SetLightGridColor('red');
// Change grid color to make it visible
$plot->SetImageBorderType('plain');
$plot->SetPlotBorderType('full');
$plot->SetXTickIncrement(1);
// For grid line spacing
$plot->SetYTickIncrement(1);
$plot->SetPlotAreaWorld(0, 0, 6.5, 6.5);
# Establish the handler for the Y label text:
$plot->SetYLabelType('custom', 'get_label', $y_labels);
$plot->SetXTickPos('both');
// Tick marks on both sides
$plot->SetYTickPos('both');
// Tick marks on top and bottom too
$plot->SetXDataLabelPos('both');
// X axis data labels top and bottom
$plot->SetYTickLabelPos('both');
// Y axis labels left and right
$plot->SetDrawXGrid(True);
$plot->DrawGraph();