From 582ed1b56939a20297b054eb5a5073802d62c1a9 Mon Sep 17 00:00:00 2001 From: David Arroyo Menendez Date: Sun, 4 May 2014 16:29:34 +0200 Subject: [PATCH] org-effectiveness.el (org-effectiveness-plot-html, org-effectiveness-html-bar): creation * org-effectiveness.el (org-effectiveness-plot-html, org-effectiveness-html-bar): creation --- contrib/lisp/org-effectiveness.el | 39 +++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/contrib/lisp/org-effectiveness.el b/contrib/lisp/org-effectiveness.el index c8d8e53c1..1e80d1f90 100644 --- a/contrib/lisp/org-effectiveness.el +++ b/contrib/lisp/org-effectiveness.el @@ -196,6 +196,18 @@ many TODO pending" (setq z (+ z 1))) (insert "+")))) +(defun org-effectiveness-html-bar(n &optional label) + "Print a bar with the percentage from 0 to 100 printed in html" + (interactive "nPercentage: \nsLabel: ") + (if (or (< n 0) (> n 100)) + (message "The percentage must be between 0 to 100") + (let ((x 0) + (y 0) + (z 0)) + (insert (format "\n
%d
" n n)) +))) + + (defun org-effectiveness-check-dates (startdate enddate) "Generate a list with ((startyear startmonth) (endyear endmonth))" (setq str nil) @@ -244,6 +256,33 @@ many TODO pending" (setq month (+ 1 month))))) (switch-to-buffer "*org-effectiveness*")) +(defun org-effectiveness-plot-html (startdate enddate) + "Print html bars about the effectiveness in a buffer" + (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) + (setq dates (org-effectiveness-check-dates startdate enddate)) + (let ((syear (cadr (assoc 'startyear dates))) + (smonth (cadr (assoc 'startmonth dates))) + (year (cadr (assoc 'startyear dates))) + (month (cadr (assoc 'startmonth dates))) + (emonth (cadr (assoc 'endmonth dates))) + (eyear (cadr (assoc 'endyear dates))) + (buffer (current-buffer)) + (str "")) + (switch-to-buffer "*org-effectiveness-html*") + (insert "Graphbar") + (while (or (> eyear year) (and (= eyear year) (>= emonth month))) + (setq str (org-effectiveness-in-date (concat (number-to-string year) "-" (org-effectiveness-month-to-string month)) 1)) + (switch-to-buffer "*org-effectiveness-html*") + (org-effectiveness-html-bar (string-to-number str) (format "%s-%s" year month)) + (switch-to-buffer buffer) + (format "%s-%s" year month) + (if (eq month 12) + (progn + (setq year (+ 1 year)) + (setq month 1)) + (setq month (+ 1 month)))) + (switch-to-buffer "*org-effectiveness-html*") + (insert ""))) (provide 'org-effectiveness)