110 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
113 $this->bordercolor = array(235, 235, 224);
114 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
115 $this->bgcolor = array(235, 235, 224);
118 if (!empty($conf->dol_optimize_smallscreen)) {
123 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
124 if (is_readable($color_file)) {
126 if (isset($theme_bordercolor)) {
127 $this->bordercolor = $theme_bordercolor;
129 if (isset($theme_datacolor)) {
130 $this->datacolor = $theme_datacolor;
132 if (isset($theme_bgcolor)) {
133 $this->bgcolor = $theme_bgcolor;
138 $this->_library = $library;
139 if ($this->_library ==
'auto') {
140 $this->_library = (!
getDolGlobalString(
'MAIN_JS_GRAPH') ?
'chart' : $conf->global->MAIN_JS_GRAPH);
784 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . join(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
786 if (empty($this->width) && empty($this->height)) {
787 print
'Error width or height not set';
793 if (is_array($this->data) && is_array($this->data[0])) {
794 $nblot = count($this->data[0]) - 1;
797 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
805 while ($i < $nblot) {
807 $serie[$i] =
"var d" . $i .
" = [];\n";
811 foreach ($this->data as $valarray) {
812 $legends[$x] = $valarray[0];
813 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
817 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
818 foreach ($values as $x => $y) {
820 $serie[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
824 foreach ($values as $x => $y) {
826 $serie[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
836 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
837 if (!empty($this->title)) {
838 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
840 if (!empty($this->shownographyet)) {
841 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
842 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
847 $dolxaxisvertical =
'';
848 if (count($this->data) > 20) {
849 $dolxaxisvertical =
'dol-xaxis-vertical';
851 $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";
853 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
854 $this->stringtoshow .=
'$(function () {' .
"\n";
857 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
859 while ($i < $nblot) {
860 $this->stringtoshow .=
'<!-- Serie ' . $i .
' -->' .
"\n";
861 $this->stringtoshow .= $serie[$i] .
"\n";
865 $this->stringtoshow .=
"\n";
868 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
869 $datacolor = array();
870 foreach ($this->datacolor as $val) {
871 if (is_array($val)) {
872 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
874 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
879 $showlegend = $this->showlegend;
880 $showpointvalue = $this->showpointvalue;
881 $showpercent = $this->showpercent;
883 $this->stringtoshow .=
'
884 function plotWithOptions_' . $tag .
'() {
885 $.plot($("#placeholder_' . $tag .
'"), d0,
891 ' . ($this->combine ?
'
893 threshold: ' . $this->combine .
'
898 formatter: function(label, series) {
899 var percent=Math.round(series.percent);
900 var number=series.data[0][1];
902 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
904 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
906 $this->stringtoshow .=
'\'+
';
907 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
908 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
909 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
910 $this->stringtoshow .=
'\'';
912 $this->stringtoshow .=
'</a>';
914 $this->stringtoshow .=
'</span>\';
929 if (count($datacolor)) {
930 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
932 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
939 $this->stringtoshow .=
'
940 function showTooltip_' . $tag .
'(x, y, contents) {
941 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
942 position: \'absolute\',
946 border: \'1px solid #000\',
948 \'background-color\': \'#000\',
950 \'font-weight\': \'bold\',
953 }).appendTo("body").fadeIn(100);
956 var previousPoint = null;
957 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
958 $("#x").text(pos.x.toFixed(2));
959 $("#y").text(pos.y.toFixed(2));
962 if (previousPoint != item.dataIndex) {
963 previousPoint = item.dataIndex;
965 $("#tooltip").remove();
966 /* console.log(item); */
967 var x = item.datapoint[0].toFixed(2);
968 var y = item.datapoint[1].toFixed(2);
969 var z = item.series.xaxis.ticks[item.dataIndex].label;
971 if ($this->showpointvalue > 0) {
972 $this->stringtoshow .=
'
973 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
976 $this->stringtoshow .=
'
980 $("#tooltip_' . $tag .
'").remove();
981 previousPoint = null;
986 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
988 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
989 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
991 while ($i < $nblot) {
992 if ($i > $firstlot) {
993 $this->stringtoshow .=
', ' .
"\n";
995 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
996 $this->stringtoshow .=
'{ ';
997 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
999 if ($i == $firstlot) {
1001 } elseif ($i == $firstlot + 1) {
1006 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
1008 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
1011 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
1012 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1014 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1018 $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";
1021 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1023 foreach ($this->data as $key => $valarray) {
1025 $this->stringtoshow .=
', ' .
"\n";
1027 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1030 $this->stringtoshow .=
'] }' .
"\n";
1033 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1036 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1037 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1038 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1039 $this->stringtoshow .=
'});' .
"\n";
1040 $this->stringtoshow .=
'}' .
"\n";
1043 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1044 $this->stringtoshow .=
'});' .
"\n";
1045 $this->stringtoshow .=
'</script>' .
"\n";
1071 dol_syslog(get_class($this) .
"::draw_chart this->type=" . join(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1073 if (empty($this->width) && empty($this->height)) {
1074 print
'Error width or height not set';
1078 $showlegend = $this->showlegend;
1083 if (is_array($this->data)) {
1084 foreach ($this->data as $valarray) {
1085 $nblot = max($nblot, count($valarray) - 1);
1090 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1097 $arrayofgroupslegend = array();
1101 while ($i < $nblot) {
1107 foreach ($this->data as $valarray) {
1108 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1109 $array_of_ykeys = array_keys($valarray);
1111 $tmpykey = explode(
'_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1112 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1113 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1114 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1115 $arrayofgroupslegend[$i] = array(
1116 'stacknum' => $tmpykey[1],
1117 'legend' => $this->Legend[$tmpykey[1]],
1118 'legendwithgroup' => $this->Legend[$tmpykey[1]] .
' - ' . $tmpykey[2]
1121 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1123 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1129 foreach ($values as $x => $y) {
1131 $serie[$i] .= ($j > 0 ?
", " :
"") . $y;
1133 $serie[$i] .= ($j > 0 ?
", " :
"") .
'null';
1146 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1147 if (!empty($this->title)) {
1148 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1150 if (!empty($this->shownographyet)) {
1151 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1152 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1157 $dolxaxisvertical =
'';
1158 if (count($this->data) > 20) {
1159 $dolxaxisvertical =
'dol-xaxis-vertical';
1162 $cssfordiv =
'dolgraphchart';
1163 if (isset($this->
type[$firstlot])) {
1164 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1166 $this->stringtoshow .=
'<div id="placeholder_'.$tag.
'" style="min-height: '.$this->height.(strpos($this->height,
'%') > 0 ?
'' :
'px').
'; max-height: '.(strpos($this->height,
'%') > 0 ? $this->height : ($this->height + 100) .
'px').
'; width:'.$this->width.(strpos($this->width,
'%') > 0 ?
'' :
'px').
';" class="'.$cssfordiv.
' dolgraph'.(empty($dolxaxisvertical) ?
'' :
' '.$dolxaxisvertical).(empty($this->cssprefix) ?
'' :
' dolgraph'.$this->cssprefix).
' center">'.
"\n";
1167 $this->stringtoshow .=
'<canvas id="canvas_'.$tag.
'"></canvas></div>'.
"\n";
1169 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1172 $this->stringtoshow .=
'<!-- No series of data -->';
1174 while ($i < $nblot) {
1180 $this->stringtoshow .=
"\n";
1183 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1184 $type = $this->
type[$firstlot];
1186 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1189 $legendMaxLines = 0;
1192 if (empty($showlegend)) {
1193 $this->stringtoshow .=
'legend: { display: false }, ';
1195 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1196 if (!empty($legendMaxLines)) {
1197 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1199 $this->stringtoshow .=
' }, ' .
"\n";
1203 $this->stringtoshow .=
'plugins: { ';
1204 if (empty($showlegend)) {
1205 $this->stringtoshow .=
'legend: { display: false }, ';
1207 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1208 if (!empty($legendMaxLines)) {
1209 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1211 $this->stringtoshow .=
' }, ' .
"\n";
1213 $this->stringtoshow .=
' }, ' .
"\n";
1216 if ($this->
type[$firstlot] ==
'piesemicircle') {
1217 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1218 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1220 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1222 $this->stringtoshow .=
'backgroundColor: [';
1224 $foundnegativecolor = 0;
1225 foreach ($legends as $val) {
1227 $this->stringtoshow .=
', ' .
"\n";
1229 if (is_array($this->datacolor[$i])) {
1230 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1232 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1233 if (strpos($tmp,
'-') !==
false) {
1234 $foundnegativecolor++;
1235 $color =
'rgba(0,0,0,.0)';
1237 $color =
"#" . $tmp;
1240 $this->stringtoshow .=
"'" . $color .
"'";
1243 $this->stringtoshow .=
'], ' .
"\n";
1245 if ($foundnegativecolor) {
1246 $this->stringtoshow .=
'borderColor: [';
1248 foreach ($legends as $val) {
1250 $this->stringtoshow .=
', ' .
"\n";
1252 if (is_array($this->datacolor[$i])) {
1255 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1256 if (strpos($tmp,
'-') !==
false) {
1257 $color =
'#' . str_replace(
'-',
'', $tmp);
1262 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1265 $this->stringtoshow .=
']';
1267 $this->stringtoshow .=
'} } };' .
"\n";
1269 $this->stringtoshow .=
'
1270 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1271 var chart = new Chart(ctx, {
1272 // The type of chart we want to create
1273 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1280 foreach ($legends as $val) { // Loop on each serie
1282 $this->stringtoshow .= ',
';
1284 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1288 $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: [' . $serie[$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] ==
'bars') {
1316 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1318 $xaxis =
"indexAxis: 'y', ";
1320 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1325 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1326 $this->stringtoshow .= $xaxis;
1327 if ($this->showpointvalue == 2) {
1328 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1341 $this->stringtoshow .=
'plugins: { '.
"\n";
1342 if (empty($showlegend)) {
1343 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1345 $this->stringtoshow .=
'legend: { maxWidth: '.round(intVal($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1347 $this->stringtoshow .= "}, \n";
1349 /* For Chartjs v2.9 */
1351 $this->stringtoshow .= 'scales: { xAxis: [{
';
1352 if ($this->hideXValues) {
1353 $this->stringtoshow .= ' ticks: { display:
false }, display:
true,
';
1355 //$this->stringtoshow .= 'type: \
'time\', ';
1356 $this->stringtoshow .=
'distribution: \'linear\'';
1357 if ($type ==
'bar' && count($arrayofgroupslegend) > 0) {
1358 $this->stringtoshow .=
', stacked: true';
1360 $this->stringtoshow .=
' }]';
1361 $this->stringtoshow .=
', yAxis: [{ ticks: { beginAtZero: true }';
1362 if ($type ==
'bar' && count($arrayofgroupslegend) > 0) {
1363 $this->stringtoshow .=
', stacked: true';
1365 $this->stringtoshow .=
' }] }';
1369 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1370 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1372 if (is_array($this->tooltipsTitles)) {
1373 $this->stringtoshow .=
'
1374 title: function(tooltipItem, data) {
1375 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1376 return tooltipsTitle[tooltipItem[0].datasetIndex];
1379 if (is_array($this->tooltipsLabels)) {
1380 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1381 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1382 return tooltipslabels[tooltipItem.datasetIndex]
1385 $this->stringtoshow .=
'}},';
1387 $this->stringtoshow .=
'};';
1388 $this->stringtoshow .=
'
1389 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1390 var chart = new Chart(ctx, {
1391 // The type of chart we want to create
1392 type: \'' . $type .
'\',
1399 foreach ($legends as $val) { // Loop on each serie
1401 $this->stringtoshow .= ',
';
1403 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1407 //var_dump($arrayofgroupslegend);
1409 $this->stringtoshow .= '],
1412 global $theme_datacolor;
1413 //var_dump($arrayofgroupslegend);
1417 while ($i < $nblot) { // Loop on each serie
1418 $foundnegativecolor = 0;
1419 $usecolorvariantforgroupby = 0;
1420 // We used a 'group by
' and we have too many colors so we generated color variants per
1421 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1422 $nbofcolorneeds = count($arrayofgroupslegend);
1423 $nbofcolorsavailable = count($theme_datacolor);
1424 if ($nbofcolorneeds > $nbofcolorsavailable) {
1425 $usecolorvariantforgroupby = 1;
1428 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1430 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1433 if ($usecolorvariantforgroupby) {
1434 $newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum
']];
1435 // If we change the stack
1436 if ($oldstacknum == -1 || $arrayofgroupslegend[$i]['stacknum
'] != $oldstacknum) {
1440 //var_dump($iinstack);
1442 // Change color with offset of $iinstack
1443 //var_dump($newcolor);
1444 if ($iinstack % 2) { // We increase agressiveness of reference color for color 2, 4, 6, ...
1445 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1446 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1447 } else { // We decrease agressiveness of reference color for color 3, 5, 7, ..
1448 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1449 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1451 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1453 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1455 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1457 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1458 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1459 } else { // We do not use a 'group by
'
1460 if (!empty($this->datacolor[$i])) {
1461 if (is_array($this->datacolor[$i])) {
1462 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1464 $color = $this->datacolor[$i];
1467 // else: $color will be undefined
1468 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1469 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1471 if ($type != 'horizontalBar
') {
1472 $bordercolor = $color;
1474 $bordercolor = $this->bordercolor[$i];
1478 // For negative colors, we invert border and background
1479 $tmp = str_replace('#
', '', $color);
1480 if (strpos($tmp, '-
') !== false) {
1481 $foundnegativecolor++;
1482 $bordercolor = str_replace('-
', '', $color);
1483 $color = '#FFFFFF
'; // If $val is '-123
'
1487 $this->stringtoshow .= ',
';
1489 $this->stringtoshow .= "\n";
1490 $this->stringtoshow .= '{
';
1491 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1493 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1494 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1495 if ($type == 'bar
' || $type == 'horizontalBar
') {
1496 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1498 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1499 $this->stringtoshow .= 'borderSkipped: \
'' . $this->borderskip .
'\',
';
1500 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1501 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1502 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1504 $this->stringtoshow .= 'data: [
';
1506 $this->stringtoshow .= $this->mirrorGraphValues ? '[-
' . $serie[$i] . ',
' . $serie[$i] . ']
' : $serie[$i];
1507 $this->stringtoshow .= ']
';
1508 $this->stringtoshow .= '}
' . "\n";
1513 $this->stringtoshow .= ']
' . "\n";
1514 $this->stringtoshow .= '}
' . "\n";
1515 $this->stringtoshow .= '});
' . "\n";
1518 $this->stringtoshow .= '</script>
' . "\n";