Function: orgtbl-ascii-plot
orgtbl-ascii-plot is an autoloaded, interactive and byte-compiled
function defined in org-table.el.gz.
Signature
(orgtbl-ascii-plot &optional ASK)
Documentation
Draw an ASCII bar plot in a column.
With cursor in a column containing numerical values, this function will draw a plot in a new column.
ASK, if given, is a numeric prefix to override the default 12
characters width of the plot. ASK may also be the C-u (universal-argument) prefix,
which will prompt for the width.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-table.el.gz
;;;###autoload
(defun orgtbl-ascii-plot (&optional ask)
"Draw an ASCII bar plot in a column.
With cursor in a column containing numerical values, this function
will draw a plot in a new column.
ASK, if given, is a numeric prefix to override the default 12
characters width of the plot. ASK may also be the `\\[universal-argument]' \
prefix,
which will prompt for the width."
(interactive "P")
(let ((col (org-table-current-column))
(min 1e999) ; 1e999 will be converted to infinity
(max -1e999) ; which is the desired result
(table (org-table-to-lisp))
(length
(cond ((consp ask)
(read-number "Length of column " 12))
((numberp ask) ask)
(t 12))))
;; Skip any hline a the top of table.
(while (eq (car table) 'hline) (pop table))
;; Skip table header if any.
(dolist (x (or (cdr (memq 'hline table)) table))
(when (consp x)
(setq x (nth (1- col) x))
(when (string-match
"^[-+]?\\([0-9]*[.]\\)?[0-9]*\\([eE][+-]?[0-9]+\\)?$"
x)
(setq x (string-to-number x))
(when (> min x) (setq min x))
(when (< max x) (setq max x)))))
(org-table-insert-column)
(org-table-move-column-right)
(org-table-store-formulas
(cons
(cons
(concat "$" (number-to-string (1+ col)))
(format "'(%s $%s %s %s %s)"
"orgtbl-ascii-draw" col min max length))
(org-table-get-stored-formulas)))
(org-table-recalculate t)))