Skip to content

Commit

Permalink
Show pie chart only if there is more than 1 account
Browse files Browse the repository at this point in the history
  • Loading branch information
raboof committed Jan 25, 2021
1 parent 6ef0f22 commit c9d25a8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions hledger-web/Hledger/Web/Handler/RegisterR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ registerPieChartHtml (items, _) = $(hamletFile "templates/piechart.hamlet")
sortOn snd $
flip concatMap items $ \(accname, _, _, Mixed as) ->
flip map as $ \a -> (accname, aquantity a)
showChart = if ((length labelDataTuples) > 1) then "true" else "false" :: String

dayToJsTimestamp :: Day -> Integer
dayToJsTimestamp d =
Expand Down
5 changes: 3 additions & 2 deletions hledger-web/templates/piechart.hamlet
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<label #register-pie-chart-label style=""><br>
<div #register-pie-chart style="height:150px; margin-bottom:1em; display:block;">
<div #register-pie-chart style="height:150px; margin-bottom:1em; display:none;">
<div #piehover>
<script type=text/javascript>
\$(document).ready(function() {
var $chartdiv = $('#register-pie-chart');
if ($chartdiv.is(':visible')) {
if (#{showChart}) {
\$('#register-pie-chart-label').text('#{charttitle}');
\$('#register-pie-chart').show();
var data =
[
$forall (label, dat) <- labelDataTuples
Expand Down

0 comments on commit c9d25a8

Please sign in to comment.