rashmi_k28 Posted October 14, 2008 Share Posted October 14, 2008 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 More sharing options...
rashmi_k28 Posted October 14, 2008 Author Share Posted October 14, 2008 $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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.