New: Graph js librairie can accept colors and mix bar with plots.
This commit is contained in:
parent
993428e093
commit
66df4de8be
@ -154,7 +154,6 @@ if ($conf->use_javascript_ajax)
|
|||||||
$SommeD=0;
|
$SommeD=0;
|
||||||
$dataval=array();
|
$dataval=array();
|
||||||
$datalabels=array();
|
$datalabels=array();
|
||||||
$dataseries=array();
|
|
||||||
foreach ($AdherentType as $key => $adhtype)
|
foreach ($AdherentType as $key => $adhtype)
|
||||||
{
|
{
|
||||||
$datalabels[]=$adhtype->getNomUrl(0,dol_size(16));
|
$datalabels[]=$adhtype->getNomUrl(0,dol_size(16));
|
||||||
@ -167,15 +166,18 @@ if ($conf->use_javascript_ajax)
|
|||||||
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
$SommeC+=isset($MemberUpToDate[$key])?$MemberUpToDate[$key]:0;
|
||||||
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
$SommeD+=isset($MembersResiliated[$key])?$MembersResiliated[$key]:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
$dataseries=array();
|
||||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'values'=> $dataval['draft']);
|
$dataseries[]=array('label'=>$langs->trans("MembersStatusToValid"),'values'=> $dataval['draft']);
|
||||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=> $dataval['notuptodate']);
|
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=> $dataval['notuptodate']);
|
||||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=> $dataval['uptodate']);
|
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=> $dataval['uptodate']);
|
||||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=> $dataval['resiliated']);
|
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=> $dataval['resiliated']);
|
||||||
$data=array('series'=>$dataseries,'xlabel'=>$datalabels);
|
$data=array('series'=>$dataseries,'seriestype'=>array('bar','bar','bar','bar'),'xlabel'=>$datalabels);
|
||||||
dol_print_graph('stats2',300,180,$data,1,'bar');
|
dol_print_graph('stats2',300,180,$data,1,'barline');
|
||||||
$dataseries=array();
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$dataseries=array();
|
||||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=>array(round($SommeB)));
|
$dataseries[]=array('label'=>$langs->trans("MenuMembersNotUpToDate"),'values'=>array(round($SommeB)));
|
||||||
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=>array(round($SommeC)));
|
$dataseries[]=array('label'=>$langs->trans("MenuMembersUpToDate"),'values'=>array(round($SommeC)));
|
||||||
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=>array(round($SommeD)));
|
$dataseries[]=array('label'=>$langs->trans("MembersStatusResiliated"),'values'=>array(round($SommeD)));
|
||||||
|
|||||||
@ -62,7 +62,7 @@ class Propal extends CommonObject
|
|||||||
var $author;
|
var $author;
|
||||||
var $ref;
|
var $ref;
|
||||||
var $ref_client;
|
var $ref_client;
|
||||||
var $statut; // 0, 1, 2, 3, 4
|
var $statut; // 0 (draft), 1 (validated), 2 (signed), 3 (not signed), 4 (billed)
|
||||||
var $datec; // Date of creation
|
var $datec; // Date of creation
|
||||||
var $datev; // Date of validation
|
var $datev; // Date of validation
|
||||||
var $date; // Date of proposal
|
var $date; // Date of proposal
|
||||||
@ -1994,9 +1994,9 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return label of status of proposal (draft, validated, ...)
|
* Return label of status of proposal (draft, validated, ...)
|
||||||
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||||
* \return string Label
|
* @return string Label
|
||||||
*/
|
*/
|
||||||
function getLibStatut($mode=0)
|
function getLibStatut($mode=0)
|
||||||
{
|
{
|
||||||
@ -2004,10 +2004,10 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return label of a status (draft, validated, ...)
|
* Return label of a status (draft, validated, ...)
|
||||||
* \param statut id statut
|
* @param statut id statut
|
||||||
* \param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
* @param mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto
|
||||||
* \return string Label
|
* @return string Label
|
||||||
*/
|
*/
|
||||||
function LibStatut($statut,$mode=1)
|
function LibStatut($statut,$mode=1)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
* Copyright (C) 2004-2007 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -19,11 +19,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/comm/propal/stats/index.php
|
* \file htdocs/comm/propal/stats/index.php
|
||||||
\ingroup propale
|
* \ingroup propale
|
||||||
\brief Page des stats propositions commerciales
|
* \brief Page des stats propositions commerciales
|
||||||
\version $Id$
|
* \version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("../../../main.inc.php");
|
require("../../../main.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propalestats.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/comm/propal/class/propalestats.class.php");
|
||||||
@ -32,7 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/dolgraph.class.php");
|
|||||||
$WIDTH=500;
|
$WIDTH=500;
|
||||||
$HEIGHT=200;
|
$HEIGHT=200;
|
||||||
|
|
||||||
// S<EFBFBD>curit<EFBFBD> acc<63>s client
|
// Security check
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -43,10 +43,13 @@ $year = strftime("%Y", time());
|
|||||||
$startyear=$year-2;
|
$startyear=$year-2;
|
||||||
$endyear=$year;
|
$endyear=$year;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* View
|
* View
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
$langs->load("propal");
|
||||||
|
|
||||||
llxHeader();
|
llxHeader();
|
||||||
|
|
||||||
print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
|
print_fiche_titre($langs->trans("ProposalsStatistics"), $mesg);
|
||||||
|
|||||||
@ -1267,8 +1267,11 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
|||||||
{
|
{
|
||||||
if ($type == 'pie')
|
if ($type == 'pie')
|
||||||
{
|
{
|
||||||
// data is array('series'=>array(0=>serie1,1=>serie2,...));
|
// data is array('series'=>array(serie1,serie2,...),
|
||||||
// serie is array('label'=>'label', values=>array(0=>val))
|
// 'seriestype'=>array('bar','line',...),
|
||||||
|
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
|
||||||
|
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
|
||||||
|
// serieX is array('label'=>'label', values=>array(0=>val))
|
||||||
print '
|
print '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
@ -1314,15 +1317,16 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
|||||||
interactive: true
|
interactive: true
|
||||||
},
|
},
|
||||||
';
|
';
|
||||||
|
$i=0; $outputserie=0;
|
||||||
if (sizeof($datacolor))
|
if (sizeof($datacolor))
|
||||||
{
|
{
|
||||||
print 'colors: [';
|
print 'colors: [';
|
||||||
$j=0;
|
|
||||||
foreach($datacolor as $val)
|
foreach($datacolor as $val)
|
||||||
{
|
{
|
||||||
print '"'.$val.'"';
|
if ($outputserie > 0) print ',';
|
||||||
if ($j < sizeof($datacolor)) print ',';
|
print '"'.(empty($data['seriescolor'][$i])?$val:$data['seriescolor'][$i]).'"';
|
||||||
$j++;
|
$outputserie++;
|
||||||
|
$i++;
|
||||||
}
|
}
|
||||||
print '], ';
|
print '], ';
|
||||||
}
|
}
|
||||||
@ -1333,18 +1337,23 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
|||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
else if ($type == 'bar')
|
else if ($type == 'barline')
|
||||||
{
|
{
|
||||||
// data is array('series'=>array(0=>serie1,1=>serie2,...),'xlabel'=>array(0=>label1,1=>label2,...));
|
// data is array('series'=>array(serie1,serie2,...),
|
||||||
// serie is array('label'=>'label', values=>array(0=>val1,1=>val2,...))
|
// 'seriestype'=>array('bar','line',...),
|
||||||
|
// 'seriescolor'=>array(0=>'#999999',1=>'#999999',...)
|
||||||
|
// 'xlabel'=>array(0=>labelx1,1=>labelx2,...));
|
||||||
|
// serieX is array('label'=>'label', values=>array(0=>y1,1=>y2,...)) with same nb of value than into xlabel
|
||||||
print '
|
print '
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
jQuery(function () {
|
jQuery(function () {
|
||||||
var data = [';
|
var data = [';
|
||||||
$i=1;
|
$i=1; $outputserie=0;
|
||||||
foreach($data['series'] as $serie)
|
foreach($data['series'] as $serie)
|
||||||
{
|
{
|
||||||
print '{label: \''.dol_escape_js($serie['label']).'\', data: [';
|
if ($data['seriestype'][$i-1]=='line') { $i++; continue; };
|
||||||
|
if ($outputserie > 0) print ',';
|
||||||
|
print '{ bars: { stack: 0, show: true, barWidth: 0.9, align: \'center\' }, label: \''.dol_escape_js($serie['label']).'\', data: [';
|
||||||
$j=1;
|
$j=1;
|
||||||
foreach($serie['values'] as $val)
|
foreach($serie['values'] as $val)
|
||||||
{
|
{
|
||||||
@ -1352,8 +1361,28 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
|||||||
if ($j < sizeof($serie['values'])) print ', ';
|
if ($j < sizeof($serie['values'])) print ', ';
|
||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
print ']}';
|
print ']}'."\n";
|
||||||
if ($i < sizeof($data['series'])) print ',';
|
$outputserie++;
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
if ($outputserie) print ', ';
|
||||||
|
//print '];
|
||||||
|
//var datalines = [';
|
||||||
|
$i=1; $outputserie=0;
|
||||||
|
foreach($data['series'] as $serie)
|
||||||
|
{
|
||||||
|
if (empty($data['seriestype'][$i-1]) || $data['seriestype'][$i-1]=='bar') { $i++; continue; };
|
||||||
|
if ($outputserie > 0) print ',';
|
||||||
|
print '{ lines: { show: true }, label: \''.dol_escape_js($serie['label']).'\', data: [';
|
||||||
|
$j=1;
|
||||||
|
foreach($serie['values'] as $val)
|
||||||
|
{
|
||||||
|
print '['.$j.','.$val.']';
|
||||||
|
if ($j < sizeof($serie['values'])) print ', ';
|
||||||
|
$j++;
|
||||||
|
}
|
||||||
|
print ']}'."\n";
|
||||||
|
$outputserie++;
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
print '];
|
print '];
|
||||||
@ -1367,16 +1396,11 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie')
|
|||||||
}
|
}
|
||||||
print '];
|
print '];
|
||||||
|
|
||||||
var stack = 0, bars = true, lines = false, steps = false;
|
|
||||||
|
|
||||||
function plotWithOptions() {
|
function plotWithOptions() {
|
||||||
jQuery.plot(jQuery("#'.$htmlid.'"), data,
|
jQuery.plot(jQuery("#'.$htmlid.'"), data,
|
||||||
{
|
{
|
||||||
series: {
|
series: {
|
||||||
stack: stack,
|
stack: 0
|
||||||
lines: { show: lines, fill: true, steps: steps },
|
|
||||||
bars: { show: bars, barWidth: 0.9, align: \'center\' },
|
|
||||||
shadowSize: 5
|
|
||||||
},
|
},
|
||||||
zoom: {
|
zoom: {
|
||||||
interactive: true
|
interactive: true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user