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
|
<table.registerreport
|
||||||
<tr.headings
|
<tr.headings
|
||||||
<th.date align=left>Date
|
<th.date align=left>Date
|
||||||
|
|||||||
@ -6,6 +6,8 @@
|
|||||||
<meta http-equiv=Content-Type content="text/html; charset=utf-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_js}
|
||||||
<script type=text/javascript src=@{StaticR jquery_url_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 dhtmlxcommon_js}
|
||||||
<script type=text/javascript src=@{StaticR dhtmlxcombo_js}
|
<script type=text/javascript src=@{StaticR dhtmlxcombo_js}
|
||||||
<script type=text/javascript src=@{StaticR hledger_js}
|
<script type=text/javascript src=@{StaticR hledger_js}
|
||||||
|
|||||||
@ -15,9 +15,12 @@ import Data.List
|
|||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
import Data.Text(Text,pack,unpack)
|
import Data.Text(Text,pack,unpack)
|
||||||
import Data.Time.Calendar
|
import Data.Time.Calendar
|
||||||
|
import Data.Time.Clock
|
||||||
|
import Data.Time.Format
|
||||||
-- import Safe
|
-- import Safe
|
||||||
import System.FilePath (takeFileName, (</>))
|
import System.FilePath (takeFileName, (</>))
|
||||||
import System.IO.Storage (putValue, getValue)
|
import System.IO.Storage (putValue, getValue)
|
||||||
|
import System.Locale (defaultTimeLocale)
|
||||||
import Text.Hamlet hiding (hamletFile)
|
import Text.Hamlet hiding (hamletFile)
|
||||||
import Text.Printf
|
import Text.Printf
|
||||||
import Yesod.Form
|
import Yesod.Form
|
||||||
@ -490,3 +493,6 @@ getMessageOr mnewmsg = do
|
|||||||
|
|
||||||
numbered = zip [1..]
|
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
|
,journalRegisterReport
|
||||||
,postingRegisterReportAsText
|
,postingRegisterReportAsText
|
||||||
,showPostingWithBalanceForVty
|
,showPostingWithBalanceForVty
|
||||||
|
,ariDate
|
||||||
|
,ariBalance
|
||||||
,tests_Hledger_Cli_Register
|
,tests_Hledger_Cli_Register
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@ -66,6 +68,10 @@ type AccountRegisterReportItem = (Transaction -- the corresponding transaction
|
|||||||
,MixedAmount -- the running balance for the focussed account after this 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.
|
-- | Print a (posting) register report.
|
||||||
register :: [Opt] -> [String] -> Journal -> IO ()
|
register :: [Opt] -> [String] -> Journal -> IO ()
|
||||||
register opts args j = do
|
register opts args j = do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user