109 global $theme_bordercolor, $theme_datacolor, $theme_bgcolor;
112 $this->bordercolor = array(235, 235, 224);
113 $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220));
114 $this->bgcolor = array(235, 235, 224);
117 if (!empty($conf->dol_optimize_smallscreen)) {
122 $color_file = DOL_DOCUMENT_ROOT .
'/theme/' . $conf->theme .
'/theme_vars.inc.php';
123 if (is_readable($color_file)) {
125 if (isset($theme_bordercolor)) {
126 $this->bordercolor = $theme_bordercolor;
128 if (isset($theme_datacolor)) {
129 $this->datacolor = $theme_datacolor;
131 if (isset($theme_bgcolor)) {
132 $this->bgcolor = $theme_bgcolor;
137 $this->_library = $library;
138 if ($this->_library ==
'auto') {
139 $this->_library = (empty($conf->global->MAIN_JS_GRAPH) ?
'chart' : $conf->global->MAIN_JS_GRAPH);
771 dol_syslog(get_class($this) .
"::draw_jflot this->type=" . join(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
773 if (empty($this->width) && empty($this->height)) {
774 print
'Error width or height not set';
780 if (is_array($this->data) && is_array($this->data[0])) {
781 $nblot = count($this->data[0]) - 1;
784 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
792 while ($i < $nblot) {
794 $serie[$i] =
"var d" . $i .
" = [];\n";
798 foreach ($this->data as $valarray) {
799 $legends[$x] = $valarray[0];
800 $values[$x] = (is_numeric($valarray[$i + 1]) ? $valarray[$i + 1] :
null);
804 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
805 foreach ($values as $x => $y) {
807 $serie[$i] .=
'd' . $i .
'.push({"label":"' .
dol_escape_js($legends[$x]) .
'", "data":' . $y .
'});' .
"\n";
811 foreach ($values as $x => $y) {
813 $serie[$i] .=
'd' . $i .
'.push([' . $x .
', ' . $y .
']);' .
"\n";
823 $this->stringtoshow =
'<!-- Build using jflot -->' .
"\n";
824 if (!empty($this->title)) {
825 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
827 if (!empty($this->shownographyet)) {
828 $this->stringtoshow .=
'<div style="width:' . $this->width .
'px;height:' . $this->height .
'px;" class="nographyet"></div>';
829 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
834 $dolxaxisvertical =
'';
835 if (count($this->data) > 20) {
836 $dolxaxisvertical =
'dol-xaxis-vertical';
838 $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";
840 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
841 $this->stringtoshow .=
'$(function () {' .
"\n";
844 $this->stringtoshow .=
'<!-- No series of data -->' .
"\n";
846 while ($i < $nblot) {
847 $this->stringtoshow .=
'<!-- Serie ' . $i .
' -->' .
"\n";
848 $this->stringtoshow .= $serie[$i] .
"\n";
852 $this->stringtoshow .=
"\n";
855 if (isset($this->
type[$firstlot]) && in_array($this->
type[$firstlot], array(
'pie',
'piesemicircle',
'polar'))) {
856 $datacolor = array();
857 foreach ($this->datacolor as $val) {
858 if (is_array($val)) {
859 $datacolor[] =
"#" . sprintf(
"%02x%02x%02x", $val[0], $val[1], $val[2]);
861 $datacolor[] =
"#" . str_replace(array(
'#',
'-'),
'', $val);
866 $showlegend = $this->showlegend;
867 $showpointvalue = $this->showpointvalue;
868 $showpercent = $this->showpercent;
870 $this->stringtoshow .=
'
871 function plotWithOptions_' . $tag .
'() {
872 $.plot($("#placeholder_' . $tag .
'"), d0,
878 ' . ($this->combine ?
'
880 threshold: ' . $this->combine .
'
885 formatter: function(label, series) {
886 var percent=Math.round(series.percent);
887 var number=series.data[0][1];
889 $this->stringtoshow .=
'<span style="font-size:8pt;text-align:center;padding:2px;color:black;">';
891 $this->stringtoshow .=
'<a style="color: #FFFFFF;" border="0" href="' . $urltemp .
'">';
893 $this->stringtoshow .=
'\'+
';
894 $this->stringtoshow .= ($showlegend ? '' : 'label+\
' \'+');
895 $this->stringtoshow .= ($showpointvalue ?
'number+' :
'');
896 $this->stringtoshow .= ($showpercent ?
'\'<br>\
'+percent+\'%\'+' :
'');
897 $this->stringtoshow .=
'\'';
899 $this->stringtoshow .=
'</a>';
901 $this->stringtoshow .=
'</span>\';
916 if (count($datacolor)) {
917 $this->stringtoshow .=
'colors: ' . json_encode($datacolor) .
',';
919 $this->stringtoshow .=
'legend: {show: ' . ($showlegend ?
'true' :
'false') .
', position: \'ne\' }
926 $this->stringtoshow .=
'
927 function showTooltip_' . $tag .
'(x, y, contents) {
928 $(\'<div class="graph-tooltip-inner" id="tooltip_' . $tag .
'">\' + contents + \'</div>\').css({
929 position: \'absolute\',
933 border: \'1px solid #000\',
935 \'background-color\': \'#000\',
937 \'font-weight\': \'bold\',
940 }).appendTo("body").fadeIn(100);
943 var previousPoint = null;
944 $("#placeholder_' . $tag .
'").bind("plothover", function (event, pos, item) {
945 $("#x").text(pos.x.toFixed(2));
946 $("#y").text(pos.y.toFixed(2));
949 if (previousPoint != item.dataIndex) {
950 previousPoint = item.dataIndex;
952 $("#tooltip").remove();
953 /* console.log(item); */
954 var x = item.datapoint[0].toFixed(2);
955 var y = item.datapoint[1].toFixed(2);
956 var z = item.series.xaxis.ticks[item.dataIndex].label;
958 if ($this->showpointvalue > 0) {
959 $this->stringtoshow .=
'
960 showTooltip_' . $tag .
'(item.pageX, item.pageY, item.series.label + "<br>" + z + " => " + y);
963 $this->stringtoshow .=
'
967 $("#tooltip_' . $tag .
'").remove();
968 previousPoint = null;
973 $this->stringtoshow .=
'var stack = null, steps = false;' .
"\n";
975 $this->stringtoshow .=
'function plotWithOptions_' . $tag .
'() {' .
"\n";
976 $this->stringtoshow .=
'$.plot($("#placeholder_' . $tag .
'"), [ ' .
"\n";
978 while ($i < $nblot) {
979 if ($i > $firstlot) {
980 $this->stringtoshow .=
', ' .
"\n";
982 $color = sprintf(
"%02x%02x%02x", $this->datacolor[$i][0], $this->datacolor[$i][1], $this->datacolor[$i][2]);
983 $this->stringtoshow .=
'{ ';
984 if (!isset($this->
type[$i]) || $this->
type[$i] ==
'bars') {
986 if ($i == $firstlot) {
988 } elseif ($i == $firstlot + 1) {
993 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . $align .
'", barWidth: 0.45 }, ';
995 $this->stringtoshow .=
'bars: { lineWidth: 1, show: true, align: "' . ($i == $firstlot ?
'center' :
'left') .
'", barWidth: 0.5 }, ';
998 if (isset($this->
type[$i]) && ($this->
type[$i] ==
'lines' || $this->
type[$i] ==
'linesnopoint')) {
999 $this->stringtoshow .=
'lines: { show: true, fill: false }, points: { show: ' . ($this->
type[$i] ==
'linesnopoint' ?
'false' :
'true') .
' }, ';
1001 $this->stringtoshow .=
'color: "#' . $color .
'", label: "' . (isset($this->Legend[$i]) ?
dol_escape_js($this->Legend[$i]) :
'') .
'", data: d' . $i .
' }';
1005 $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";
1008 $this->stringtoshow .=
', xaxis: { ticks: [' .
"\n";
1010 foreach ($this->data as $key => $valarray) {
1012 $this->stringtoshow .=
', ' .
"\n";
1014 $this->stringtoshow .=
' [' . $x .
', "' . $valarray[0] .
'"]';
1017 $this->stringtoshow .=
'] }' .
"\n";
1020 $this->stringtoshow .=
', yaxis: { min: ' . $this->MinValue .
', max: ' . ($this->MaxValue) .
' }' .
"\n";
1023 $color1 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[0], $this->bgcolorgrid[2]);
1024 $color2 = sprintf(
"%02x%02x%02x", $this->bgcolorgrid[0], $this->bgcolorgrid[1], $this->bgcolorgrid[2]);
1025 $this->stringtoshow .=
', grid: { hoverable: true, backgroundColor: { colors: ["#' . $color1 .
'", "#' . $color2 .
'"] }, borderWidth: 1, borderColor: \'#e6e6e6\', tickColor : \'#e6e6e6\' }' .
"\n";
1026 $this->stringtoshow .=
'});' .
"\n";
1027 $this->stringtoshow .=
'}' .
"\n";
1030 $this->stringtoshow .=
'plotWithOptions_' . $tag .
'();' .
"\n";
1031 $this->stringtoshow .=
'});' .
"\n";
1032 $this->stringtoshow .=
'</script>' .
"\n";
1058 dol_syslog(get_class($this) .
"::draw_chart this->type=" . join(
',', $this->
type) .
" this->MaxValue=" . $this->MaxValue);
1060 if (empty($this->width) && empty($this->height)) {
1061 print
'Error width or height not set';
1065 $showlegend = $this->showlegend;
1070 if (is_array($this->data)) {
1071 foreach ($this->data as $valarray) {
1072 $nblot = max($nblot, count($valarray) - 1);
1077 dol_syslog(
'Bad value for property ->data. Must be set by mydolgraph->SetData before calling mydolgrapgh->draw', LOG_WARNING);
1084 $arrayofgroupslegend = array();
1088 while ($i < $nblot) {
1094 foreach ($this->data as $valarray) {
1095 $legends[$x] = (array_key_exists(
'label', $valarray) ? $valarray[
'label'] : $valarray[0]);
1096 $array_of_ykeys = array_keys($valarray);
1098 $tmpykey = explode(
'_', ($array_of_ykeys[$i + ($alabelexists ? 1 : 0)]), 3);
1099 if (isset($tmpykey[2]) && (!empty($tmpykey[2]) || $tmpykey[2] ==
'0')) {
1100 $tmpvalue = (array_key_exists(
'y_' . $tmpykey[1] .
'_' . $tmpykey[2], $valarray) ? $valarray[
'y_' . $tmpykey[1] .
'_' . $tmpykey[2]] : $valarray[$i + 1]);
1101 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1102 $arrayofgroupslegend[$i] = array(
1103 'stacknum' => $tmpykey[1],
1104 'legend' => $this->Legend[$tmpykey[1]],
1105 'legendwithgroup' => $this->Legend[$tmpykey[1]] .
' - ' . $tmpykey[2]
1108 $tmpvalue = (array_key_exists(
'y_' . $i, $valarray) ? $valarray[
'y_' . $i] : $valarray[$i + 1]);
1110 $values[$x] = (is_numeric($tmpvalue) ? $tmpvalue :
null);
1116 foreach ($values as $x => $y) {
1118 $serie[$i] .= ($j > 0 ?
", " :
"") . $y;
1120 $serie[$i] .= ($j > 0 ?
", " :
"") .
'null';
1133 $this->stringtoshow =
'<!-- Build using chart -->' .
"\n";
1134 if (!empty($this->title)) {
1135 $this->stringtoshow .=
'<div class="center dolgraphtitle' . (empty($this->cssprefix) ?
'' :
' dolgraphtitle' . $this->cssprefix) .
'">' . $this->title .
'</div>';
1137 if (!empty($this->shownographyet)) {
1138 $this->stringtoshow .=
'<div style="width:' . $this->width . (strpos($this->width,
'%') > 0 ?
'' :
'px') .
'; height:' . $this->height .
'px;" class="nographyet"></div>';
1139 $this->stringtoshow .=
'<div class="nographyettext margintoponly">' . $langs->trans(
"NotEnoughDataYet") .
'...</div>';
1144 $dolxaxisvertical =
'';
1145 if (count($this->data) > 20) {
1146 $dolxaxisvertical =
'dol-xaxis-vertical';
1149 $cssfordiv =
'dolgraphchart';
1150 if (isset($this->
type[$firstlot])) {
1151 $cssfordiv .=
' dolgraphchar' . $this->
type[$firstlot];
1153 $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"><canvas id="canvas_' . $tag .
'"></canvas></div>' .
"\n";
1155 $this->stringtoshow .=
'<script nonce="'.getNonce().
'" id="' . $tag .
'">' .
"\n";
1158 $this->stringtoshow .=
'<!-- No series of data -->';
1160 while ($i < $nblot) {
1166 $this->stringtoshow .=
"\n";
1169 if (isset($this->
type[$firstlot]) && (in_array($this->
type[$firstlot], array(
'pie',
'polar',
'piesemicircle')))) {
1170 $type = $this->
type[$firstlot];
1172 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1175 $legendMaxLines = 0;
1178 if (empty($showlegend)) {
1179 $this->stringtoshow .=
'legend: { display: false }, ';
1181 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1182 if (!empty($legendMaxLines)) {
1183 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1185 $this->stringtoshow .=
' }, ' .
"\n";
1189 $this->stringtoshow .=
'plugins: { ';
1190 if (empty($showlegend)) {
1191 $this->stringtoshow .=
'legend: { display: false }, ';
1193 $this->stringtoshow .=
'legend: { labels: { boxWidth: 15 }, position: \'' . ($showlegend == 2 ?
'right' :
'top') .
'\'';
1194 if (!empty($legendMaxLines)) {
1195 $this->stringtoshow .=
', maxLines: ' . $legendMaxLines;
1197 $this->stringtoshow .=
' }, ' .
"\n";
1199 $this->stringtoshow .=
' }, ' .
"\n";
1202 if ($this->
type[$firstlot] ==
'piesemicircle') {
1203 $this->stringtoshow .=
'circumference: Math.PI,' .
"\n";
1204 $this->stringtoshow .=
'rotation: -Math.PI,' .
"\n";
1206 $this->stringtoshow .=
'elements: { arc: {' .
"\n";
1208 $this->stringtoshow .=
'backgroundColor: [';
1210 $foundnegativecolor = 0;
1211 foreach ($legends as $val) {
1213 $this->stringtoshow .=
', ' .
"\n";
1215 if (is_array($this->datacolor[$i])) {
1216 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1218 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1219 if (strpos($tmp,
'-') !==
false) {
1220 $foundnegativecolor++;
1221 $color =
'rgba(0,0,0,.0)';
1223 $color =
"#" . $tmp;
1226 $this->stringtoshow .=
"'" . $color .
"'";
1229 $this->stringtoshow .=
'], ' .
"\n";
1231 if ($foundnegativecolor) {
1232 $this->stringtoshow .=
'borderColor: [';
1234 foreach ($legends as $val) {
1236 $this->stringtoshow .=
', ' .
"\n";
1238 if (is_array($this->datacolor[$i])) {
1241 $tmp = str_replace(
'#',
'', $this->datacolor[$i]);
1242 if (strpos($tmp,
'-') !==
false) {
1243 $color =
'#' . str_replace(
'-',
'', $tmp);
1248 $this->stringtoshow .= ($color ==
'null' ?
"'rgba(0,0,0,0.2)'" :
"'" . $color .
"'");
1251 $this->stringtoshow .=
']';
1253 $this->stringtoshow .=
'} } };' .
"\n";
1255 $this->stringtoshow .=
'
1256 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1257 var chart = new Chart(ctx, {
1258 // The type of chart we want to create
1259 type: \'' . (in_array($type, array(
'pie',
'piesemicircle')) ?
'doughnut' :
'polarArea') .
'\',
1266 foreach ($legends as $val) { // Loop on each serie
1268 $this->stringtoshow .= ',
';
1270 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 25)) . "'"; // Lower than 25 make some important label (that we can't shorten) to be truncated
1274 $this->stringtoshow .=
'],
1278 while ($i < $nblot) {
1279 $color =
'rgb(' . $this->datacolor[$i][0] .
', ' . $this->datacolor[$i][1] .
', ' . $this->datacolor[$i][2] .
')';
1282 $this->stringtoshow .=
', ' .
"\n";
1284 $this->stringtoshow .=
'{' .
"\n";
1287 $this->stringtoshow .=
' data: [' . $serie[$i] .
']';
1288 $this->stringtoshow .=
'}' .
"\n";
1291 $this->stringtoshow .=
']' .
"\n";
1292 $this->stringtoshow .=
'}' .
"\n";
1293 $this->stringtoshow .=
'});' .
"\n";
1296 $type =
'bar'; $xaxis =
'';
1298 if (!isset($this->
type[$firstlot]) || $this->
type[$firstlot] ==
'bars') {
1301 if (isset($this->
type[$firstlot]) && $this->
type[$firstlot] ==
'horizontalbars') {
1302 $type =
'bar'; $xaxis =
"indexAxis: 'y', ";
1304 if (isset($this->
type[$firstlot]) && ($this->
type[$firstlot] ==
'lines' || $this->
type[$firstlot] ==
'linesnopoint')) {
1309 $this->stringtoshow .=
'var options = { maintainAspectRatio: false, aspectRatio: 2.5, ';
1310 $this->stringtoshow .= $xaxis;
1311 if ($this->showpointvalue == 2) {
1312 $this->stringtoshow .=
'interaction: { intersect: true, mode: \'index\'}, ';
1325 $this->stringtoshow .=
'plugins: { '.
"\n";
1326 if (empty($showlegend)) {
1327 $this->stringtoshow .=
'legend: { display: false }, '.
"\n";
1329 $this->stringtoshow .=
'legend: { maxWidth: '.round(intVal($this->width) / 2).
', labels: { boxWidth: 15 }, position: \'' . (($showlegend && $showlegend == 2) ?
'right' :
'top') .
'\' },
'."\n";
1331 $this->stringtoshow .= "}, \n";
1333 /* For Chartjs v2.9 */
1335 $this->stringtoshow .= 'scales: { xAxis: [{
';
1336 if ($this->hideXValues) {
1337 $this->stringtoshow .= ' ticks: { display:
false }, display:
true,
';
1339 //$this->stringtoshow .= 'type: \
'time\', ';
1340 $this->stringtoshow .=
'distribution: \'linear\'';
1341 if ($type ==
'bar' && count($arrayofgroupslegend) > 0) {
1342 $this->stringtoshow .=
', stacked: true';
1344 $this->stringtoshow .=
' }]';
1345 $this->stringtoshow .=
', yAxis: [{ ticks: { beginAtZero: true }';
1346 if ($type ==
'bar' && count($arrayofgroupslegend) > 0) {
1347 $this->stringtoshow .=
', stacked: true';
1349 $this->stringtoshow .=
' }] }';
1353 if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) {
1354 $this->stringtoshow .=
'tooltips: { mode: \'nearest\',
1356 if (is_array($this->tooltipsTitles)) {
1357 $this->stringtoshow .=
'
1358 title: function(tooltipItem, data) {
1359 var tooltipsTitle ='.json_encode($this->tooltipsTitles).
'
1360 return tooltipsTitle[tooltipItem[0].datasetIndex];
1363 if (is_array($this->tooltipsLabels)) {
1364 $this->stringtoshow .=
'label: function(tooltipItem, data) {
1365 var tooltipslabels ='.json_encode($this->tooltipsLabels).
'
1366 return tooltipslabels[tooltipItem.datasetIndex]
1369 $this->stringtoshow .=
'}},';
1371 $this->stringtoshow .=
'};';
1372 $this->stringtoshow .=
'
1373 var ctx = document.getElementById("canvas_' . $tag .
'").getContext("2d");
1374 var chart = new Chart(ctx, {
1375 // The type of chart we want to create
1376 type: \'' . $type .
'\',
1383 foreach ($legends as $val) { // Loop on each serie
1385 $this->stringtoshow .= ',
';
1387 $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'";
1391 //var_dump($arrayofgroupslegend);
1393 $this->stringtoshow .= '],
1396 global $theme_datacolor;
1397 //var_dump($arrayofgroupslegend);
1401 while ($i < $nblot) { // Loop on each serie
1402 $foundnegativecolor = 0;
1403 $usecolorvariantforgroupby = 0;
1404 // We used a 'group by
' and we have too many colors so we generated color variants per
1405 if (!empty($arrayofgroupslegend) && is_array($arrayofgroupslegend[$i]) && count($arrayofgroupslegend[$i]) > 0) { // If we used a group by.
1406 $nbofcolorneeds = count($arrayofgroupslegend);
1407 $nbofcolorsavailable = count($theme_datacolor);
1408 if ($nbofcolorneeds > $nbofcolorsavailable) {
1409 $usecolorvariantforgroupby = 1;
1412 $textoflegend = $arrayofgroupslegend[$i]['legendwithgroup
'];
1414 $textoflegend = !empty($this->Legend[$i]) ? $this->Legend[$i] : '';
1417 if ($usecolorvariantforgroupby) {
1418 $newcolor = $this->datacolor[$arrayofgroupslegend[$i]['stacknum
']];
1419 // If we change the stack
1420 if ($oldstacknum == -1 || $arrayofgroupslegend[$i]['stacknum
'] != $oldstacknum) {
1424 //var_dump($iinstack);
1426 // Change color with offset of $iinstack
1427 //var_dump($newcolor);
1428 if ($iinstack % 2) { // We increase agressiveness of reference color for color 2, 4, 6, ...
1429 $ratio = min(95, 10 + 10 * $iinstack); // step of 20
1430 $brightnessratio = min(90, 5 + 5 * $iinstack); // step of 10
1431 } else { // We decrease agressiveness of reference color for color 3, 5, 7, ..
1432 $ratio = max(-100, -15 * $iinstack + 10); // step of -20
1433 $brightnessratio = min(90, 10 * $iinstack); // step of 20
1435 //var_dump('Color
'.($iinstack+1).' :
'.$ratio.' '.$brightnessratio);
1437 $newcolor = array_values(colorHexToRgb(colorAgressiveness(colorArrayToHex($newcolor), $ratio, $brightnessratio), false, true));
1439 $oldstacknum = $arrayofgroupslegend[$i]['stacknum
'];
1441 $color = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ', 0.9)
';
1442 $bordercolor = 'rgb(
' . $newcolor[0] . ',
' . $newcolor[1] . ',
' . $newcolor[2] . ')
';
1443 } else { // We do not use a 'group by
'
1444 if (!empty($this->datacolor[$i]) && is_array($this->datacolor[$i])) {
1445 $color = 'rgb(
' . $this->datacolor[$i][0] . ',
' . $this->datacolor[$i][1] . ',
' . $this->datacolor[$i][2] . ', 0.9)
';
1447 $color = $this->datacolor[$i];
1449 if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) {
1450 $bordercolor = 'rgb(
' . $this->bordercolor[$i][0] . ',
' . $this->bordercolor[$i][1] . ',
' . $this->bordercolor[$i][2] . ', 0.9)
';
1452 if ($type != 'horizontalBar
') {
1453 $bordercolor = $color;
1455 $bordercolor = $this->bordercolor[$i];
1459 // For negative colors, we invert border and background
1460 $tmp = str_replace('#
', '', $color);
1461 if (strpos($tmp, '-
') !== false) {
1462 $foundnegativecolor++;
1463 $bordercolor = str_replace('-
', '', $color);
1464 $color = '#FFFFFF
'; // If $val is '-123
'
1468 $this->stringtoshow .= ',
';
1470 $this->stringtoshow .= "\n";
1471 $this->stringtoshow .= '{
';
1472 $this->stringtoshow .= 'dolibarrinfo: \
'y_' . $i .
'\',
';
1474 $this->stringtoshow .= 'pointStyle: \
'' . ((!empty($this->
type[$i]) && $this->
type[$i] ==
'linesnopoint') ?
'line' :
'circle') .
'\',
';
1475 $this->stringtoshow .= 'fill:
' . ($type == 'bar
' ? 'true' : 'false') . ',
';
1476 if ($type == 'bar
' || $type == 'horizontalBar
') {
1477 $this->stringtoshow .= 'borderWidth: \
''.$this->borderwidth.
'\',
';
1479 $this->stringtoshow .= 'borderColor: \
'' . $bordercolor .
'\',
';
1480 $this->stringtoshow .= 'backgroundColor: \
'' . $color .
'\',
';
1481 if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) {
1482 $this->stringtoshow .= 'stack: \
'' . $arrayofgroupslegend[$i][
'stacknum'] .
'\',
';
1484 $this->stringtoshow .= 'data: [
';
1486 $this->stringtoshow .= $this->mirrorGraphValues ? '[
' . -$serie[$i] . ',
' . $serie[$i] . ']
' : $serie[$i];
1487 $this->stringtoshow .= ']
';
1488 $this->stringtoshow .= '}
' . "\n";
1493 $this->stringtoshow .= ']
' . "\n";
1494 $this->stringtoshow .= '}
' . "\n";
1495 $this->stringtoshow .= '});
' . "\n";
1498 $this->stringtoshow .= '</script>
' . "\n";