mirror of
https://github.com/simonmichael/hledger.git
synced 2024-11-08 07:09:28 +03:00
web: simple register balance chart, using flot
This commit is contained in:
parent
13227cfc13
commit
35b3c0d37e
1427
hledger-web/.hledger/web/static/excanvas.js
Normal file
1427
hledger-web/.hledger/web/static/excanvas.js
Normal file
File diff suppressed because it is too large
Load Diff
1
hledger-web/.hledger/web/static/excanvas.min.js
vendored
Normal file
1
hledger-web/.hledger/web/static/excanvas.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2599
hledger-web/.hledger/web/static/jquery.flot.js
Normal file
2599
hledger-web/.hledger/web/static/jquery.flot.js
Normal file
File diff suppressed because it is too large
Load Diff
6
hledger-web/.hledger/web/static/jquery.flot.min.js
vendored
Normal file
6
hledger-web/.hledger/web/static/jquery.flot.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,3 +1,24 @@
|
||||
<script type=text/javascript>
|
||||
$(document).ready(function() {
|
||||
/* render chart */
|
||||
/* if ($('#register-chart')) */
|
||||
$.plot($('#register-chart'),
|
||||
[
|
||||
[
|
||||
$forall i <- items
|
||||
[#{dayToJsTimestamp $ ariDate i}, #{ariBalance i}],
|
||||
]
|
||||
],
|
||||
{
|
||||
xaxis: {
|
||||
mode: "time",
|
||||
timeformat: "%y/%m/%d"
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
<div#register-chart style="width:600px;height:100px; margin-bottom:1em;"
|
||||
|
||||
<table.registerreport
|
||||
<tr.headings
|
||||
<th.date align=left>Date
|
||||
|
@ -6,6 +6,8 @@
|
||||
<meta http-equiv=Content-Type content="text/html; charset=utf-8"
|
||||
<script type=text/javascript src=@{StaticR jquery_js}
|
||||
<script type=text/javascript src=@{StaticR jquery_url_js}
|
||||
<script type=text/javascript src=@{StaticR jquery_flot_js}
|
||||
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
|
||||
<script type=text/javascript src=@{StaticR dhtmlxcommon_js}
|
||||
<script type=text/javascript src=@{StaticR dhtmlxcombo_js}
|
||||
<script type=text/javascript src=@{StaticR hledger_js}
|
||||
|
@ -15,9 +15,12 @@ import Data.List
|
||||
import Data.Maybe
|
||||
import Data.Text(Text,pack,unpack)
|
||||
import Data.Time.Calendar
|
||||
import Data.Time.Clock
|
||||
import Data.Time.Format
|
||||
-- import Safe
|
||||
import System.FilePath (takeFileName, (</>))
|
||||
import System.IO.Storage (putValue, getValue)
|
||||
import System.Locale (defaultTimeLocale)
|
||||
import Text.Hamlet hiding (hamletFile)
|
||||
import Text.Printf
|
||||
import Yesod.Form
|
||||
@ -490,3 +493,6 @@ getMessageOr mnewmsg = do
|
||||
|
||||
numbered = zip [1..]
|
||||
|
||||
dayToJsTimestamp :: Day -> Integer
|
||||
dayToJsTimestamp d = read (formatTime defaultTimeLocale "%s" t) * 1000
|
||||
where t = UTCTime d (secondsToDiffTime 0)
|
@ -16,6 +16,8 @@ module Hledger.Cli.Register (
|
||||
,journalRegisterReport
|
||||
,postingRegisterReportAsText
|
||||
,showPostingWithBalanceForVty
|
||||
,ariDate
|
||||
,ariBalance
|
||||
,tests_Hledger_Cli_Register
|
||||
) where
|
||||
|
||||
@ -66,6 +68,10 @@ type AccountRegisterReportItem = (Transaction -- the corresponding transaction
|
||||
,MixedAmount -- the running balance for the focussed account after this transaction
|
||||
)
|
||||
|
||||
ariDate (t,_,_,_,_,_) = tdate t
|
||||
ariBalance (_,_,_,_,_,Mixed a) = case a of [] -> "0"
|
||||
(Amount{quantity=q}):_ -> show q
|
||||
|
||||
-- | Print a (posting) register report.
|
||||
register :: [Opt] -> [String] -> Journal -> IO ()
|
||||
register opts args j = do
|
||||
|
Loading…
Reference in New Issue
Block a user