0

I'm using the gchart php wrapper from http://code.google.com/p/gchartphp/. This is a question for anyone out there using it.

Can you visibly display the values that make up slices of a pie chart?

<?php
$piChart = new gPieChart();
$piChart->setDimensions(650,300);
$piChart->addDataSet(array_values($type));
$piChart->setLabels(array_keys($type));
$piChart->setColors(array("F26134", "F1F1F1","FFC7A8","E6E6E6","171717"));
$piChart->setTitle("All Tickets by Issue Type");
?>

<img src="<?php print $piChart->getUrl();  ?>" /> 

Is it possible that for each slice it shows this sort of format - "label (15)"

Raj
  • 22,346
  • 14
  • 99
  • 142
iamjonesy
  • 24,732
  • 40
  • 139
  • 206

1 Answers1

2

You can always modify your labels so that they fit in the format you want. For example, this will format your label into the format "Name (Value)" :

<?php
function formatLabel(&$item, $key, $arr) {
    $item = $item . ' (' . $arr[$item] . ')';
}

$keys = array_keys($type);
array_walk($keys, 'formatLabel', $type);

$piChart = new gPieChart();
$piChart->setDimensions(650,300);
$piChart->addDataSet(array_values($type));
$piChart->setLabels($keys);
$piChart->setColors(array("F26134", "F1F1F1","FFC7A8","E6E6E6","171717"));
$piChart->setTitle("All Tickets by Issue Type");
?>
HoLyVieR
  • 10,985
  • 5
  • 42
  • 67
  • 1
    fantastic! I just didn't think about doing it that way! it gives me much more flexibility too! thanks! – iamjonesy Sep 03 '10 at 13:07