207 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
210 $this->bordercolor = array(235, 235, 224);
211 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
212 $this->bgcolor = array(235, 235, 224);
215 if (!empty(
$conf->dol_optimize_smallscreen)) {
220 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' .
$conf->theme .
'/theme_vars.inc.php';
221 if (is_readable($color_file)) {
223 if (isset($theme_bordercolor)) {
224 $this->bordercolor = $theme_bordercolor;
226 if (isset($theme_datacolor)) {
227 $this->datacolor = $theme_datacolor;
229 if (isset($theme_bgcolor)) {
230 $this->bgcolor = $theme_bgcolor;
235 $this->_library = $library;
236 if ($this->_library ==
'auto') {
886 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
888 if (empty($this->width) && empty($this->height)) {
889 print
'Error width or height not set';
895 if (is_array($this->data) && is_array($this->data[0])) {
896 $nblot = count($this->data[0]) - 1;
899 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
907 while ($i < $nblot) {
909 $series[$i] =
"var d" . $i .
" = [];\n";
913 foreach ($this->data as $valarray) {
914 $legends[$x] = $valarray[0];
915 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
919 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
920 foreach ($values as $x => $y) {
922 $series[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
926 foreach ($values as $x => $y) {
928 $series[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
938 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
939 if (!empty($this->title)) {
940 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
942 if (!empty($this->shownographyet)) {
943 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
944 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
949 $dolxaxisvertical =
'';
950 if (count($this->data) > 20) {
951 $dolxaxisvertical =
'dol-xaxis-vertical';
953 $this->stringtoshow .=
'<div id="placeholder_' . $tag .
'" style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="dolgraph' . (empty($dolxaxisvertical) ?
'' :
' ' . $dolxaxisvertical) . (empty($this->cssprefix) ?
'' :
' dolgraph' . $this->cssprefix) .
' center"></div>' .
"\n";
955 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
956 $this->stringtoshow .=
'$(function () {' .
"\n";
959 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
961 while ($i < $nblot) {
962 $this->stringtoshow .=
'<!-- Series ' . $i .
' -->' .
"\n";
963 $this->stringtoshow .= $series[$i] .
"\n";
967 $this->stringtoshow .=
"\n";
970 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
971 $datacolor = array();
972 foreach ($this->datacolor as $val) {
973 if (is_array($val)) {
974 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
976 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
981 $showlegend = $this->showlegend;
982 $showpointvalue = $this->showpointvalue;
983 $showpercent = $this->showpercent;
985 $this->stringtoshow .=
'
986 function plotWithOptions_' . $tag .
'() {
987 $.plot($("#placeholder_' . $tag .
'"), d0,
993 ' . ($this->combine ?
'
995 threshold: ' . $this->combine .
'
1000 formatter: function(label, series) {
1001 var percent=Math.round(series.percent);
1002 var number=series.data[0][1];
1004 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
1006 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
1008 $this->stringtoshow .=
'\'+
';
1009 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
1010 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
1011 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
1012 $this->stringtoshow .=
'\'';
1014 $this->stringtoshow .=
'</a>';
1016 $this->stringtoshow .=
'</span>\';
1031 if (count($datacolor)) {
1032 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
1034 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
1041 $this->stringtoshow .=
'
1042 function showTooltip_' . $tag .
'(x, y, contents) {
1043 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
1044 position: \'absolute\',
1048 border: \'1px solid #000\',
1050 \'background-color\': \'#000\',
1051 \'color\': \'#fff\',
1052 \'font-weight\': \'bold\',
1055 }).appendTo("body").fadeIn(100);
1058 var previousPoint = null;
1059 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
1060 $("#x").text(pos.x.toFixed(2));
1061 $("#y").text(pos.y.toFixed(2));
1064 if (previousPoint != item.dataIndex) {
1065 previousPoint = item.dataIndex;
1067 $("#tooltip").remove();
1068 /* console.log(item); */
1069 var x = item.datapoint[0].toFixed(2);
1070 var y = item.datapoint[1].toFixed(2);
1071 var z = item.series.xaxis.ticks[item.dataIndex].label;
1073 if ($this->showpointvalue > 0) {
1074 $this->stringtoshow .=
'
1075 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
1078 $this->stringtoshow .=
'
1082 $("#tooltip_' . $tag .
'").remove();
1083 previousPoint = null;
1088 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
1090 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
1091 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
1093 while ($i < $nblot) {
1094 if ($i > $firstlot) {
1095 $this->stringtoshow .=
', ' .
"\n";
1097 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
1098 $this->stringtoshow .=
'{ ';
1099 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
1101 if ($i == $firstlot) {
1103 } elseif ($i == $firstlot + 1) {
1108 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
1110 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
1113 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
1114 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1116 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1120 $this->stringtoshow .=
"\n" .
' ], { series: { shadowSize: 0, stack: stack, lines: { fill: false, steps: steps }, bars: { barWidth: 0.6, fillColor: { colors: [{opacity: 0.9 }, {opacity: 0.85}] }} }' .
"\n";
1123 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1125 foreach ($this->data as $key => $valarray) {
1127 $this->stringtoshow .=
', ' .
"\n";
1129 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1132 $this->stringtoshow .=
'] }' .
"\n";
1135 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1138 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1139 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1140 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1141 $this->stringtoshow .=
'});' .
"\n";
1142 $this->stringtoshow .=
'}' .
"\n";
1145 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1146 $this->stringtoshow .=
'});' .
"\n";
1147 $this->stringtoshow .=
'</script>' .
"\n";
1173 dol_syslog(get_class($this) .
"::draw_chart this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1175 if (empty($this->width) && empty($this->height)) {
1176 print
'Error width or height not set';
1180 $showlegend = $this->showlegend;
1185 if (is_array($this->data)) {
1186 foreach ($this->data as $valarray) {
1187 $nblot = max($nblot, count($valarray) - 1);
1192 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1199 '@phan-var-force array<int,array{stacknum:int,legend:string,legendwithgroup:string}> $arrayofgroupslegend';
1200 $arrayofgroupslegend = array();
1204 while ($i < $nblot) {
1210 foreach ($this->data as $valarray) {
1211 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1212 $array_of_ykeys = array_keys($valarray);
1214 $tmpykey = explode(
'_', (
string) ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1215 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1216 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1217 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1218 $arrayofgroupslegend[$i] = array(
1219 'stacknum' => (
int) $tmpykey[1],
1220 'legend' => $this->Legend[$tmpykey[1]] ??
'',
1221 'legendwithgroup' => ($this->Legend[$tmpykey[1]] ??
'') .
' - ' . $tmpykey[2]
1224 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1226 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1232 foreach ($values as $x => $y) {
1234 $series[$i] .= ($j > 0 ?
", " :
"") . $y;
1236 $series[$i] .= ($j > 0 ?
", " :
"") .
'null';
1249 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1250 if (!empty($this->title)) {
1251 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1253 if (!empty($this->shownographyet)) {
1254 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1255 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1260 $dolxaxisvertical =
'';
1261 if (count($this->data) > 20) {
1262 $dolxaxisvertical =
'dol-xaxis-vertical';
1265 $cssfordiv =
'dolgraphchart';
1266 if (isset($this->
type[$firstlot])) {
1267 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1269 $this->stringtoshow .=
'<div id="placeholder_'.$tag.
'" style="min-height: '.$this->height.(strpos((
string) $this->height,
'%') > 0 ?
'' :
'px').
'; max-height: '.(strpos((
string) $this->height,
'%') > 0 ? $this->height : ((int) $this->height + 100) .
'px').
'; width:'.$this->width.(strpos((
string) $this->width,
'%') > 0 ?
'' :
'px').
';" class="'.$cssfordiv.
' dolgraph'.(empty($dolxaxisvertical) ?
'' :
' '.$dolxaxisvertical).(empty($this->cssprefix) ?
'' :
' dolgraph'.$this->cssprefix).
' center">'.
"\n";
1270 $this->stringtoshow .=
'<canvas id="canvas_'.$tag.
'"></canvas></div>'.
"\n";
1272 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1275 $this->stringtoshow .=
'<!-- No series of data -->';
1277 while ($i < $nblot) {
1283 $this->stringtoshow .=
"\n";
1286 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1287 $type = $this->
type[$firstlot];
1289 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1292 $legendMaxLines = 0;
1295 if (empty($showlegend)) {
1296 $this->stringtoshow .=
'legend: { display: false }, ';
1298 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1299 if (!empty($legendMaxLines)) {
1300 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1302 $this->stringtoshow .=
' }, ' .
"\n";
1306 $this->stringtoshow .=
'plugins: { ';
1307 if (empty($showlegend)) {
1308 $this->stringtoshow .=
'legend: { display: false }, ';
1310 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1311 if (!empty($legendMaxLines)) {
1312 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1314 $this->stringtoshow .=
' }, ' .
"\n";
1316 $this->stringtoshow .=
' }, ' .
"\n";
1319 if ($this->
type[$firstlot] ==
'piesemicircle') {
1320 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1321 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1323 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1325 $this->stringtoshow .=
'backgroundColor: [';
1327 $foundnegativecolor = 0;
1328 foreach ($legends as $val) {
1330 $this->stringtoshow .=
', ' .
"\n";
1332 if (is_array($this->datacolor[$i])) {
1333 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1335 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1336 if (strpos($tmp,
'-') !==
false) {
1337 $foundnegativecolor++;
1338 $color =
'rgba(0,0,0,.0)';
1340 $color =
"#" . $tmp;
1343 $this->stringtoshow .=
"'" . $color .
"'";
1346 $this->stringtoshow .=
'], ' .
"\n";
1348 if ($foundnegativecolor) {
1349 $this->stringtoshow .=
'borderColor: [';
1351 foreach ($legends as $val) {
1353 $this->stringtoshow .=
', ' .
"\n";
1355 if ($this->datacolor !==
null) {
1356 $datacolor_item = $this->datacolor[$i];
1358 $datacolor_item =
null;
1361 if (is_array($datacolor_item) || $datacolor_item ===
null) {
1364 $tmpcolor = str_replace(
'#',
'', $datacolor_item);
1365 if (strpos($tmpcolor,
'-') !==
false) {
1366 $color =
'#' . str_replace(
'-',
'', $tmpcolor);
1371 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1374 $this->stringtoshow .=
']';
1376 $this->stringtoshow .=
'} } };' .
"\n";
1378 $this->stringtoshow .=
'
1379 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1380 var chart = new Chart(ctx, {
1381 // The type of chart we want to create
1382 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1389 foreach ($legends as $val) { // Loop on each series
1391 $this->stringtoshow .= ',
';
1393 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1397 $this->stringtoshow .=
'],
1400 while ($i < $nblot) {
1401 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1404 $this->stringtoshow .=
', ' .
"\n";
1406 $this->stringtoshow .=
'{' .
"\n";
1409 $this->stringtoshow .=
' data: [' . $series[$i] .
']';
1410 $this->stringtoshow .=
'}' .
"\n";
1413 $this->stringtoshow .=
']' .
"\n";
1414 $this->stringtoshow .=
'}' .
"\n";
1415 $this->stringtoshow .=
'});' .
"\n";
1421 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1422 $xaxis =
"indexAxis: 'y', ";
1424 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1429 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1430 $this->stringtoshow .= $xaxis;
1431 if ($this->showpointvalue == 2) {
1432 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1445 $this->stringtoshow .=
'plugins: { '.
"\n";
1446 if (empty($showlegend)) {
1447 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1449 $this->stringtoshow .=
'legend: { maxWidth: '.round(intval($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1451 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1452 $this->stringtoshow .= 'tooltip: { mode: \
'nearest\',
1454 if (is_array($this->tooltipsTitles)) {
1455 $this->stringtoshow .=
'
1456 title: function(tooltipItem, data) {
1457 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1458 return tooltipsTitle[tooltipItem[0].datasetIndex];
1461 if (is_array($this->tooltipsLabels)) {
1462 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1463 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1464 return tooltipslabels[tooltipItem.datasetIndex]
1467 $this->stringtoshow .=
'}},';
1469 $this->stringtoshow .=
"}, \n";
1491 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1492 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1494 if (is_array($this->tooltipsTitles)) {
1495 $this->stringtoshow .=
'
1496 title: function(tooltipItem, data) {
1497 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1498 return tooltipsTitle[tooltipItem[0].datasetIndex];
1501 if (is_array($this->tooltipsLabels)) {
1502 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1503 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1504 return tooltipslabels[tooltipItem.datasetIndex]
1507 $this->stringtoshow .=
'}},';
1509 $this->stringtoshow .=
'};';
1510 $this->stringtoshow .=
'
1511 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1512 var chart = new Chart(ctx, {
1513 // The type of chart we want to create
1514 type: \'' . $type .
'\',
1521 foreach ($legends as $val) { // Loop on each series
1523 $this->stringtoshow .= ',
';
1525 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1529 //var_dump($arrayofgroupslegend);
1531 $this->stringtoshow .= '],
1534 global $theme_datacolor;
1535 '@phan-var-force array{0:array{0:int,1:int,2:
int},1:array{0:int,1:int,2:
int},2:array{0:int,1:int,2:
int},3:array{0:int,1:int,2:
int}} $theme_datacolor
';
1536 //var_dump($arrayofgroupslegend);
1541 while ($i < $nblot) { // Loop on each series
1542 $foundnegativecolor = 0;
1543 $usecolorvariantforgroupby = 0;
1544 // We used a 'group by
' and we have too many colors so we generated color variants per
1545 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1546 $nbofcolorneeds = count($arrayofgroupslegend);
1547 $nbofcolorsavailable = count($theme_datacolor);
1548 if ($nbofcolorneeds > $nbofcolorsavailable) {
1549 $usecolorvariantforgroupby = 1;
1552 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1554 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1557 if ($usecolorvariantforgroupby) {
1558 $idx = $arrayofgroupslegend[$i]['stacknum
'];
1560 $newcolor = $this->datacolor[$idx];
1561 // If we change the stack
1562 if ($oldstacknum == -1 || $idx != $oldstacknum) {
1566 //var_dump($iinstack);
1568 // Change color with offset of $iinstack
1569 //var_dump($newcolor);
1570 if ($iinstack % 2) { // We increase aggressiveness of reference color for color 2, 4, 6, ...
1571 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1572 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1573 } else { // We decrease aggressiveness of reference color for color 3, 5, 7, ..
1574 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1575 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1577 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1579 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1581 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1583 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1584 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1585 } else { // We do not use a 'group by
'
1586 if (!empty($this->datacolor[$i])) {
1587 if (is_array($this->datacolor[$i])) {
1588 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1590 $color = $this->datacolor[$i];
1593 // else: $color will be undefined
1594 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1595 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1597 if ($type != 'horizontalBar
') {
1598 $bordercolor = $color;
1600 $bordercolor = $this->bordercolor[$i];
1604 // For negative colors, we invert border and background
1605 $tmp = str_replace('#
', '', $color);
1606 if (strpos($tmp, '-
') !== false) {
1607 $foundnegativecolor++;
1608 $bordercolor = str_replace('-
', '', $color);
1609 $color = '#FFFFFF
'; // If $val is '-123
'
1613 $this->stringtoshow .= ',
';
1615 $this->stringtoshow .= "\n";
1616 $this->stringtoshow .= '{
';
1617 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1619 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1620 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1621 if ($type == 'bar
' || $type == 'horizontalBar
') {
1622 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1624 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1625 $this->stringtoshow .= 'borderSkipped: \
'' . $this->borderskip .
'\',
';
1626 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1627 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1628 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1630 $this->stringtoshow .= 'data: [
';
1632 $this->stringtoshow .= $this->mirrorGraphValues ? '[-
' . $series[$i] . ',
' . $series[$i] . ']
' : $series[$i];
1633 $this->stringtoshow .= ']
';
1634 $this->stringtoshow .= '}
' . "\n";
1639 $this->stringtoshow .= ']
' . "\n";
1640 $this->stringtoshow .= '}
' . "\n";
1641 $this->stringtoshow .= '});
' . "\n";
1644 $this->stringtoshow .= '</script>
' . "\n";