112 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
115 $this->bordercolor = array(235, 235, 224);
116 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
117 $this->bgcolor = array(235, 235, 224);
120 if (!empty($conf->dol_optimize_smallscreen)) {
125 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
126 if (is_readable($color_file)) {
128 if (isset($theme_bordercolor)) {
129 $this->bordercolor = $theme_bordercolor;
131 if (isset($theme_datacolor)) {
132 $this->datacolor = $theme_datacolor;
134 if (isset($theme_bgcolor)) {
135 $this->bgcolor = $theme_bgcolor;
140 $this->_library = $library;
141 if ($this->_library ==
'auto') {
142 $this->_library = (!
getDolGlobalString(
'MAIN_JS_GRAPH') ?
'chart' : $conf->global->MAIN_JS_GRAPH);
786 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
788 if (empty($this->width) && empty($this->height)) {
789 print
'Error width or height not set';
795 if (is_array($this->data) && is_array($this->data[0])) {
796 $nblot = count($this->data[0]) - 1;
799 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
807 while ($i < $nblot) {
809 $series[$i] =
"var d" . $i .
" = [];\n";
813 foreach ($this->data as $valarray) {
814 $legends[$x] = $valarray[0];
815 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
819 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
820 foreach ($values as $x => $y) {
822 $series[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
826 foreach ($values as $x => $y) {
828 $series[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
838 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
839 if (!empty($this->title)) {
840 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
842 if (!empty($this->shownographyet)) {
843 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
844 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
849 $dolxaxisvertical =
'';
850 if (count($this->data) > 20) {
851 $dolxaxisvertical =
'dol-xaxis-vertical';
853 $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";
855 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
856 $this->stringtoshow .=
'$(function () {' .
"\n";
859 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
861 while ($i < $nblot) {
862 $this->stringtoshow .=
'<!-- Series ' . $i .
' -->' .
"\n";
863 $this->stringtoshow .= $series[$i] .
"\n";
867 $this->stringtoshow .=
"\n";
870 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
871 $datacolor = array();
872 foreach ($this->datacolor as $val) {
873 if (is_array($val)) {
874 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
876 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
881 $showlegend = $this->showlegend;
882 $showpointvalue = $this->showpointvalue;
883 $showpercent = $this->showpercent;
885 $this->stringtoshow .=
'
886 function plotWithOptions_' . $tag .
'() {
887 $.plot($("#placeholder_' . $tag .
'"), d0,
893 ' . ($this->combine ?
'
895 threshold: ' . $this->combine .
'
900 formatter: function(label, series) {
901 var percent=Math.round(series.percent);
902 var number=series.data[0][1];
904 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
906 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
908 $this->stringtoshow .=
'\'+
';
909 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
910 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
911 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
912 $this->stringtoshow .=
'\'';
914 $this->stringtoshow .=
'</a>';
916 $this->stringtoshow .=
'</span>\';
931 if (count($datacolor)) {
932 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
934 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
941 $this->stringtoshow .=
'
942 function showTooltip_' . $tag .
'(x, y, contents) {
943 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
944 position: \'absolute\',
948 border: \'1px solid #000\',
950 \'background-color\': \'#000\',
952 \'font-weight\': \'bold\',
955 }).appendTo("body").fadeIn(100);
958 var previousPoint = null;
959 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
960 $("#x").text(pos.x.toFixed(2));
961 $("#y").text(pos.y.toFixed(2));
964 if (previousPoint != item.dataIndex) {
965 previousPoint = item.dataIndex;
967 $("#tooltip").remove();
968 /* console.log(item); */
969 var x = item.datapoint[0].toFixed(2);
970 var y = item.datapoint[1].toFixed(2);
971 var z = item.series.xaxis.ticks[item.dataIndex].label;
973 if ($this->showpointvalue > 0) {
974 $this->stringtoshow .=
'
975 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
978 $this->stringtoshow .=
'
982 $("#tooltip_' . $tag .
'").remove();
983 previousPoint = null;
988 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
990 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
991 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
993 while ($i < $nblot) {
994 if ($i > $firstlot) {
995 $this->stringtoshow .=
', ' .
"\n";
997 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
998 $this->stringtoshow .=
'{ ';
999 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
1001 if ($i == $firstlot) {
1003 } elseif ($i == $firstlot + 1) {
1008 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
1010 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
1013 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
1014 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1016 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1020 $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";
1023 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1025 foreach ($this->data as $key => $valarray) {
1027 $this->stringtoshow .=
', ' .
"\n";
1029 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1032 $this->stringtoshow .=
'] }' .
"\n";
1035 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1038 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1039 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1040 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1041 $this->stringtoshow .=
'});' .
"\n";
1042 $this->stringtoshow .=
'}' .
"\n";
1045 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1046 $this->stringtoshow .=
'});' .
"\n";
1047 $this->stringtoshow .=
'</script>' .
"\n";
1073 dol_syslog(get_class($this) .
"::draw_chart this->type=" . implode(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1075 if (empty($this->width) && empty($this->height)) {
1076 print
'Error width or height not set';
1080 $showlegend = $this->showlegend;
1085 if (is_array($this->data)) {
1086 foreach ($this->data as $valarray) {
1087 $nblot = max($nblot, count($valarray) - 1);
1092 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1099 $arrayofgroupslegend = array();
1103 while ($i < $nblot) {
1109 foreach ($this->data as $valarray) {
1110 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1111 $array_of_ykeys = array_keys($valarray);
1113 $tmpykey = explode(
'_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1114 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1115 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1116 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1117 $arrayofgroupslegend[$i] = array(
1118 'stacknum' => $tmpykey[1],
1119 'legend' => $this->Legend[$tmpykey[1]],
1120 'legendwithgroup' => $this->Legend[$tmpykey[1]] .
' - ' . $tmpykey[2]
1123 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1125 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1131 foreach ($values as $x => $y) {
1133 $series[$i] .= ($j > 0 ?
", " :
"") . $y;
1135 $series[$i] .= ($j > 0 ?
", " :
"") .
'null';
1148 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1149 if (!empty($this->title)) {
1150 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1152 if (!empty($this->shownographyet)) {
1153 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1154 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1159 $dolxaxisvertical =
'';
1160 if (count($this->data) > 20) {
1161 $dolxaxisvertical =
'dol-xaxis-vertical';
1164 $cssfordiv =
'dolgraphchart';
1165 if (isset($this->
type[$firstlot])) {
1166 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1168 $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";
1169 $this->stringtoshow .=
'<canvas id="canvas_'.$tag.
'"></canvas></div>'.
"\n";
1171 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1174 $this->stringtoshow .=
'<!-- No series of data -->';
1176 while ($i < $nblot) {
1182 $this->stringtoshow .=
"\n";
1185 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1186 $type = $this->
type[$firstlot];
1188 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1191 $legendMaxLines = 0;
1194 if (empty($showlegend)) {
1195 $this->stringtoshow .=
'legend: { display: false }, ';
1197 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1198 if (!empty($legendMaxLines)) {
1199 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1201 $this->stringtoshow .=
' }, ' .
"\n";
1205 $this->stringtoshow .=
'plugins: { ';
1206 if (empty($showlegend)) {
1207 $this->stringtoshow .=
'legend: { display: false }, ';
1209 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1210 if (!empty($legendMaxLines)) {
1211 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1213 $this->stringtoshow .=
' }, ' .
"\n";
1215 $this->stringtoshow .=
' }, ' .
"\n";
1218 if ($this->
type[$firstlot] ==
'piesemicircle') {
1219 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1220 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1222 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1224 $this->stringtoshow .=
'backgroundColor: [';
1226 $foundnegativecolor = 0;
1227 foreach ($legends as $val) {
1229 $this->stringtoshow .=
', ' .
"\n";
1231 if (is_array($this->datacolor[$i])) {
1232 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1234 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1235 if (strpos($tmp,
'-') !==
false) {
1236 $foundnegativecolor++;
1237 $color =
'rgba(0,0,0,.0)';
1239 $color =
"#" . $tmp;
1242 $this->stringtoshow .=
"'" . $color .
"'";
1245 $this->stringtoshow .=
'], ' .
"\n";
1247 if ($foundnegativecolor) {
1248 $this->stringtoshow .=
'borderColor: [';
1250 foreach ($legends as $val) {
1252 $this->stringtoshow .=
', ' .
"\n";
1254 if (is_array($this->datacolor[$i])) {
1257 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1258 if (strpos($tmp,
'-') !==
false) {
1259 $color =
'#' . str_replace(
'-',
'', $tmp);
1264 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1267 $this->stringtoshow .=
']';
1269 $this->stringtoshow .=
'} } };' .
"\n";
1271 $this->stringtoshow .=
'
1272 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1273 var chart = new Chart(ctx, {
1274 // The type of chart we want to create
1275 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1282 foreach ($legends as $val) { // Loop on each series
1284 $this->stringtoshow .= ',
';
1286 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1290 $this->stringtoshow .=
'],
1293 while ($i < $nblot) {
1294 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1297 $this->stringtoshow .=
', ' .
"\n";
1299 $this->stringtoshow .=
'{' .
"\n";
1302 $this->stringtoshow .=
' data: [' . $series[$i] .
']';
1303 $this->stringtoshow .=
'}' .
"\n";
1306 $this->stringtoshow .=
']' .
"\n";
1307 $this->stringtoshow .=
'}' .
"\n";
1308 $this->stringtoshow .=
'});' .
"\n";
1314 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1315 $xaxis =
"indexAxis: 'y', ";
1317 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1322 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1323 $this->stringtoshow .= $xaxis;
1324 if ($this->showpointvalue == 2) {
1325 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1338 $this->stringtoshow .=
'plugins: { '.
"\n";
1339 if (empty($showlegend)) {
1340 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1342 $this->stringtoshow .=
'legend: { maxWidth: '.round(intval($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1344 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1345 $this->stringtoshow .= 'tooltip: { mode: \
'nearest\',
1347 if (is_array($this->tooltipsTitles)) {
1348 $this->stringtoshow .=
'
1349 title: function(tooltipItem, data) {
1350 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1351 return tooltipsTitle[tooltipItem[0].datasetIndex];
1354 if (is_array($this->tooltipsLabels)) {
1355 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1356 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1357 return tooltipslabels[tooltipItem.datasetIndex]
1360 $this->stringtoshow .=
'}},';
1362 $this->stringtoshow .=
"}, \n";
1384 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1385 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1387 if (is_array($this->tooltipsTitles)) {
1388 $this->stringtoshow .=
'
1389 title: function(tooltipItem, data) {
1390 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1391 return tooltipsTitle[tooltipItem[0].datasetIndex];
1394 if (is_array($this->tooltipsLabels)) {
1395 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1396 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1397 return tooltipslabels[tooltipItem.datasetIndex]
1400 $this->stringtoshow .=
'}},';
1402 $this->stringtoshow .=
'};';
1403 $this->stringtoshow .=
'
1404 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1405 var chart = new Chart(ctx, {
1406 // The type of chart we want to create
1407 type: \'' . $type .
'\',
1414 foreach ($legends as $val) { // Loop on each series
1416 $this->stringtoshow .= ',
';
1418 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1422 //var_dump($arrayofgroupslegend);
1424 $this->stringtoshow .= '],
1427 global $theme_datacolor;
1428 '@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
';
1429 //var_dump($arrayofgroupslegend);
1433 while ($i < $nblot) { // Loop on each series
1434 $foundnegativecolor = 0;
1435 $usecolorvariantforgroupby = 0;
1436 // We used a 'group by
' and we have too many colors so we generated color variants per
1437 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1438 $nbofcolorneeds = count($arrayofgroupslegend);
1439 $nbofcolorsavailable = count($theme_datacolor);
1440 if ($nbofcolorneeds > $nbofcolorsavailable) {
1441 $usecolorvariantforgroupby = 1;
1444 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1446 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1449 if ($usecolorvariantforgroupby) {
1450 $newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum
']];
1451 // If we change the stack
1452 if ($oldstacknum == -1 || $arrayofgroupslegend[$i]['stacknum
'] != $oldstacknum) {
1456 //var_dump($iinstack);
1458 // Change color with offset of $iinstack
1459 //var_dump($newcolor);
1460 if ($iinstack % 2) { // We increase aggressiveness of reference color for color 2, 4, 6, ...
1461 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1462 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1463 } else { // We decrease aggressiveness of reference color for color 3, 5, 7, ..
1464 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1465 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1467 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1469 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1471 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1473 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1474 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1475 } else { // We do not use a 'group by
'
1476 if (!empty($this->datacolor[$i])) {
1477 if (is_array($this->datacolor[$i])) {
1478 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1480 $color = $this->datacolor[$i];
1483 // else: $color will be undefined
1484 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1485 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1487 if ($type != 'horizontalBar
') {
1488 $bordercolor = $color;
1490 $bordercolor = $this->bordercolor[$i];
1494 // For negative colors, we invert border and background
1495 $tmp = str_replace('#
', '', $color);
1496 if (strpos($tmp, '-
') !== false) {
1497 $foundnegativecolor++;
1498 $bordercolor = str_replace('-
', '', $color);
1499 $color = '#FFFFFF
'; // If $val is '-123
'
1503 $this->stringtoshow .= ',
';
1505 $this->stringtoshow .= "\n";
1506 $this->stringtoshow .= '{
';
1507 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1509 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1510 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1511 if ($type == 'bar
' || $type == 'horizontalBar
') {
1512 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1514 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1515 $this->stringtoshow .= 'borderSkipped: \
'' . $this->borderskip .
'\',
';
1516 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1517 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1518 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1520 $this->stringtoshow .= 'data: [
';
1522 $this->stringtoshow .= $this->mirrorGraphValues ? '[-
' . $series[$i] . ',
' . $series[$i] . ']
' : $series[$i];
1523 $this->stringtoshow .= ']
';
1524 $this->stringtoshow .= '}
' . "\n";
1529 $this->stringtoshow .= ']
' . "\n";
1530 $this->stringtoshow .= '}
' . "\n";
1531 $this->stringtoshow .= '});
' . "\n";
1534 $this->stringtoshow .= '</script>
' . "\n";