From c0e7b1bc0dc1fec9af3d60adba5620abba2756d6 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Wed, 6 Sep 2023 14:42:19 +0800 Subject: account: modify svg and move all-cost to the front * account.el (account-agenda-command, account-agenda-shop-command): Display the sum of all costs at the beginning instead of at the end. This is more convenient. (account-agenda-export-to-svg): Fix the widths of blocks of each day in the output SVG to be 150, and the total width of the image will depend on the number of days to display. This is necessary if I want to put text under the blocks. --- account.el | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/account.el b/account.el index b17f304..c6b01bf 100644 --- a/account.el +++ b/account.el @@ -567,13 +567,21 @@ MATCH is required by Org-agenda, and relentlessly ignored by us." (with-current-buffer buffer (account-collect-into-vec titles account-agenda-collector))) + (mapc + (lambda (element) + (setq all-cost (+ all-cost (car (cdr element))))) + info) + (insert + (propertize + (format "all: %d" all-cost) + 'face 'org-agenda-calendar-event)) + (newline 2) (mapc (lambda (element) (let* ((title (car element)) (cost (car (cdr element))) (date (get-text-property 0 'date title)) (date-face (org-agenda-get-day-face date))) - (setq all-cost (+ all-cost cost)) (insert (propertize title 'face date-face)) (newline) (mapc @@ -596,11 +604,6 @@ MATCH is required by Org-agenda, and relentlessly ignored by us." 'date date))) (newline)) info) - (newline 2) - (insert - (propertize - (format "all: %d" all-cost) - 'face 'org-agenda-calendar-event)) (newline) (goto-char (point-min)) (account-mode))) @@ -679,6 +682,11 @@ MATCH is required by Org-agenda, and relentlessly ignored by us." shop-cost-alist (lambda (cell1 cell2) (>= (cdr cell1) (cdr cell2))))) + (insert + (propertize + (format "all: %d" all-cost) + 'face 'org-agenda-calendar-event)) + (newline 2) (mapc (lambda (cell) (insert @@ -690,11 +698,6 @@ MATCH is required by Org-agenda, and relentlessly ignored by us." 'face 'org-agenda-calendar-event)) (newline)) shop-cost-alist) - (newline 2) - (insert - (propertize - (format "all: %d" all-cost) - 'face 'org-agenda-calendar-event)) (newline) (goto-char (point-min)) (account-mode))) @@ -932,13 +935,14 @@ a match." (setq temp (cdr temp)))) (require 'svg) (let* ((len (length result)) - (block-width (/ 800.0 len)) + (block-width 115) + (width (ceiling (* block-width len))) (index 0) (start 0) - (svg (svg-create 800 700 :stroke-width 10))) + (svg (svg-create width 700 :stroke-width 10))) (svg-circle svg - 400 350 1000 + (ceiling width 2) 350 (max width 1000) :fill-color "white") (mapc (lambda (cell) -- cgit v1.2.3-18-g5258