NEW Can force position of legend of graph on right (instead of top)

This commit is contained in:
Laurent Destailleur 2020-03-05 17:23:19 +01:00
parent ddb26d7a8f
commit 0bd2740779
17 changed files with 32 additions and 27 deletions

View File

@ -204,7 +204,7 @@ if ($conf->use_javascript_ajax)
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->SetDataColor(array($badgeStatus1, $badgeStatus4, $badgeStatus6, '-'.$badgeStatus0));
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -141,7 +141,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -140,7 +140,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -115,10 +115,10 @@ if ($conf->use_javascript_ajax)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($totalnb?0:1);

View File

@ -209,7 +209,7 @@ if (!empty($conf->use_javascript_ajax))
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -30,10 +30,10 @@
* $dolgraph->SetTitle($langs->transnoentities('MyTitle').'<br>'.$langs->transnoentities('MyTitlePercent').'%');
* $dolgraph->SetMaxValue(50);
* $dolgraph->SetData($data);
* $dolgraph->setShowLegend(1);
* $dolgraph->setShowLegend(2);
* $dolgraph->setShowPercent(1);
* $dolgraph->SetType(array('pie'));
* $dolgraph->setWidth('100%');
* $dolgraph->setHeight('200');
* $dolgraph->draw('idofgraph');
* print $dolgraph->show($total?0:1);
*/
@ -422,7 +422,7 @@ class DolGraph
/**
* Show legend or not
*
* @param int $showlegend 1=Show legend (default), 0=Hide legend
* @param int $showlegend 1=Show legend (default), 0=Hide legend, 2=Show legend on right
* @return void
*/
public function setShowLegend($showlegend)
@ -957,6 +957,8 @@ class DolGraph
return;
}
$showlegend = $this->showlegend;
$legends = array();
$nblot = 0;
if (is_array($this->data) && is_array($this->data[0])) {
@ -1040,6 +1042,7 @@ class DolGraph
$this->stringtoshow .= 'circumference: Math.PI,'."\n";
$this->stringtoshow .= 'rotation: -Math.PI,'."\n";
}
if ($showlegend) $this->stringtoshow .= 'legend: { position: \''.($showlegend == 2 ? 'right' : 'top').'\' },'."\n";
$this->stringtoshow .= 'elements: { arc: {'."\n";
// Color of earch arc
$this->stringtoshow .= 'backgroundColor: [';

View File

@ -137,7 +137,7 @@ if ($conf->use_javascript_ajax)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -136,7 +136,7 @@ if ($conf->use_javascript_ajax)
$dolgraph->SetData($dataseries);
$dolgraph->setHeight(350);
$dolgraph->combine = empty($conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT) ? 0.05 : $conf->global->MAIN_EXPENSEREPORT_COMBINE_GRAPH_STAT;
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -140,7 +140,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -137,10 +137,10 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total ? 0 : 1);

View File

@ -101,10 +101,10 @@ if ($conf->use_javascript_ajax)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->SetHeight(200);
$dolgraph->SetHeight('200');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($totalnb?0:1);

View File

@ -174,15 +174,15 @@ if ((!empty($conf->product->enabled) || !empty($conf->service->enabled)) && ($us
{
$dataseries[] = array($langs->trans("ServicesOnSale"), round($SommeD));
$dataseries[] = array($langs->trans("ServicesOnPurchase"), round($SommeE));
$dataseries[] = array($langs->trans("ServicesNotOnSell"), round($SommeF));
$dataseries[] = array(dol_trunc($langs->trans("ServicesNotOnSell"), 24), round($SommeF));
}
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(0);
$dolgraph->SetType(array('piesemicircle'));
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphstatus');
print $dolgraph->show($total ? 0 : 1);
@ -241,10 +241,10 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->setHeight('200');
$dolgraph->draw('idstatscategproduct');
print $dolgraph->show($total ? 0 : 1);
}

View File

@ -80,7 +80,7 @@ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES))
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
//$dolgraph->setWidth('100%');

View File

@ -112,7 +112,7 @@ if (!empty($conf->use_javascript_ajax) && ((round($third['prospect']) ? 1 : 0) +
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');
@ -200,10 +200,10 @@ if (!empty($conf->categorie->enabled) && !empty($conf->global->CATEGORY_GRAPHSTA
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setWidth('100%');
$dolgraph->setHeight('200');
$dolgraph->draw('idgraphcateg');
print $dolgraph->show();
}

View File

@ -144,7 +144,7 @@ if ($resql)
include_once DOL_DOCUMENT_ROOT.'/core/class/dolgraph.class.php';
$dolgraph = new DolGraph();
$dolgraph->SetData($dataseries);
$dolgraph->setShowLegend(1);
$dolgraph->setShowLegend(2);
$dolgraph->setShowPercent(1);
$dolgraph->SetType(array('pie'));
$dolgraph->setHeight('200');

View File

@ -2348,7 +2348,8 @@ input.vmenusearchselectcombo[type=text] {
a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active, span.vmenu, span.vsmenu { white-space: nowrap; font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; }
a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active { font-weight: bold; } /* bold = 600, 500 is ko with Edge on 1200x960 */
a.vmenu:link, a.vmenu:visited, a.vmenu:hover, a.vmenu:active,
span.vmenu, span.vmenu:link, span.vmenu:visited, span.vmenu:hover, span.vmenu:active { font-weight: bold; } /* bold = 600, 500 is ko with Edge on 1200x960 */
font.vmenudisabled { font-family: <?php print $fontlist ?>; text-align: <?php print $left; ?>; font-weight: bold; color: #aaa; margin-left: 4px; } /* bold = 600, 500 is ko with Edge on 1200x960 */
a.vmenu:link, a.vmenu:visited { color: var(--colortextbackvmenu); }

View File

@ -239,6 +239,7 @@ if (!empty($dataseries) && count($dataseries) > 1) {
$legend[] = $i;
$i++;
}
$px1->setShowLegend(2);
$px1->SetType(array('pie'));
$px1->SetLegend($legend);
$px1->SetMaxValue($px1->GetCeilMaxValue());