本文整理汇总了PHP中Graph::SetTickDensity方法的典型用法代码示例。如果您正苦于以下问题:PHP Graph::SetTickDensity方法的具体用法?PHP Graph::SetTickDensity怎么用?PHP Graph::SetTickDensity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Graph
的用法示例。
在下文中一共展示了Graph::SetTickDensity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
<?php
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_line.php';
$ydata = array(12, 17, 22, 19, 5, 15);
$graph = new Graph(250, 170);
$graph->SetScale("textlin", 3, 35);
$graph->SetTickDensity(TICKD_DENSE);
$graph->yscale->SetAutoTicks();
$graph->title->Set('Manual scale, auto ticks');
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$line = new LinePlot($ydata);
$graph->Add($line);
// Output graph
$graph->Stroke();
?>
示例2: Graph
// Size of the overall graph
$width = 350;
$height = 250;
// Create the graph and set a scale.
// These two calls are always required
$graph = new Graph(800, 600, 'auto');
$graph->SetScale("datlin", 0, $max + 10);
$graph->yaxis->scale->SetGrace(7);
$graph->img->SetMargin(50, 30, 40, 130);
$graph->SetShadow();
$graph->yaxis->title->Set("Close");
$graph->xaxis->title->Set("Date");
$graph->title->Set($var_graph);
$lplot = new LinePlot($closearray);
$graph->xaxis->SetLabelAngle(90);
$graph->SetTickDensity(TICKD_NORMAL, TICKD_SPARSE);
$graph->xaxis->SetTickLabels($datearray);
$lplot->SetFillColor('red@0.5');
$graph->Add($lplot);
$graph->Stroke();
$user = 'root';
$pass = '';
$db = 'testdb';
$conn = new mysqli('localhost', $user, $pass, $db) or die("unable to connect");
//echo"great work!";
$sql = "insert into search(userName,searchValue) values('{$uname}','{$var_graph}')";
$data = mysqli_query($conn, $sql) or die;
?>
<a href="index.html" style="color:blue;font-size:30px;position:absolute;right:10px;top:50px;font-weight:bold;">back to home</a>
</body>
示例3: GetView
//.........这里部分代码省略.........
$iv = $caches->CreateInterval($req, true);
$window_size = $iv->GetWindowSize();
$window_start = $iv->GetWindowStart();
$window_end = $iv->GetWindowEnd();
$rescfg = array('limit' => $this->max_points, 'resolution' => $res);
$gid = 0;
$res = array();
foreach ($caches as $key => $cachewrap) {
if ($gid != $x_gid && $gid != $y_gid) {
$gid++;
continue;
}
$resolution = $cachewrap->GetResolution();
$r = $resolution->Get($iv, $width);
$size = $resolution->GetWindowSize($r);
if ($size > 0 && $window_size / $size > $this->max_points) {
$new_r = $resolution->Larger($r);
if ($new_r !== false) {
$r = $new_r;
}
$size = $resolution->GetWindowSize($r);
}
$rescfg['resolution'] = $r;
$points = $cachewrap->GetIntervals($iv, $rescfg, CACHE::TRUNCATE_INTERVALS);
$operation_info = $points->GetOperationInfo();
if ($gid == $x_gid) {
$res_x = $size;
}
if ($gid == $y_gid) {
$res_y = $size;
}
foreach ($points as $t => $v) {
/* if (($t < $window_start)||(($t + $size) > $window_end)) {
continue;
}*/
if ($gid == $x_gid && is_numeric($v['mean' . $x_id])) {
if (!is_array($res[$t])) {
$res[$t] = array();
}
$res[$t]['x'] = $v['mean' . $x_id];
}
if ($gid == $y_gid && is_numeric($v['mean' . $y_id])) {
if (!is_array($res[$t])) {
$res[$t] = array();
}
$res[$t]['y'] = $v['mean' . $y_id];
}
}
$gid++;
}
$x = array();
$y = array();
foreach ($res as $val) {
if (isset($val['x']) && isset($val['y'])) {
array_push($x, $val['x']);
array_push($y, $val['y']);
}
}
if (!$x) {
throw new ADEIException(translate("No data found"));
}
$corr = stats_stat_correlation($x, $y);
$tmp_file = ADEI::GetTmpFile();
$graph = new Graph($width, $height);
if ($res_x == $res_y) {
$title = "Resolution: {$res_x}";
} else {
$title = "Resolution: {$res_x}, {$res_y}";
}
if (!$this->object) {
$title = "{$title}, " . date('c', $iv->GetWindowStart()) . " - " . date('c', $iv->GetWindowEnd());
}
$graph->title->Set($title);
$graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE);
$graph->img->SetMargin(55, 5, 10, 20);
$graph->SetScale("linlin");
$graph->xaxis->SetPos("min");
$graph->yaxis->SetPos("min");
$graph->xaxis->SetLabelFormat('%3.1e');
$graph->yaxis->SetLabelFormat('%3.1e');
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->yaxis->HideFirstTickLabel();
$sp = new ScatterPlot($x, $y);
$graph->Add($sp);
/*
$txt = new Text();
$txt->SetFont(FF_ARIAL,FS_BOLD,11);
$txt->Set(sprintf("R = %01.2f", $corr));
$txt->SetPos(0.99,0.1,'right');
$txt->SetBox('lightyellow');
$graph->Add($txt);
*/
$graph->Stroke("{$TMP_PATH}/{$tmp_file}");
if ($this->object) {
return array("img" => array("id" => $tmp_file), "div" => array("xml" => "<b>Correlation</b>: " . $corr . "<br/>" . "<b>From</b>: " . date('c', $iv->GetWindowStart()) . "<br/>" . "<b>To</b>: " . date('c', $iv->GetWindowEnd()) . "<br/>"));
} else {
return array("img" => array("id" => $tmp_file));
}
}
示例4: array
<?php
include "../jpgraph.php";
include "../jpgraph_bar.php";
$data1y = array(12, 8, 19, 3, 10, 5);
$data2y = array(8, 2, 11, 7, 14, 4);
$data3y = array(4, 1, 9, 15, 12, 6);
$data4y = array(8, 3, 2, 1, 9, 10);
// Create the graph. These two calls are always required
$graph = new Graph(300, 315, "auto");
$graph->img->SetMargin(40, 30, 20, 40);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->SetBox();
$graph->SetTickDensity(TICKD_VERYSPARSE);
// Create the bar plots
$b1plot = new BarPlot($data1y);
$b1plot->SetFillColor("orange");
$b2plot = new BarPlot($data2y);
$b2plot->SetFillColor("blue");
$b3plot = new BarPlot($data3y);
$b3plot->SetFillColor("green");
$b4plot = new BarPlot($data4y);
$b4plot->SetFillColor("red");
// Create the accumulated bar plots
$ab1plot = new AccBarPlot(array($b1plot, $b2plot));
$ab2plot = new AccBarPlot(array($b3plot, $b4plot));
// Create the grouped bar plot
//$gbplot = new GroupBarPlot(array($ab1plot,$ab2plot));
// ...and add it to the graPH
//$graph->Add($gbplot);
示例5: GetView
//.........这里部分代码省略.........
array_push($x, $val['x']);
}
}
if (!$x) {
throw new ADEIException(translate("No data found"));
}
$bins = $req->GetProp("view_bins", 0);
if (!$bins) {
$bins = ceil(sqrt(sizeof($x)));
}
$norm = $req->GetProp("view_hist_norm", 0);
$fit = $req->GetProp("view_hist_fit", 0);
$min = min($x);
$max = max($x);
$step = ($max - $min) / $bins;
$coef = $norm ? 1 / ($step * sizeof($x)) : 1;
$h = array_fill(0, $bins, 0);
foreach ($x as $val) {
$idx = ($val - $min) / $step;
if ($idx == $bins) {
$idx--;
}
$h[$idx] += $coef;
}
for ($i = 0; $i < $bins; $i++) {
array_push($t, sprintf("%3.1e", $min + $i * $step));
}
$tmp_file = ADEI::GetTmpFile();
$graph = new Graph($width, $height);
/* $title = "Resolution: $res_x";
$graph->title->SetFont(FF_ARIAL,FS_BOLD,10);
$graph->title->Set($title);*/
$graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE);
$graph->img->SetMargin(55, 5, 10, 20);
$graph->SetScale("textlin");
$graph->xaxis->SetPos("min");
$graph->yaxis->SetPos("min");
// $graph->xaxis->SetLabelFormat('%3.1e');
// if (abs(max($h))<9999 && (abs(min($h))>0.01)) $graph->yaxis->SetLabelFormat('%01.2f');
// else $graph->yaxis->SetLabelFormat('%3.1e');
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
// $graph->yaxis->HideFirstTickLabel();
$graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD);
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD);
//$graph->xaxis->title->Set($arr[0]['select']['options'][$x_idg]['label']);
if ($bins > 8) {
$graph->xaxis->SetTextLabelInterval(ceil($bins / 6));
}
$graph->xaxis->SetTickLabels($t);
$bplot = new BarPlot($h);
$bplot->SetWidth(1);
$graph->Add($bplot);
$graph->yaxis->scale->SetGrace(14);
$mean = array_sum($x) / sizeof($x);
$stddev = stats_standard_deviation($x);
$var = stats_variance($x);
$sigma = sqrt($var);
$re = 100 * $sigma / $mean;
sort($x);
if (sizeof($x) % 2) {
$median = $x[(sizeof($x) - 1) / 2];
} else {
$median = ($x[sizeof($x) / 2 - 1] + $x[sizeof($x) / 2]) / 2;
}
示例6: GetView
//.........这里部分代码省略.........
$rescfg['resolution'] = $r;
$points = $cachewrap->GetIntervals($iv, $rescfg, CACHE::TRUNCATE_INTERVALS);
$operation_info = $points->GetOperationInfo();
$res_x = $size;
$sum_of_vars = 0;
$sum_of_vars_min = 0;
$sum_of_vars_max = 0;
$number_of_events = 0;
$number_of_events_min = 0;
$number_of_events_max = 0;
foreach ($points as $t => $v) {
for ($i = $bin_from - 1; $i < $bin_to; $i++) {
$bin_height = $v['mean' . $i];
if ($mode_of_draw == "hist_sum") {
$bin_height *= $v['items'];
}
$x_bin[$i - $bin_from + 1] += $bin_height;
$sum_of_vars += ($i + 1) * $bin_height;
$number_of_events += $bin_height;
if ($mode_of_draw == "hist_minmax") {
$x_bin_min[$i - $bin_from + 1] += $v['min' . $i];
$x_bin_max[$i - $bin_from + 1] += $v['max' . $i];
}
array_push($x_axis_tick_labels, sprintf("%d", $i + 1));
}
}
if (!$x_bin) {
throw new ADEIException(translate("No data found"));
}
$mean = $sum_of_vars / $number_of_events;
$var_std = 0;
$var_sum = 0;
$var_bin = 0;
$half_number_of_events = $number_of_events / 2;
for ($i = $bin_from; $i <= $bin_to; $i++) {
$var_std += ($i - $mean) * ($i - $mean) * $x_bin[$i - $bin_from];
if ($var_sum < $half_number_of_events) {
$var_sum += $x_bin[$i - $bin_from];
$var_bin = $i - $bin_from;
}
}
$stddev = sqrt($var_std / $number_of_events);
$median = $var_bin + ($half_number_of_events - $var_sum + $x_bin[$var_bin + 1]) / $x_bin[$var_bin + 1];
}
$tmp_file = ADEI::GetTmpFile();
$graph = new Graph($width, $height);
$graph->SetTickDensity(TICKD_SPARSE, TICKD_SPARSE);
$graph->img->SetMargin(55, 5, 10, 20);
if (!$scale_log) {
$graph->SetScale("textlin", 0, $max_of_y);
} else {
if (min($x_bin) >= 0) {
$graph->SetScale("textlog");
} else {
throw new ADEIException(translate("The selected data contains negative values which can't be visualized on the log scale"));
}
}
$graph->xaxis->SetPos("min");
$graph->yaxis->SetPos("min");
$graph->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8);
$graph->xaxis->title->SetFont(FF_ARIAL, FS_BOLD);
$graph->yaxis->title->SetFont(FF_ARIAL, FS_BOLD);
if ($bins_n > 16) {
$graph->xaxis->SetTextLabelInterval(ceil($bins_n / ceil($width / 25)));
}
$graph->xaxis->SetTickLabels($x_axis_tick_labels);
$bplot = new BarPlot($x_bin);
$bplot->SetWidth(1);
if ($mode_of_draw == "hist_sum") {
$bplot->SetLegend("Sum Mode");
} else {
$bplot->SetLegend("AVG Mode");
}
if ($mode_of_draw == "hist_minmax") {
$bplot_min = new BarPlot($x_bin_min);
$bplot_min->SetWidth(1);
$bplot_min->SetLegend("Minimum");
$bplot_min->SetFillColor('deepskyblue');
$bplot_max = new BarPlot($x_bin_max);
$bplot_max->SetWidth(1);
$bplot_max->SetLegend("Maximum");
$bplot_max->SetFillColor('indianred1');
}
if ($mode_of_draw == "hist_minmax") {
$graph->Add($bplot_max);
}
$graph->Add($bplot);
if ($mode_of_draw == "hist_minmax") {
$graph->Add($bplot_min);
}
$graph->yaxis->scale->SetGrace(14);
$graph->Stroke("{$TMP_PATH}/{$tmp_file}");
if ($this->object) {
$res = array(array("img" => array("id" => $tmp_file)), array("info" => array(array("title" => _("Number of Bins"), "value" => round($bins_n, 3)), array("title" => _("Mode"), "value" => array_search(max($x_bin), $x_bin) + $bin_from), array("title" => _("Mean"), "value" => round($mean, 3)), array("title" => _("Median"), "value" => round($median, 3)), array("title" => _("Value of Mode"), "value" => round(max($x_bin), 3)), array("title" => _("Integral of Hist"), "value" => round($number_of_events, 3)), array("title" => _("StdDev"), "value" => round($stddev, 3)), array("title" => _("RE"), "value" => round($stddev / $mean * 100 . "%", 3) . "%"), array("title" => _("From"), "value" => date('c', $iv->GetWindowStart())), array("title" => _("To"), "value" => date('c', $iv->GetWindowEnd())), array("title" => _("Resolution"), "value" => round($res_x, 3)))));
return $res;
} else {
return array("img" => array("id" => $tmp_file));
}
}