PHP: gChartPHP - adding visible values to pie charts
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)"
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");
?>
精彩评论