Overview
Artifact ID: | 90398bc3e05b47ccef4a0d5357a0c25f163cd365 |
---|---|
Ticket: | e6a2c8e0d9b280b53ae32ff1fc2eb2cd3f15c8fa
Camemberts de recettes/dépenses par valeur plutot que par nombre de transactions |
User & Date: | ghostdog on 2014-11-21 17:13:49 |
Changes
- foundin changed to: "0.6.2"
- icomment:
Les camemberts dans la vue comptabilité montre des pourcentages en nombre de transaction et pas en valeur de transaction (c'est à dire si vous avez 2 catégories de recettes une de 50€ et une de 150€: le camembert est coupé en deux parts égales). Le patch ci-dessous permet d'avoir des pourcentages par valeur. $ diff -u include/libs/svgplot/lib.svgpie.php.orig include/libs/svgplot/lib.svgpie.php --- include/libs/svgplot/lib.svgpie.php.orig 2014-11-21 16:12:54.841072386 +0100 +++ include/libs/svgplot/lib.svgpie.php 2014-11-21 16:54:43.147069985 +0100 @@ -64,15 +64,15 @@ foreach ($this->data as $row) { - $sum += $row->data; + $sum += $row->somme; } foreach ($this->data as $row) { - $row->angle = ceil(360 * $row->data / $sum); + $row->angle = ceil(360 * $row->somme / $sum); - $start_angle = $end_angle; - $end_angle = $start_angle + $row->angle; + $start_angle = $end_angle; + $end_angle = $start_angle + $row->angle; $x1 = $cx + $radius * cos(deg2rad($start_angle)); $y1 = $cy + $radius * sin(deg2rad($start_angle)); @@ -84,7 +84,7 @@ $out .= "<path d=\"M{$cx},{$cy} L{$x1},{$y1} A{$radius},{$radius} 0 {$arc},1 {$x2},{$y2} Z\" fill=\"{$row->fill}\" stroke=\"white\" stroke-width=\"".($circle_size * 0.005)."\" stroke-linecap=\"round\" - stroke-linejoin=\"round\" />"; + stroke-linejoin=\"round\" />" . PHP_EOL; } } @@ -132,12 +132,14 @@ public $fill = 'blue'; public $data = 0.0; public $label = null; + public $somme = 0.0; - public function __construct($data, $label = null, $fill = 'blue') + public function __construct($data, $label = null, $fill = 'blue', $somme) { $this->data = $data; $this->fill = $fill; $this->label = $label; + $this->somme = $somme; } } $ diff -u include/class.compta_stats.php.orig include/class.compta_stats.php --- include/class.compta_stats.php.orig 2014-11-21 16:26:11.011071624 +0100 +++ include/class.compta_stats.php 2014-11-21 16:32:23.436071268 +0100 @@ -7,7 +7,7 @@ protected function _parRepartitionCategorie($type) { $db = DB::getInstance(); - return $db->simpleStatementFetch('SELECT COUNT(*) AS nb, id_categorie + return $db->simpleStatementFetch('SELECT COUNT(*) AS nb, id_categorie, SUM(montant) AS somme FROM compta_journal WHERE id_categorie IN (SELECT id FROM compta_categories WHERE type = ?) AND id_exercice = (SELECT id FROM compta_exercices WHERE cloture = 0) $ diff -u www/admin/compta/pie.php.orig www/admin/compta/pie.php --- www/admin/compta/pie.php.orig 2014-11-21 16:40:08.583070822 +0100 +++ www/admin/compta/pie.php 2014-11-21 16:38:38.373070908 +0100 @@ -33,6 +33,7 @@ } $others = 0; + $somme_others = 0; $colors = ['#c71', '#941', '#fa4', '#fd9', '#ffc', '#cc9']; $max = count($colors); $i = 0; @@ -42,17 +43,18 @@ if ($i++ >= $max) { $others += $row['nb']; + $somme_others += $row['somme']; } else { $cat = $categories[$row['id_categorie']]; - $pie->add(new \SVGPie_Data($row['nb'], substr($cat['intitule'], 0, 50), $colors[$i-1])); + $pie->add(new \SVGPie_Data($row['nb'], substr($cat['intitule'], 0, 50), $colors[$i-1], $row['somme'])); } } if ($others > 0) { - $pie->add(new \SVGPie_Data($others, 'Autres', '#ccc')); + $pie->add(new \SVGPie_Data($others, 'Autres', '#ccc', $somme_others)); } Static_Cache::store('pie_' . $graph, $pie->output());
- login: "ghostdog"
- mimetype: "text/x-fossil-plain"
- private_contact changed to: "f49fb24b6279d8e333bc8f352600b84edcc7cdb6"
- severity changed to: "Minor"
- status changed to: "Open"
- title changed to:
Camemberts de recettes/dépenses par valeur plutot que par nombre de transactions
- type changed to: "Feature_Request"