【问题标题】:change margin color for a jpgraph更改 jpgraph 的边距颜色
【发布时间】:2012-05-31 06:08:22
【问题描述】:

我正在尝试更改 jpgraph 上边距的颜色。我似乎无法弄清楚。我尝试了$graph->SetMarginColor("khaki:0.6");,但这似乎无济于事。下面是生成示例图表以及示例输出的代码。如果有帮助,我正在使用 jpgraph 3.5。

$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();

?>

【问题讨论】:

  • 之前没用过jpgraph,但是能不能找出图的输出html是什么,然后用css改变margin?
  • @RMcLeod 我是 jpgraph 的新手,但据我了解,它输出的是图像,而不是 html 代码。
  • 图片的边缘是否与D上方的垂直线不对齐?如果不是,那么我认为空白可以被视为背景,有没有办法改变它?

标签: php jpgraph


【解决方案1】:

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);

这会产生这样的图像

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-26
    • 2013-09-05
    相关资源
    最近更新 更多