Jump to content

[SOLVED] Pie Chart, hidden text


MasterACE14

Recommended Posts

Hello,

 

I have a script which is creating a pie chart, it's working fine except the text in the center of the chart is hidden behind the Imagefilledarc();

 

How can I bring it to the front?

 

<?php
header ("Content-type: image/png");

$_GET['percent'] = (int)$_GET['percent'];
if($_GET['percent'] >= 0 && $_GET['percent'] <= 100) {
	$percent = round($_GET['percent']);
	if($percent == 100) {
		$shift = 35;
	}
	if($percent >= 10 && $percent <= 99) {
		$shift = 39;
	}
	if($percent >= 0 && $percent <= 9) {
		$shift = 44;
	}
	$percent = $percent."%";
}
   
 $width = 100;
 $height = 100;
     $im = ImageCreate($width, $height);
     $grey = ImageColorAllocate($im, 200, 200, 200);
     $black = ImageColorAllocate($im, 0, 0, 0);
 $white = ImageColorAllocate($im, 150, 150, 150);

 Imagecolortransparent($im, $grey);
     ImageString($im, 5, $shift, 40, $percent, $white);
     ImageArc($im, 50, 50, 90, 90, 0, 360, $black);
 ImageFilledArc($im, 50, 50, 90, 90, 50, 360, $black, IMG_ARC_PIE);
     ImagePng($im);
     ImageDestroy($im);
?>

 

Regards, Ace

Link to comment
https://forums.phpfreaks.com/topic/168119-solved-pie-chart-hidden-text/
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.