Skip to content

Commit c9d25a8

Browse files
committed
Show pie chart only if there is more than 1 account
1 parent 6ef0f22 commit c9d25a8

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

hledger-web/Hledger/Web/Handler/RegisterR.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ registerPieChartHtml (items, _) = $(hamletFile "templates/piechart.hamlet")
126126
sortOn snd $
127127
flip concatMap items $ \(accname, _, _, Mixed as) ->
128128
flip map as $ \a -> (accname, aquantity a)
129+
showChart = if ((length labelDataTuples) > 1) then "true" else "false" :: String
129130

130131
dayToJsTimestamp :: Day -> Integer
131132
dayToJsTimestamp d =

hledger-web/templates/piechart.hamlet

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<label #register-pie-chart-label style=""><br>
2-
<div #register-pie-chart style="height:150px; margin-bottom:1em; display:block;">
2+
<div #register-pie-chart style="height:150px; margin-bottom:1em; display:none;">
33
<div #piehover>
44
<script type=text/javascript>
55
\$(document).ready(function() {
66
var $chartdiv = $('#register-pie-chart');
7-
if ($chartdiv.is(':visible')) {
7+
if (#{showChart}) {
88
\$('#register-pie-chart-label').text('#{charttitle}');
9+
\$('#register-pie-chart').show();
910
var data =
1011
[
1112
$forall (label, dat) <- labelDataTuples

0 commit comments

Comments
 (0)