在创建Bar Plot顶部有一条线的图形时,JPGraph版本4和3.5似乎存在问题.该线似乎在稍微不同的位置呈现两次.如果我将库恢复到版本3,它将解决问题.我目前正在与他们的支持团队调查此问题.
这是生成图表的代码
$graph = new Graph($w, $h, 'auto');
$graph->SetScale("textint", 0,10);
$graph->SetMargin(0,0,0,0); // left, right, top, bottom.
$graph->SetMarginColor('white');
$graph->SetBox(false);
$graph->SetFrame(false);
$graph->SetY2OrderBack(false);
$graph->img->SetAntiAliasing(false);
$graph->yaxis->SetTickPositions([0,2,4,6,8,10]);
$graph->yaxis->HideLabels();
$graph->xaxis->HideLabels();
$graph->xaxis->SetTickLabels( ['2012', '2013', '2014', '2015'] );
$graph->xaxis->SetLabelAlign('center','center');
$graph->ygrid->SetFill(true,'#f3f3f4','#ffffff');
$graph->ygrid->Show();
$colour_one = $this->colors['blue_dark'];
$colour_two = $this->colors['blue'];
$line = $this->colors['line'];
$barplot = new BarPlot($bars);
$graph->Add($barplot);
$barplot->SetFillColor(array($colour_one, $colour_one, $colour_one, $colour_two));
$graph->SetColor($this->colors['text']);
$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);
$group_standard = new LinePlot($lines[0]);
$group_standard->SetBarCenter();
$graph->Add($group_standard);
$group_standard->SetStyle('dashed');
$group_standard->SetColor($line);
$twenty_fifteen_target = new LinePlot($lines[1]);
$twenty_fifteen_target->SetBarCenter();
$twenty_fifteen_target->SetStyle('solid');
$twenty_fifteen_target->SetColor($line);
$graph->Add($twenty_fifteen_target);
$graph->Stroke(storage_path().'/audit-generator/images/graphs/' . $name . '.png');
Run Code Online (Sandbox Code Playgroud)
要访问演示,请访问 …
我想问一下如何使用jpgraph将自定义行添加到图表中.例如,为了识别从数据库中选择的日期SUNDAY,jpgraph将在每个星期日绘制一条红色的直线,将在x轴上显示.
有没有人遇到相关问题并且已经解决了?请告诉我,谢谢.
我的情况代码:`
$dateLocale = new DateLocale();
$dateLocale->Set('');
$file_date = date("Ymd");
$dateArray = array();
$dataSuccessful = array(); //get from db
$dataUser_not_found = array();
$dataAcc_not_activated = array();
$dataUnsuccess_others = array();
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
//Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "example";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$dateArray[] = date("d/m/Y (D)", strtotime($row["date"]));
$dataSuccessful[] = $row["login_success_count"];
$dataUser_not_found[] = $row["unsuccess_not_found"];
$dataAcc_not_activated[] …Run Code Online (Sandbox Code Playgroud) 我正在使用jpgraph并创建雷达图表.
面对填充自定义形状多边形与渐变颜色的问题.
我有功能填充一个平底的渐变颜色多边形,我想填充自定义形状多边形中的渐变颜色.谁能帮我?我怎样才能做到这一点?
电流输出:

期望的输出:

您可以在此处找到渐变类.
// Fill a special case of a polygon with a flat bottom
// with a gradient. Can be used for filled line plots.
// Please note that this is NOT a generic gradient polygon fill
// routine. It assumes that the bottom is flat (like a drawing
// of a mountain)
function FilledFlatPolygon($pts,$from_color,$to_color) {
if( count($pts) == 0 ) return;
$maxy=$pts[1];
$miny=$pts[1];
$n = count($pts) ;
for( $i=0, $idx=0; $i < …Run Code Online (Sandbox Code Playgroud) 我刚开始使用jpgraph和XAMPP我正在寻找一个barplot.当我在网上阅读一些文章时,它说你可以将一系列颜色传递给setfillcolor,这样每个条形都会有不同的颜色.但是,每当我通过它时,图表都不会改变其浅蓝色的默认颜色.
图表响应数据的变化而不是颜色的变化.我尝试了一个累积的条形图示例,这似乎是颜色响应.
我不确定如何诊断这样的问题.请帮忙!
下面的代码(Jpgraph文档中的示例,颜色从橙色变为#B0C4DE [原始示例中的橙色未显示]):
<?php // content="text/plain; charset=utf-8"
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph.php");
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph_line.php");
require_once(dirname(__FILE__)."\lib\jpgraph-3.5.0b1\src\jpgraph_bar.php");
$datay=array(2,3,5,25,15,6,3);
$datax=array('Jan','Feb','Mar','Apr','May','Jun','Jul');
// Size of graph
$width=400;
$height=500;
// Set the basic parameters of the graph
$graph = new Graph($width,$height,'auto');
$graph->SetScale('textlin');
// Rotate graph 90 degrees and set margin
$graph->Set90AndMargin(50,20,50,30);
// Nice shadow
$graph->SetShadow();
// Setup title
$graph->title->Set('Horizontal bar graph ex 1');
$graph->title->SetFont(FF_VERDANA,FS_BOLD,14);
// Setup X-axis
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,12);
// Some extra margin looks nicer
$graph->xaxis->SetLabelMargin(10);
// Label align for X-axis
$graph->xaxis->SetLabelAlign('right','center');
// Add some grace to y-axis so …Run Code Online (Sandbox Code Playgroud) 我正在使用这个脚本,这是jpgraph本身提供的示例之一.当我把它放在一个网页(空白)上时,它正在绘制图形.但是当我将代码嵌入已经存在的网页(包含一些内容)时,它并没有绘制图形.
GD已根据phpinfo()启用.我使用jpgraph 3.5.0b1.
你能帮我解决一下如何在JpGraph上设置实线的重量吗?
使用创建行
// Create the first line
$p1 = new LinePlot($datay1);
$p1->SetStyle('solid');
$p1->SetWeight('20');
$p1->SetColor("#6495ED");
$p1->SetLegend('Line 1');
$graph->Add($p1);
Run Code Online (Sandbox Code Playgroud)
使用此代码,线宽为1.
但是如果将行定义为
$p1->SetStyle('dotted');
Run Code Online (Sandbox Code Playgroud)
...线的重量是20px.
你能告诉我在线路定义中我做错了吗?我需要更大胆的实线......
先感谢您!
我在php中使用了JpGraph.一切都好但切片($ p1-> SetSliceColors($ color);)颜色不起作用.它一直是默认颜色.这是我用过的代码.请帮我 :
$data = array('40','50', '10');
$Legends = array('Loss','Win', 'Draw');
$labels = array("Loss\n(%.1f%%)","Win\n(%.1f%%)","Draw\n(%.1f%%)");
$color = array('red','red','red');
$graph = new PieGraph(550,350);
$graph->SetShadow();
$p1 = new PiePlot3D($data);
$p1->ExplodeSlice(1);
$p1->SetCenter(0.55);
$p1->SetLegends($Legends);
$graph->legend->Pos(0.5,0.1);
$p1->SetTheme("earth");
$p1->SetSliceColors($color);
// Setup the labels to be displayed
$p1->SetLabels($labels);
$p1->SetLabelPos(1);
$p1->SetLabelType(PIE_VALUE_PER);
$p1->value->Show();
$p1->value->SetFont(FF_FONT1,FS_NORMAL,9);
$p1->value->SetColor('navy');
$graph->Add($p1);
$graph->Stroke();
Run Code Online (Sandbox Code Playgroud) 我正在使用jpgraph条形图.这一切都很好,但有一件事我无法弄明白.我需要在该栏(列)的顶部显示每个栏的值,但似乎我错过了一些我无法做到的事情.
我尝试过使用以下内容:
$bplot->value->Show();
Run Code Online (Sandbox Code Playgroud)
但它不起作用!任何帮助是极大的赞赏!
我正在使用JpGraph版本3.5.0b1为PDF文档创建一些图表,我遇到了一个问题,这个问题花费了我一半的时间来尝试找出问题所在.
我想做的就是改变线条图的线条粗细,但无论我尝试什么,它总是默认为1(假设1是默认值).
我完成了我的研究,并且知道在将其添加到图形之后我必须设置它,并且如果antialias设置为true,则忽略SetWeight.我的代码遵循这些规则,但仍然没有.我能够改变线的颜色,所以我知道它与我如何调用方法无关.
有人可以帮我吗?我会非常感激,因为它开始让我感到烦恼.
无论如何,这里是我的代码的一小部分:
$lineplot = new LinePlot($ydata, $xdata);
$graph->Add($lineplot);
$lineplot->SetColor("red");
$lineplot->SetWeight(2);
Run Code Online (Sandbox Code Playgroud)