/    Sign up×
Community /Pin to ProfileBookmark

jp graph+legends

?

Dear all,

I have got the four people’s evaluation results in percent value and displayed them in bar graph in four diffrent colours.

What I want to give the legends with four people’s names on the same graph.

I tried with an array, but it shows only the word “array” with color of the first graph “green” as the legend.

How can one show that each of the four persons name x,y…etc on this graph as the legend.

The codes are as follows;

$datay=array( $a_row[‘APPRAISERPERC’], $a_row[‘APPRAISSEEPERC’], $a_row[‘SUBPERC’], $a_row[‘PEERPERC’]);
$colors=array(“green”,”blue”,”red”,”gray4″);
$legends=array(‘appraiser%’,’appraisee%’,’subordinate%’,’peer%’);
// Setup the graph.
$graph = new Graph(400,200,”auto”);
$graph->img->SetMargin(60,30,30,40);
$graph->SetScale(“textlin”);
$graph->SetMarginColor(“teal”);
$graph->SetShadow();

// Create the bar pot
$bplot = new BarPlot($datay);
//$bplot1 = new BarPlot(‘array[1]’);
$bplot->SetWidth(0.6);

// This is how you make the bar graph start from something other than 0
$bplot->SetYMin(0);

// Setup color for gradient fill style
$tcol=array(100,100,255);
$fcol=array(255,100,100);
//$bplot->SetFillGradient($fcol,$tcol,GRAD_HOR);
//setup different colors for bars
$bplot->SetFillColor($colors =array(“green”,”blue”,”red”,”gray4″));
$bplot->SetLegend($legends=array(‘x’,’y’,’r’,’z’));//=array(‘appraiser%’));//,”appraisee%”,”subordinate%”,”peer%”));
//display the value on top of each bar
$bplot->value->show();

$graph->Add($bplot);

// Set up the title for the graph
$graph->title->Set(“Bargraph of four evaluators’ Percent values”);
$graph->title->SetColor(“yellow”);
$graph->title->SetFont(FF_VERDANA,FS_BOLD,12);
//add the space at the top of the scale by using SetGrace().
$graph->yaxis->scale->SetGrace(20);
//$graph->legend->SetLayout(Legend_HOR);

// Setup color for axis and labels
$graph->xaxis->SetColor(“black”,”white”);
$graph->yaxis->SetColor(“black”,”white”);

// Setup font for axis
$graph->xaxis->SetFont(FF_VERDANA,FS_NORMAL,10);
$graph->yaxis->SetFont(FF_VERDANA,FS_NORMAL,10);

// Setup X-axis title (color & font)
$graph->xaxis->title->Set(“Four Evaluators”);
$graph->xaxis->title->SetColor(“white”);
$graph->xaxis->title->SetFont(FF_VERDANA,FS_BOLD,10);

$graph->yaxis->title->Set(“Percentage Value”);
$graph->yaxis->title->SetColor(“white”);
$graph->yaxis->title->SetFont(FF_VERDANA,FS_BOLD,10);
$graph->yaxis->SetLabelAlign(‘center’,’right’);

// Finally send the graph to the browser
$graph->Stroke();
?>

Please help me.

Regards,
wasantha

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @wasantha spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.4,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...