web: simple register balance chart, using flot

This commit is contained in:
Simon Michael 2011-06-30 00:29:57 +00:00
parent 13227cfc13
commit 35b3c0d37e
8 changed files with 4068 additions and 0 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -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

View File

@ -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}

View File

@ -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)

View File

@ -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