English 中文(简体)
jpgraph 更改边距颜色
原标题:change margin color for a jpgraph
  • 时间:2012-05-24 16:05:39
  •  标签:
  • php
  • jpgraph

I am trying to change the color of the margin on a jpgraph. I cannot seem to figure it out. I tried $graph->SetMarginColor("khaki:0.6"); but that seemed to do nothing. below is the code that generates an example chart as well as the sample output. I am using jpgraph 3.5 if that helps.

$datay1 = array(20,15,23,15);
$datay2 = array(12,9,42,8);
$datay3 = array(5,17,32,24);

// Setup the graph
$graph = new Graph(300,250);
$graph->SetScale("textlin");

$theme_class=new UniversalTheme;

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set( Filled Y-grid );
$graph->SetBox(false);

$graph->img->SetAntiAliasing();

$graph->yaxis->HideZeroLabel();
$graph->yaxis->HideLine(false);
$graph->yaxis->HideTicks(false,false);

$graph->xgrid->Show();
$graph->xgrid->SetLineStyle("solid");
$graph->xaxis->SetTickLabels(array( A , B , C , D ));
$graph->xgrid->SetColor( #E3E3E3 );

// Create the first line
$p1 = new LinePlot($datay1);
$graph->Add($p1);
$p1->SetColor("#6495ED");
$p1->SetLegend( Line 1 );

// Create the second line
$p2 = new LinePlot($datay2);
$graph->Add($p2);
$p2->SetColor("#B22222");
$p2->SetLegend( Line 2 );

// Create the third line
$p3 = new LinePlot($datay3);
$graph->Add($p3);
$p3->SetColor("#FF1493");
$p3->SetLegend( Line 3 );

$graph->legend->SetFrameWeight(1);

// Output line
$graph->Stroke();

?>

""https://i.sstatic.net/TzNd0.jpg" alt="此处输入图像描述"/ >

最佳回答

setMarginColor 是您需要的两个命令之一。 您也需要使用 setFrame

$graph->SetTheme($theme_class);
$graph->img->SetAntiAliasing(false);
$graph->title->Set( Filled Y-grid );
$graph->SetMarginColor( khaki:0.6 ); 
$graph->SetFrame(true, khaki:0.6 ,1);    // The  1  here seems to be irrelevant
                                         // I ve tried much larger numbers with no
                                         // change. This is supposed to be frame
                                         // width (in pixels). 
$graph->SetBox(false);

产生像这样的图像

""https://i.sstatic.net/SivnA.png" alt="此处输入图像描述"/ >

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签