Enhance graphs

This commit is contained in:
Laurent Destailleur 2020-03-05 00:17:16 +01:00
parent d0839350db
commit aa1552dbc0
6 changed files with 36 additions and 28 deletions

View File

@ -350,10 +350,11 @@ else
}
$datamin[$i] = $object->min_desired;
$dataall[$i] = $object->min_allowed;
if ($xday == '15')
/*if ($xday == '15') // Set only some label for jflot
{
$labels[$i] = dol_print_date($day, "%b");
}
}*/
$labels[$i] = dol_print_date($day, "%Y%m");
$day += 86400;
$textdate = strftime("%Y%m%d", $day);
$xyear = substr($textdate, 0, 4);
@ -465,10 +466,11 @@ else
}
$datamin[$i] = $object->min_desired;
$dataall[$i] = $object->min_allowed;
if (substr($textdate, 6, 2) == '01' || $i == 0)
/*if (substr($textdate, 6, 2) == '01' || $i == 0) // Set only few label for jflot
{
$labels[$i] = substr($textdate, 4, 2);
}
$labels[$i] = substr($textdate, 0, 6);
}*/
$labels[$i] = substr($textdate, 0, 6);
$day += 86400;
$textdate = strftime("%Y%m%d", $day);
@ -815,6 +817,8 @@ else
}
print '<br><br></td></tr>';
print '</table>';
// Graphs
if ($mode == 'standard')
@ -826,39 +830,39 @@ if ($mode == 'standard')
// For month
$link = "<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"] != 'all' ? '' : '&option=all')."&year=".$prevyear."&month=".$prevmonth."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Month")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".$nextyear."&month=".$nextmonth."'>".img_next('', 'class="valignbottom"')."</a>";
print '<tr><td class="right">'.$link.'</td></tr>';
print '<div class="right clearboth">'.$link.'</div>';
print '<tr><td class="center">';
print '<div class="center clearboth margintoponly">';
$file = "movement".$account."-".$year.$month.".png";
print $show4;
print '</td></tr>';
print '</div>';
print '<tr><td class="center">';
print '<div class="center clearboth margintoponly">';
print $show1;
print '</td></tr>';
print '</div>';
// For year
$prevyear = $year - 1; $nextyear = $year + 1;
$link = "<a href='".$_SERVER["PHP_SELF"]."?account=".$account.($_GET["option"] != 'all' ? '' : '&option=all')."&year=".($prevyear)."'>".img_previous('', 'class="valignbottom"')."</a> ".$langs->trans("Year")." <a href='".$_SERVER["PHP_SELF"]."?account=".$account."&year=".($nextyear)."'>".img_next('', 'class="valignbottom"')."</a>";
print '<tr><td class="right">'.$link.'</td></tr>';
print '<tr><td class="center">';
print '<div class="right clearboth margintoponly">'.$link.'</div>';
print '<div class="center clearboth margintoponly">';
print $show5;
print '</td></tr>';
print '</div>';
print '<tr><td class="center">';
print '<div class="center clearboth margintoponly">';
print $show2;
print '</td></tr>';
print '</div>';
}
if ($mode == 'showalltime')
{
print '<tr><td class="center">';
print '<div class="center clearboth margintoponly">';
print $show3;
print '</td></tr>';
print '</div>';
}
print '</table>';
// End of page
llxFooter();

View File

@ -1036,7 +1036,9 @@ class DolGraph
$dolxaxisvertical='';
if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical';
// No height for the pie grah
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="width:'.$this->width.(strpos($this->width, '%') > 0 ? '': 'px').';" class="dolgraphchart dolgraph'.(empty($dolxaxisvertical)?'':' '.$dolxaxisvertical).(empty($this->cssprefix) ? '' : ' dolgraph'.$this->cssprefix).' center"><canvas id="canvas_'.$tag.'"></canvas></div>'."\n";
$cssfordiv = 'dolgraphchart';
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'pie' || $this->type[$firstlot] == 'polar')) $cssfordiv .= ' dolgraphcharpie';
$this->stringtoshow .= '<div id="placeholder_'.$tag.'" style="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";
$this->stringtoshow .= '<script id="'.$tag.'">'."\n";
$i = $firstlot;
@ -1055,7 +1057,7 @@ class DolGraph
}
$this->stringtoshow .= "\n";
// Special case for Graph of type 'pie'
// Special case for Graph of type 'pie' or 'polar'
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'pie' || $this->type[$firstlot] == 'polar'))
{
$type = $this->type[$firstlot]; // pie or polar
@ -1090,7 +1092,7 @@ class DolGraph
$i = 0;
foreach($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', '."\n";
if ($i > 0) $this->stringtoshow .= ', ';
$this->stringtoshow .= "'".$val."'";
$i++;
}
@ -1116,12 +1118,12 @@ class DolGraph
$this->stringtoshow .= '}'."\n";
$this->stringtoshow .= '});'."\n";
}
// Other cases, graph of type 'bars', 'lines'
// Other cases, graph of type 'bars', 'lines', 'linesnopoint'
else
{
$type = 'bars';
$type = 'bar';
if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar';
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$i] == 'linesnopoint')) $type = 'line';
if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line';
$this->stringtoshow .= '
var ctx = document.getElementById("canvas_'.$tag.'").getContext("2d");
@ -1136,7 +1138,7 @@ class DolGraph
$i = 0;
foreach($legends as $val) // Loop on each serie
{
if ($i > 0) $this->stringtoshow .= ', '."\n";
if ($i > 0) $this->stringtoshow .= ', ';
$this->stringtoshow .= "'".$val."'";
$i++;
}

View File

@ -148,8 +148,8 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us
{
print '<div class="div-table-responsive-no-min">';
print '<table class="noborder centpercent">';
print '<tr class="liste_titre"><th colspan="2">'.$langs->trans("Statistics").'</th></tr>';
print '<tr><td class="center" colspan="2">';
print '<tr class="liste_titre"><th>'.$langs->trans("Statistics").'</th></tr>';
print '<tr><td class="center nopaddingleftimp nopaddingrightimp">';
$SommeA = $prodser[0]['sell'];
$SommeB = $prodser[0]['buy'];

View File

@ -75,7 +75,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
}
if ($conf->use_javascript_ajax)
{
print '<tr><td class="center" colspan="2">';
print '<tr><td class="center nopaddingleftimp nopaddingrightimp" colspan="2">';
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();

View File

@ -3777,6 +3777,7 @@ span.widthpictotitle { font-size: 2.1em; };
.dolgraphtitle { margin-top: 6px; margin-bottom: 4px; }
.dolgraphtitlecssboxes { /* margin: 0px; */ }
.dolgraphchart canvas { width: calc(100% - 20px) !important; }
.legendColorBox, .legendLabel { border: none !important; }
div.dolgraph div.legend, div.dolgraph div.legend div { background-color: var(--dolgraphbg) !important; }
div.dolgraph div.legend table tbody tr { height: auto; }

View File

@ -3771,6 +3771,7 @@ div.boximport {
.dolgraphtitle { margin-top: 6px; margin-bottom: 4px; }
.dolgraphtitlecssboxes { /* margin: 0px; */ }
.dolgraphchart canvas { width: calc(100% - 20px) !important; }
.legendColorBox, .legendLabel { border: none !important; }
div.dolgraph div.legend, div.dolgraph div.legend div { background-color: rgba(255,255,255,0) !important; }
div.dolgraph div.legend table tbody tr { height: auto; }