From 03c0ab007954be7ecd22dba11575c66795b9f905 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Arroyo=20Men=C3=A9ndez?= Date: Wed, 15 Oct 2014 14:58:13 +0200 Subject: [PATCH] org-effectiveness.el: Add org-effectiveness-plot-save * contrib/lisp/org-effectiveness.el (org-effectiveness-plot): Adapt source to save as file image. (org-effectiveness-plot-save): Add function. --- contrib/lisp/org-effectiveness.el | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/contrib/lisp/org-effectiveness.el b/contrib/lisp/org-effectiveness.el index 1e80d1f90..0d830abd1 100644 --- a/contrib/lisp/org-effectiveness.el +++ b/contrib/lisp/org-effectiveness.el @@ -127,7 +127,7 @@ many TODO pending" (concat "0" (number-to-string m)) (number-to-string m))) -(defun org-effectiveness-plot(startdate enddate) +(defun org-effectiveness-plot(startdate enddate &optional save) (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) (setq dates (org-effectiveness-check-dates startdate enddate)) (setq syear (cadr (assoc 'startyear dates))) @@ -165,10 +165,20 @@ many TODO pending" (setq month (+ 1 month)))) (write-region str nil "/tmp/org-effectiveness")) ;; Create the bar graph + (if (eq save t) + (setq strplot "/usr/bin/gnuplot -e 'set term png; set output \"/tmp/org-effectiveness.png\"; plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p") + (setq strplot "/usr/bin/gnuplot -e 'plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p")) (if (file-exists-p "/usr/bin/gnuplot") - (call-process "/bin/bash" nil t nil "-c" "/usr/bin/gnuplot -e 'plot \"/tmp/org-effectiveness\" using 2:xticlabels(1) with histograms' -p") + (call-process "/bin/bash" nil t nil "-c" strplot) (message "gnuplot is not installed"))) +(defun org-effectiveness-plot-save(startdate enddate &optional save) + (interactive "sGive me the start date: \nsGive me the end date: " startdate enddate) + (org-effectiveness-plot startdate enddate t)) + +;; (defun org-effectiveness-plot(startdate enddate) + + (defun org-effectiveness-ascii-bar(n &optional label) "Print a bar with the percentage from 0 to 100 printed in ascii" (interactive "nPercentage: \nsLabel: ")