Jump to content

assign Values


rashmi_k28

Recommended Posts

The values of $param varies.

 

How to assign the $dplot[] dynamically when the $param values increases or decreases.

 

The dplot[]=new LinePLot($values[''] should be dynamically assigned the value.

 

 


$param=array('bw','cpu','au','gs','cnt');

$dplot[] = new LinePLot($values['bw']);
$dplot[0]->SetFillColor("antiquewhite");
$dplot[0]->SetLegend('BW');



$dplot[] = new LinePLot($values['cpu']);
$dplot[1]->SetFillColor("aquamarine4");
$dplot[1]->SetLegend('CPU');


$dplot[] = new LinePLot($values['au']);
$dplot[2]->SetFillColor("cadetblue4");
$dplot[2]->SetLegend('AU');


$dplot[] = new LinePLot($values['gs']);
$dplot[3]->SetFillColor("darkgoldenrod");
$dplot[3]->SetLegend('GS');

$dplot[] = new LinePLot($values['cnt']);
$dplot[4]->SetFillColor("darkorchid");
$dplot[4]->SetLegend('CNT');

 

 

Please help me

Link to comment
https://forums.phpfreaks.com/topic/128334-assign-values/
Share on other sites

$param=array("bw","cpu","auser","gs","cnt");
$color=array("antiquewhite","aquamarine4","cadetblue4","darkgoldenrod","darkorchid");
$legend=array("bw","CPU","AUser","GS","Cnt");


foreach($param as $p){
$dplot[]=new LinePLot($values[$p]);
}


for ($i=0; $i <= 4; $i++) {                     
  $dplot[$i]->SetFillColor($color[$i]);
  $dplot[$i]->SetLegend($param[$i]);       
}

 

 

 

Code:

 

$param=array("bw","cpu","auser","gs","cnt");

$color=array("antiquewhite","aquamarine4","cadetblue4","darkgoldenrod","darkorchid");

$legend=array("bw","CPU","AUser","GS","Cnt");

 

 

foreach($param as $p){

$dplot[]=new LinePLot($values[$p]);

}

 

 

for ($i=0; $i <= 4; $i++) {                   

  $dplot[$i]->SetFillColor($color[$i]);

  $dplot[$i]->SetLegend($param[$i]);     

}

 

 

I tried this way. It works but when I select $param as $param=array("bw","gs");

 

Then the color and legend will not change as bw and GS. It shows some other value. How to select the color and legend based on the value of $param

Link to comment
https://forums.phpfreaks.com/topic/128334-assign-values/#findComment-664822
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.