summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Rische <leon.rische@me.com>2020-10-02 12:21:13 +0200
committerLeon Rische <leon.rische@me.com>2020-10-02 12:21:13 +0200
commit609dca88a8701d5c80511bb894ddabc72271c727 (patch)
treebd52001acb38fe31e70ace88b18a0bbeb66f7635
parent0fd72b4d9dcf82584b784bb7cf76d94109ee9bab (diff)
Add percentages to svg bar charts
-rw-r--r--org-fc.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/org-fc.el b/org-fc.el
index f775d2c..d2146c3 100644
--- a/org-fc.el
+++ b/org-fc.el
@@ -1570,6 +1570,7 @@ Pauses the review, unnarrows the buffer and activates
"Generate a svg bar-chart for the plist STAT."
(let* ((width org-fc-dashboard-bar-chart-width)
(height org-fc-dashboard-bar-chart-height)
+ (fontsize (floor (* height 0.6)))
(total (float (plist-get stat :total)))
(pos 0)
(values
@@ -1580,6 +1581,14 @@ Pauses the review, unnarrows the buffer and activates
(svg (svg-create width height)))
(dolist (value values)
(svg-rectangle svg pos 0 (* width (car value)) height :fill (cdr value))
+ (if (> (* width (car value)) (* 2 fontsize))
+ (svg-text svg (format "%.1f" (* 100 (car value)))
+ :font-size fontsize
+ :fill "white"
+ :font-weight "bold"
+ :font-family "sans-serif"
+ :x (+ pos 5)
+ :y (+ fontsize (floor (- height fontsize) 2))))
(setq pos (+ pos (* width (car value)))))
(svg-image svg)))
@@ -1667,14 +1676,13 @@ Pauses the review, unnarrows the buffer and activates
(:all . "All")))
(when-let (stat (plist-get reviews-stats (car scope)))
(when (> (plist-get stat :total) 0)
- (insert (propertize (format " %s (%d)\n" (cdr scope) (plist-get stat :total)) 'face 'org-level-1))
(insert " ")
(if (and (display-graphic-p)
(memq 'svg (and (boundp 'image-types) image-types)))
(insert-image (org-fc-dashboard-bar-chart stat))
(insert (org-fc-dashboard-text-bar-chart stat)))
- (insert (org-fc-dashboard-percent-right stat))
- (insert "\n\n"))))
+ (insert (propertize (format " %s (%d)\n\n" (cdr scope) (plist-get stat :total)) 'face 'org-level-1))
+ )))
(insert "\n"))
(insert
(propertize " [r] Review\n" 'face 'org-level-1))