209 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
212 $this->bordercolor = array(235, 235, 224);
213 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
214 $this->bgcolor = array(235, 235, 224);
217 if (!empty(
$conf->dol_optimize_smallscreen)) {
222 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' .
$conf->theme .
'/theme_vars.inc.php';
223 if (is_readable($color_file)) {
225 if (isset($theme_bordercolor)) {
226 $this->bordercolor = $theme_bordercolor;
228 if (isset($theme_datacolor)) {
229 $this->datacolor = $theme_datacolor;
231 if (isset($theme_bgcolor)) {
232 $this->bgcolor = $theme_bgcolor;
237 $this->_library = $library;
238 if ($this->_library ==
'auto') {
888 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
890 if (empty($this->width) && empty($this->height)) {
891 print
'Error width or height not set';
897 if (is_array($this->data) && is_array($this->data[0])) {
898 $nblot = count($this->data[0]) - 1;
901 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
909 while ($i < $nblot) {
911 $series[$i] =
"var d" . $i .
" = [];\n";
915 foreach ($this->data as $valarray) {
916 $legends[$x] = $valarray[0];
917 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
921 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
922 foreach ($values as $x => $y) {
924 $series[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
928 foreach ($values as $x => $y) {
930 $series[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
940 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
941 if (!empty($this->title)) {
942 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
944 if (!empty($this->shownographyet)) {
945 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
946 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
951 $dolxaxisvertical =
'';
952 if (count($this->data) > 20) {
953 $dolxaxisvertical =
'dol-xaxis-vertical';
955 $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";
957 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
958 $this->stringtoshow .=
'$(function () {' .
"\n";
961 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
963 while ($i < $nblot) {
964 $this->stringtoshow .=
'<!-- Series ' . $i .
' -->' .
"\n";
965 $this->stringtoshow .= $series[$i] .
"\n";
969 $this->stringtoshow .=
"\n";
972 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
973 $datacolor = array();
974 foreach ($this->datacolor as $val) {
975 if (is_array($val)) {
976 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
978 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
983 $showlegend = $this->showlegend;
984 $showpointvalue = $this->showpointvalue;
985 $showpercent = $this->showpercent;
987 $this->stringtoshow .=
'
988 function plotWithOptions_' . $tag .
'() {
989 $.plot($("#placeholder_' . $tag .
'"), d0,
995 ' . ($this->combine ?
'
997 threshold: ' . $this->combine .
'
1002 formatter: function(label, series) {
1003 var percent=Math.round(series.percent);
1004 var number=series.data[0][1];
1006 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
1008 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
1010 $this->stringtoshow .=
'\'+
';
1011 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
1012 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
1013 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
1014 $this->stringtoshow .=
'\'';
1016 $this->stringtoshow .=
'</a>';
1018 $this->stringtoshow .=
'</span>\';
1033 if (count($datacolor)) {
1034 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
1036 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
1043 $this->stringtoshow .=
'
1044 function showTooltip_' . $tag .
'(x, y, contents) {
1045 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
1046 position: \'absolute\',
1050 border: \'1px solid #000\',
1052 \'background-color\': \'#000\',
1053 \'color\': \'#fff\',
1054 \'font-weight\': \'bold\',
1057 }).appendTo("body").fadeIn(100);
1060 var previousPoint = null;
1061 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
1062 $("#x").text(pos.x.toFixed(2));
1063 $("#y").text(pos.y.toFixed(2));
1066 if (previousPoint != item.dataIndex) {
1067 previousPoint = item.dataIndex;
1069 $("#tooltip").remove();
1070 /* console.log(item); */
1071 var x = item.datapoint[0].toFixed(2);
1072 var y = item.datapoint[1].toFixed(2);
1073 var z = item.series.xaxis.ticks[item.dataIndex].label;
1075 if ($this->showpointvalue > 0) {
1076 $this->stringtoshow .=
'
1077 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
1080 $this->stringtoshow .=
'
1084 $("#tooltip_' . $tag .
'").remove();
1085 previousPoint = null;
1090 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
1092 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
1093 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
1095 while ($i < $nblot) {
1096 if ($i > $firstlot) {
1097 $this->stringtoshow .=
', ' .
"\n";
1099 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
1100 $this->stringtoshow .=
'{ ';
1101 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
1103 if ($i == $firstlot) {
1105 } elseif ($i == $firstlot + 1) {
1110 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
1112 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
1115 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
1116 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1118 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1122 $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";
1125 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1127 foreach ($this->data as $key => $valarray) {
1129 $this->stringtoshow .=
', ' .
"\n";
1131 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1134 $this->stringtoshow .=
'] }' .
"\n";
1137 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1140 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1141 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1142 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1143 $this->stringtoshow .=
'});' .
"\n";
1144 $this->stringtoshow .=
'}' .
"\n";
1147 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1148 $this->stringtoshow .=
'});' .
"\n";
1149 $this->stringtoshow .=
'</script>' .
"\n";
1175 dol_syslog(get_class($this) .
"::draw_chart this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1177 if (empty($this->width) && empty($this->height)) {
1178 print
'Error width or height not set';
1182 $showlegend = $this->showlegend;
1187 if (is_array($this->data)) {
1188 foreach ($this->data as $valarray) {
1189 $nblot = max($nblot, count($valarray) - 1);
1194 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1201 '@phan-var-force array<int,array{stacknum:int,legend:string,legendwithgroup:string}> $arrayofgroupslegend';
1202 $arrayofgroupslegend = array();
1206 while ($i < $nblot) {
1212 foreach ($this->data as $valarray) {
1213 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1214 $array_of_ykeys = array_keys($valarray);
1216 $tmpykey = explode(
'_', (
string) ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1217 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1218 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1219 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1220 $arrayofgroupslegend[$i] = array(
1221 'stacknum' => (
int) $tmpykey[1],
1222 'legend' => $this->Legend[$tmpykey[1]] ??
'',
1223 'legendwithgroup' => ($this->Legend[$tmpykey[1]] ??
'') .
' - ' . $tmpykey[2]
1226 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1228 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1234 foreach ($values as $x => $y) {
1236 $series[$i] .= ($j > 0 ?
", " :
"") . $y;
1238 $series[$i] .= ($j > 0 ?
", " :
"") .
'null';
1251 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1252 if (!empty($this->title)) {
1253 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1255 if (!empty($this->shownographyet)) {
1256 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1257 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1262 $dolxaxisvertical =
'';
1263 if (count($this->data) > 20) {
1264 $dolxaxisvertical =
'dol-xaxis-vertical';
1267 $cssfordiv =
'dolgraphchart';
1268 if (isset($this->
type[$firstlot])) {
1269 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1271 $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";
1272 $this->stringtoshow .=
'<canvas id="canvas_'.$tag.
'"></canvas></div>'.
"\n";
1274 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1277 $this->stringtoshow .=
'<!-- No series of data -->';
1279 while ($i < $nblot) {
1285 $this->stringtoshow .=
"\n";
1288 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1289 $type = $this->
type[$firstlot];
1291 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1294 $legendMaxLines = 0;
1297 if (empty($showlegend)) {
1298 $this->stringtoshow .=
'legend: { display: false }, ';
1300 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1301 if (!empty($legendMaxLines)) {
1302 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1304 $this->stringtoshow .=
' }, ' .
"\n";
1308 $this->stringtoshow .=
'plugins: { ';
1309 if (empty($showlegend)) {
1310 $this->stringtoshow .=
'legend: { display: false }, ';
1312 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1313 if (!empty($legendMaxLines)) {
1314 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1316 $this->stringtoshow .=
' }, ' .
"\n";
1318 $this->stringtoshow .=
' }, ' .
"\n";
1321 if ($this->
type[$firstlot] ==
'piesemicircle') {
1322 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1323 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1325 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1327 $this->stringtoshow .=
'backgroundColor: [';
1329 $foundnegativecolor = 0;
1330 foreach ($legends as $val) {
1332 $this->stringtoshow .=
', ' .
"\n";
1334 if (is_array($this->datacolor[$i])) {
1335 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1337 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1338 if (strpos($tmp,
'-') !==
false) {
1339 $foundnegativecolor++;
1340 $color =
'rgba(0,0,0,.0)';
1342 $color =
"#" . $tmp;
1345 $this->stringtoshow .=
"'" . $color .
"'";
1348 $this->stringtoshow .=
'], ' .
"\n";
1350 if ($foundnegativecolor) {
1351 $this->stringtoshow .=
'borderColor: [';
1353 foreach ($legends as $val) {
1355 $this->stringtoshow .=
', ' .
"\n";
1357 if ($this->datacolor !==
null) {
1358 $datacolor_item = $this->datacolor[$i];
1360 $datacolor_item =
null;
1363 if (is_array($datacolor_item) || $datacolor_item ===
null) {
1366 $tmpcolor = str_replace(
'#',
'', $datacolor_item);
1367 if (strpos($tmpcolor,
'-') !==
false) {
1368 $color =
'#' . str_replace(
'-',
'', $tmpcolor);
1373 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1376 $this->stringtoshow .=
']';
1378 $this->stringtoshow .=
'} } };' .
"\n";
1380 $this->stringtoshow .=
'
1381 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1382 var chart = new Chart(ctx, {
1383 // The type of chart we want to create
1384 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1391 foreach ($legends as $val) { // Loop on each series
1393 $this->stringtoshow .= ',
';
1395 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1399 $this->stringtoshow .=
'],
1402 while ($i < $nblot) {
1403 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1406 $this->stringtoshow .=
', ' .
"\n";
1408 $this->stringtoshow .=
'{' .
"\n";
1411 $this->stringtoshow .=
' data: [' . $series[$i] .
']';
1412 $this->stringtoshow .=
'}' .
"\n";
1415 $this->stringtoshow .=
']' .
"\n";
1416 $this->stringtoshow .=
'}' .
"\n";
1417 $this->stringtoshow .=
'});' .
"\n";
1423 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1424 $xaxis =
"indexAxis: 'y', ";
1426 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1431 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1432 $this->stringtoshow .= $xaxis;
1433 if ($this->showpointvalue == 2) {
1434 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1447 $this->stringtoshow .=
'plugins: { '.
"\n";
1448 if (empty($showlegend)) {
1449 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1451 $this->stringtoshow .=
'legend: { maxWidth: '.round(intval($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1453 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1454 $this->stringtoshow .= 'tooltip: { mode: \
'nearest\',
1456 if (is_array($this->tooltipsTitles)) {
1457 $this->stringtoshow .=
'
1458 title: function(tooltipItem, data) {
1459 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1460 return tooltipsTitle[tooltipItem[0].datasetIndex];
1463 if (is_array($this->tooltipsLabels)) {
1464 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1465 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1466 return tooltipslabels[tooltipItem.datasetIndex]
1469 $this->stringtoshow .=
'}},';
1471 $this->stringtoshow .=
"}, \n";
1493 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1494 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1496 if (is_array($this->tooltipsTitles)) {
1497 $this->stringtoshow .=
'
1498 title: function(tooltipItem, data) {
1499 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1500 return tooltipsTitle[tooltipItem[0].datasetIndex];
1503 if (is_array($this->tooltipsLabels)) {
1504 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1505 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1506 return tooltipslabels[tooltipItem.datasetIndex]
1509 $this->stringtoshow .=
'}},';
1511 $this->stringtoshow .=
'};';
1512 $this->stringtoshow .=
'
1513 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1514 var chart = new Chart(ctx, {
1515 // The type of chart we want to create
1516 type: \'' . $type .
'\',
1523 foreach ($legends as $val) { // Loop on each series
1525 $this->stringtoshow .= ',
';
1527 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1531 //var_dump($arrayofgroupslegend);
1533 $this->stringtoshow .= '],
1536 global $theme_datacolor;
1537 '@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
';
1538 //var_dump($arrayofgroupslegend);
1543 while ($i < $nblot) { // Loop on each series
1544 $foundnegativecolor = 0;
1545 $usecolorvariantforgroupby = 0;
1546 // We used a 'group by
' and we have too many colors so we generated color variants per
1547 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1548 $nbofcolorneeds = count($arrayofgroupslegend);
1549 $nbofcolorsavailable = count($theme_datacolor);
1550 if ($nbofcolorneeds > $nbofcolorsavailable) {
1551 $usecolorvariantforgroupby = 1;
1554 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1556 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1559 if ($usecolorvariantforgroupby) {
1560 $idx = $arrayofgroupslegend[$i]['stacknum
'];
1562 $newcolor = $this->datacolor[$idx];
1563 // If we change the stack
1564 if ($oldstacknum == -1 || $idx != $oldstacknum) {
1568 //var_dump($iinstack);
1570 // Change color with offset of $iinstack
1571 //var_dump($newcolor);
1572 if ($iinstack % 2) { // We increase aggressiveness of reference color for color 2, 4, 6, ...
1573 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1574 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1575 } else { // We decrease aggressiveness of reference color for color 3, 5, 7, ..
1576 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1577 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1579 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1581 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1583 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1585 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1586 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1587 } else { // We do not use a 'group by
'
1588 if (!empty($this->datacolor[$i])) {
1589 if (is_array($this->datacolor[$i])) {
1590 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1592 $color = $this->datacolor[$i];
1595 // else: $color will be undefined
1596 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1597 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1599 if ($type != 'horizontalBar
') {
1600 $bordercolor = $color;
1602 $bordercolor = $this->bordercolor[$i];
1606 // For negative colors, we invert border and background
1607 $tmp = str_replace('#
', '', $color);
1608 if (strpos($tmp, '-
') !== false) {
1609 $foundnegativecolor++;
1610 $bordercolor = str_replace('-
', '', $color);
1611 $color = '#FFFFFF
'; // If $val is '-123
'
1615 $this->stringtoshow .= ',
';
1617 $this->stringtoshow .= "\n";
1618 $this->stringtoshow .= '{
';
1619 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1621 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1622 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1623 if ($type == 'bar
' || $type == 'horizontalBar
') {
1624 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1626 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1627 $this->stringtoshow .= 'borderSkipped: \
'' . $this->borderskip .
'\',
';
1628 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1629 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1630 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1632 $this->stringtoshow .= 'data: [
';
1634 $this->stringtoshow .= $this->mirrorGraphValues ? '[-
' . $series[$i] . ',
' . $series[$i] . ']
' : $series[$i];
1635 $this->stringtoshow .= ']
';
1636 $this->stringtoshow .= '}
' . "\n";
1641 $this->stringtoshow .= ']
' . "\n";
1642 $this->stringtoshow .= '}
' . "\n";
1643 $this->stringtoshow .= '});
' . "\n";
1646 $this->stringtoshow .= '</script>
' . "\n";