【问题标题】:Jpgraph : how set label for group bar column chart in phpJpgraph:如何在 php 中为组条形柱形图设置标签
【发布时间】:2012-12-09 21:46:01
【问题描述】:

这是我的 jpgraph 演示代码:

<?php // content="text/plain; charset=utf-8"
// $Id: groupbarex1.php,v 1.2 2002/07/11 23:27:28 aditus Exp $
require_once ('jpgraph/jpgraph.php');
require_once ('jpgraph/jpgraph_bar.php');

$datay1=array(35,160,0,0,0,0);
$datay2=array(35,190,190,190,190,190);
$datay3=array(20,70,70,140,230,260);

$graph = new Graph(450,200,'auto');    
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40,30,40,40);
$graph->xaxis->SetTickLabels($gDateLocale->GetShortMonth());

$graph->xaxis->title->Set('Year 2002');
$graph->xaxis->title->SetFont(FF_FONT1,FS_BOLD);

$graph->title->Set('Group bar plot');
$graph->title->SetFont(FF_FONT1,FS_BOLD);

$bplot1 = new BarPlot($datay1);
$bplot2 = new BarPlot($datay2);
$bplot3 = new BarPlot($datay3);

$bplot1->SetFillColor("orange");
$bplot2->SetFillColor("brown");
$bplot3->SetFillColor("darkgreen");

$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);

$graph->Stroke();
?>

此代码没有错误,并且运行良好...我的问题是如何为这个多条设置标签以进行识别...

如何设置标签..

【问题讨论】:

  • 我使用了这个代码,但它对我不起作用....$graph->SetLegends(array('Pass','Fail','Not Eligble')); $graph->添加($p1);
  • 谁能帮我们开发这段代码????
  • i.stack.imgur.com/Hs4hR.png 我想将此 img 应用于上图...我认为这是最好的解决方案...

标签: php jpgraph


【解决方案1】:
$graph->legend->SetPos(0.5,0.98,'center','bottom');
$bplot1->SetLegend("Pass");
$bplot2->SetLegend("---");
$bplot3->SetLegend("---");

$gbarplot = new GroupBarPlot(array($bplot1,$bplot2,$bplot3));
$gbarplot->SetWidth(0.6);
$graph->Add($gbarplot);

$graph->Stroke();

在你的代码中写下这一行。欲了解更多信息,请参阅此网址:

Class Reference

With Example

【讨论】:

    猜你喜欢
    • 2012-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-22
    • 2012-04-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多