New: Graph js librairie can accept url to click on values.

This commit is contained in:
Laurent Destailleur
2011-06-06 22:34:10 +00:00
parent a3755324c0
commit f943f8775a

View File

@@ -1238,8 +1238,9 @@ function dolibarr_trunc($string,$size=40,$trunc='right',$stringencoding='')
* @param showlegend Show legend * @param showlegend Show legend
* @param type Type of graph ('pie', 'barline') * @param type Type of graph ('pie', 'barline')
* @param showpercent Show percent (with type='pie' only) * @param showpercent Show percent (with type='pie' only)
* @param url Param to add an url to click values
*/ */
function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',$showpercent=0) function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',$showpercent=0,$url='')
{ {
global $conf,$langs; global $conf,$langs;
global $theme_datacolor; // To have var kept when function is called several times global $theme_datacolor; // To have var kept when function is called several times
@@ -1301,9 +1302,14 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
formatter: function(label, series) { formatter: function(label, series) {
var percent=Math.round(series.percent); var percent=Math.round(series.percent);
var number=series.data[0][1]; var number=series.data[0][1];
return \'<div style="font-size:8pt;text-align:center;padding:2px;color:white;">\'+'.($showlegend?'number':'label+\'<br/>\'+number'); return \'';
print '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">';
if ($url) print '<a style="color: #FFFFFF;" border="0" href="'.$url.'=">';
print '\'+'.($showlegend?'number':'label+\'<br/>\'+number');
if (! empty($showpercent)) print '+\'<br/>\'+percent+\'%\''; if (! empty($showpercent)) print '+\'<br/>\'+percent+\'%\'';
print '+\'</div>\'; print '+\'';
if ($url) print '</a>';
print '</div>\';
}, },
background: { background: {
opacity: 0.5, opacity: 0.5,