111 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
114 $this->bordercolor = array(235, 235, 224);
115 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
116 $this->bgcolor = array(235, 235, 224);
119 if (!empty($conf->dol_optimize_smallscreen)) {
124 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
125 if (is_readable($color_file)) {
127 if (isset($theme_bordercolor)) {
128 $this->bordercolor = $theme_bordercolor;
130 if (isset($theme_datacolor)) {
131 $this->datacolor = $theme_datacolor;
133 if (isset($theme_bgcolor)) {
134 $this->bgcolor = $theme_bgcolor;
139 $this->_library = $library;
140 if ($this->_library ==
'auto') {
141 $this->_library = (!
getDolGlobalString(
'MAIN_JS_GRAPH') ?
'chart' : $conf->global->MAIN_JS_GRAPH);
785 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
787 if (empty($this->width) && empty($this->height)) {
788 print
'Error width or height not set';
794 if (is_array($this->data) && is_array($this->data[0])) {
795 $nblot = count($this->data[0]) - 1;
798 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
806 while ($i < $nblot) {
808 $series[$i] =
"var d" . $i .
" = [];\n";
812 foreach ($this->data as $valarray) {
813 $legends[$x] = $valarray[0];
814 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
818 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
819 foreach ($values as $x => $y) {
821 $series[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
825 foreach ($values as $x => $y) {
827 $series[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
837 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
838 if (!empty($this->title)) {
839 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
841 if (!empty($this->shownographyet)) {
842 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
843 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
848 $dolxaxisvertical =
'';
849 if (count($this->data) > 20) {
850 $dolxaxisvertical =
'dol-xaxis-vertical';
852 $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";
854 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
855 $this->stringtoshow .=
'$(function () {' .
"\n";
858 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
860 while ($i < $nblot) {
861 $this->stringtoshow .=
'<!-- Series ' . $i .
' -->' .
"\n";
862 $this->stringtoshow .= $series[$i] .
"\n";
866 $this->stringtoshow .=
"\n";
869 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
870 $datacolor = array();
871 foreach ($this->datacolor as $val) {
872 if (is_array($val)) {
873 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
875 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
880 $showlegend = $this->showlegend;
881 $showpointvalue = $this->showpointvalue;
882 $showpercent = $this->showpercent;
884 $this->stringtoshow .=
'
885 function plotWithOptions_' . $tag .
'() {
886 $.plot($("#placeholder_' . $tag .
'"), d0,
892 ' . ($this->combine ?
'
894 threshold: ' . $this->combine .
'
899 formatter: function(label, series) {
900 var percent=Math.round(series.percent);
901 var number=series.data[0][1];
903 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
905 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
907 $this->stringtoshow .=
'\'+
';
908 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
909 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
910 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
911 $this->stringtoshow .=
'\'';
913 $this->stringtoshow .=
'</a>';
915 $this->stringtoshow .=
'</span>\';
930 if (count($datacolor)) {
931 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
933 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
940 $this->stringtoshow .=
'
941 function showTooltip_' . $tag .
'(x, y, contents) {
942 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
943 position: \'absolute\',
947 border: \'1px solid #000\',
949 \'background-color\': \'#000\',
951 \'font-weight\': \'bold\',
954 }).appendTo("body").fadeIn(100);
957 var previousPoint = null;
958 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
959 $("#x").text(pos.x.toFixed(2));
960 $("#y").text(pos.y.toFixed(2));
963 if (previousPoint != item.dataIndex) {
964 previousPoint = item.dataIndex;
966 $("#tooltip").remove();
967 /* console.log(item); */
968 var x = item.datapoint[0].toFixed(2);
969 var y = item.datapoint[1].toFixed(2);
970 var z = item.series.xaxis.ticks[item.dataIndex].label;
972 if ($this->showpointvalue > 0) {
973 $this->stringtoshow .=
'
974 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
977 $this->stringtoshow .=
'
981 $("#tooltip_' . $tag .
'").remove();
982 previousPoint = null;
987 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
989 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
990 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
992 while ($i < $nblot) {
993 if ($i > $firstlot) {
994 $this->stringtoshow .=
', ' .
"\n";
996 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
997 $this->stringtoshow .=
'{ ';
998 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
1000 if ($i == $firstlot) {
1002 } elseif ($i == $firstlot + 1) {
1007 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
1009 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
1012 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
1013 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1015 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1019 $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";
1022 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1024 foreach ($this->data as $key => $valarray) {
1026 $this->stringtoshow .=
', ' .
"\n";
1028 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1031 $this->stringtoshow .=
'] }' .
"\n";
1034 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1037 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1038 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1039 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1040 $this->stringtoshow .=
'});' .
"\n";
1041 $this->stringtoshow .=
'}' .
"\n";
1044 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1045 $this->stringtoshow .=
'});' .
"\n";
1046 $this->stringtoshow .=
'</script>' .
"\n";
1072 dol_syslog(get_class($this) .
"::draw_chart this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1074 if (empty($this->width) && empty($this->height)) {
1075 print
'Error width or height not set';
1079 $showlegend = $this->showlegend;
1084 if (is_array($this->data)) {
1085 foreach ($this->data as $valarray) {
1086 $nblot = max($nblot, count($valarray) - 1);
1091 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1098 $arrayofgroupslegend = array();
1102 while ($i < $nblot) {
1108 foreach ($this->data as $valarray) {
1109 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1110 $array_of_ykeys = array_keys($valarray);
1112 $tmpykey = explode(
'_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1113 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1114 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1115 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1116 $arrayofgroupslegend[$i] = array(
1117 'stacknum' => $tmpykey[1],
1118 'legend' => $this->Legend[$tmpykey[1]],
1119 'legendwithgroup' => $this->Legend[$tmpykey[1]] .
' - ' . $tmpykey[2]
1122 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1124 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1130 foreach ($values as $x => $y) {
1132 $series[$i] .= ($j > 0 ?
", " :
"") . $y;
1134 $series[$i] .= ($j > 0 ?
", " :
"") .
'null';
1147 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1148 if (!empty($this->title)) {
1149 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1151 if (!empty($this->shownographyet)) {
1152 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1153 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1158 $dolxaxisvertical =
'';
1159 if (count($this->data) > 20) {
1160 $dolxaxisvertical =
'dol-xaxis-vertical';
1163 $cssfordiv =
'dolgraphchart';
1164 if (isset($this->
type[$firstlot])) {
1165 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1167 $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";
1168 $this->stringtoshow .=
'<canvas id="canvas_'.$tag.
'"></canvas></div>'.
"\n";
1170 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1173 $this->stringtoshow .=
'<!-- No series of data -->';
1175 while ($i < $nblot) {
1181 $this->stringtoshow .=
"\n";
1184 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1185 $type = $this->
type[$firstlot];
1187 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1190 $legendMaxLines = 0;
1193 if (empty($showlegend)) {
1194 $this->stringtoshow .=
'legend: { display: false }, ';
1196 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1197 if (!empty($legendMaxLines)) {
1198 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1200 $this->stringtoshow .=
' }, ' .
"\n";
1204 $this->stringtoshow .=
'plugins: { ';
1205 if (empty($showlegend)) {
1206 $this->stringtoshow .=
'legend: { display: false }, ';
1208 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1209 if (!empty($legendMaxLines)) {
1210 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1212 $this->stringtoshow .=
' }, ' .
"\n";
1214 $this->stringtoshow .=
' }, ' .
"\n";
1217 if ($this->
type[$firstlot] ==
'piesemicircle') {
1218 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1219 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1221 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1223 $this->stringtoshow .=
'backgroundColor: [';
1225 $foundnegativecolor = 0;
1226 foreach ($legends as $val) {
1228 $this->stringtoshow .=
', ' .
"\n";
1230 if (is_array($this->datacolor[$i])) {
1231 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1233 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1234 if (strpos($tmp,
'-') !==
false) {
1235 $foundnegativecolor++;
1236 $color =
'rgba(0,0,0,.0)';
1238 $color =
"#" . $tmp;
1241 $this->stringtoshow .=
"'" . $color .
"'";
1244 $this->stringtoshow .=
'], ' .
"\n";
1246 if ($foundnegativecolor) {
1247 $this->stringtoshow .=
'borderColor: [';
1249 foreach ($legends as $val) {
1251 $this->stringtoshow .=
', ' .
"\n";
1253 if (is_array($this->datacolor[$i])) {
1256 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1257 if (strpos($tmp,
'-') !==
false) {
1258 $color =
'#' . str_replace(
'-',
'', $tmp);
1263 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1266 $this->stringtoshow .=
']';
1268 $this->stringtoshow .=
'} } };' .
"\n";
1270 $this->stringtoshow .=
'
1271 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1272 var chart = new Chart(ctx, {
1273 // The type of chart we want to create
1274 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1281 foreach ($legends as $val) { // Loop on each series
1283 $this->stringtoshow .= ',
';
1285 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1289 $this->stringtoshow .=
'],
1292 while ($i < $nblot) {
1293 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1296 $this->stringtoshow .=
', ' .
"\n";
1298 $this->stringtoshow .=
'{' .
"\n";
1301 $this->stringtoshow .=
' data: [' . $series[$i] .
']';
1302 $this->stringtoshow .=
'}' .
"\n";
1305 $this->stringtoshow .=
']' .
"\n";
1306 $this->stringtoshow .=
'}' .
"\n";
1307 $this->stringtoshow .=
'});' .
"\n";
1313 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1314 $xaxis =
"indexAxis: 'y', ";
1316 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1321 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1322 $this->stringtoshow .= $xaxis;
1323 if ($this->showpointvalue == 2) {
1324 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1337 $this->stringtoshow .=
'plugins: { '.
"\n";
1338 if (empty($showlegend)) {
1339 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1341 $this->stringtoshow .=
'legend: { maxWidth: '.round(intval($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1343 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1344 $this->stringtoshow .= 'tooltip: { mode: \
'nearest\',
1346 if (is_array($this->tooltipsTitles)) {
1347 $this->stringtoshow .=
'
1348 title: function(tooltipItem, data) {
1349 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1350 return tooltipsTitle[tooltipItem[0].datasetIndex];
1353 if (is_array($this->tooltipsLabels)) {
1354 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1355 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1356 return tooltipslabels[tooltipItem.datasetIndex]
1359 $this->stringtoshow .=
'}},';
1361 $this->stringtoshow .=
"}, \n";
1383 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1384 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1386 if (is_array($this->tooltipsTitles)) {
1387 $this->stringtoshow .=
'
1388 title: function(tooltipItem, data) {
1389 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1390 return tooltipsTitle[tooltipItem[0].datasetIndex];
1393 if (is_array($this->tooltipsLabels)) {
1394 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1395 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1396 return tooltipslabels[tooltipItem.datasetIndex]
1399 $this->stringtoshow .=
'}},';
1401 $this->stringtoshow .=
'};';
1402 $this->stringtoshow .=
'
1403 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1404 var chart = new Chart(ctx, {
1405 // The type of chart we want to create
1406 type: \'' . $type .
'\',
1413 foreach ($legends as $val) { // Loop on each series
1415 $this->stringtoshow .= ',
';
1417 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1421 //var_dump($arrayofgroupslegend);
1423 $this->stringtoshow .= '],
1426 global $theme_datacolor;
1427 '@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
';
1428 //var_dump($arrayofgroupslegend);
1432 while ($i < $nblot) { // Loop on each series
1433 $foundnegativecolor = 0;
1434 $usecolorvariantforgroupby = 0;
1435 // We used a 'group by
' and we have too many colors so we generated color variants per
1436 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1437 $nbofcolorneeds = count($arrayofgroupslegend);
1438 $nbofcolorsavailable = count($theme_datacolor);
1439 if ($nbofcolorneeds > $nbofcolorsavailable) {
1440 $usecolorvariantforgroupby = 1;
1443 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1445 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1448 if ($usecolorvariantforgroupby) {
1449 $newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum
']];
1450 // If we change the stack
1451 if ($oldstacknum == -1 || $arrayofgroupslegend[$i]['stacknum
'] != $oldstacknum) {
1455 //var_dump($iinstack);
1457 // Change color with offset of $iinstack
1458 //var_dump($newcolor);
1459 if ($iinstack % 2) { // We increase aggressiveness of reference color for color 2, 4, 6, ...
1460 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1461 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1462 } else { // We decrease aggressiveness of reference color for color 3, 5, 7, ..
1463 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1464 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1466 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1468 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1470 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1472 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1473 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1474 } else { // We do not use a 'group by
'
1475 if (!empty($this->datacolor[$i])) {
1476 if (is_array($this->datacolor[$i])) {
1477 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1479 $color = $this->datacolor[$i];
1482 // else: $color will be undefined
1483 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1484 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1486 if ($type != 'horizontalBar
') {
1487 $bordercolor = $color;
1489 $bordercolor = $this->bordercolor[$i];
1493 // For negative colors, we invert border and background
1494 $tmp = str_replace('#
', '', $color);
1495 if (strpos($tmp, '-
') !== false) {
1496 $foundnegativecolor++;
1497 $bordercolor = str_replace('-
', '', $color);
1498 $color = '#FFFFFF
'; // If $val is '-123
'
1502 $this->stringtoshow .= ',
';
1504 $this->stringtoshow .= "\n";
1505 $this->stringtoshow .= '{
';
1506 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1508 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1509 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1510 if ($type == 'bar
' || $type == 'horizontalBar
') {
1511 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1513 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1514 $this->stringtoshow .= 'borderSkipped: \
'' . $this->borderskip .
'\',
';
1515 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1516 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1517 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1519 $this->stringtoshow .= 'data: [
';
1521 $this->stringtoshow .= $this->mirrorGraphValues ? '[-
' . $series[$i] . ',
' . $series[$i] . ']
' : $series[$i];
1522 $this->stringtoshow .= ']
';
1523 $this->stringtoshow .= '}
' . "\n";
1528 $this->stringtoshow .= ']
' . "\n";
1529 $this->stringtoshow .= '}
' . "\n";
1530 $this->stringtoshow .= '});
' . "\n";
1533 $this->stringtoshow .= '</script>
' . "\n";