emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Table formula and text properties


From: Michael Brand
Subject: Re: [O] Table formula and text properties
Date: Thu, 8 Jan 2015 18:26:50 +0100

Hi Wim

On Wed, Jan 7, 2015 at 6:11 PM, Willem Rein Oudshoorn
<address@hidden> wrote:
> I am trying to insert an image into a table by using a table formula.
> My basic approach is by using a string with a display property like:
>
>
>   (propertize "TEXT" 'display (list image))
>
>
> Or to be more precise
>
>    (propertize "SPARKLINE" 'display
>                (list (sparkline-make-sparkline
>                         100 10
>                            '(1 20 12 13 141 13 24 90))))
>
> In which the `sparkline-make-sparkline' function returns an image.

Very interesting. Your package to insert a sparkline image
http://en.wikipedia.org/wiki/Sparkline
into an Emacs buffer is nice:
https://github.com/woudshoo/sparkline

> Inserting the resulting string with `insert' into a buffer will ensure
> the image is displayed.
>
> However org mode table formula code seems to strip the display property
> from the string returned by the formula.  So this trick will not work.

I think this is by design. If someone wants to change current behavior
then there are other issues to be considered: An 80 by 8 pixel image
that is inserted with

    (insert-image
     (sparkline-make-sparkline 80 8 '(1 20 12 13 141 13 24 90))
     "SPARKLINE")

with point in a table is first visible as an image but will change to
the text "SPARKLINE" after e. g. table realignment. And determining
column width around an image for table realignment would not be
trivial.

> Is there a way to insert a calculated image into an org table?

Below is a unicode ASCII art solution with Zach Holman's shell script
package Spark:
https://github.com/holman/spark

| Measurement | t0 | t1 | t2 | t3 |  t4 | t5 | t6 | t7 | Sparkline |
|-------------+----+----+----+----+-----+----+----+----+-----------|
|           1 |  1 | 20 | 12 | 13 | 141 | 13 | 24 | 90 | ▁▁▁▁█▁▂▅  |
|           2 |  0 |  1 |  2 |  3 |   4 |  5 |  6 |  7 | ▁▂▃▄▅▆▇█  |
|           3 |  0 |  2 |  4 |  6 |   8 | 10 | 12 | 14 | ▁▂▃▄▅▆▇█  |
|           4 | -7 | -6 | -5 | -4 |  -3 | -2 | -1 |  0 | ▁▂▃▄▅▆▇█  |
|           5 |  0 |  0 |  0 |  0 |   0 |  0 |  0 |  0 | ▅▅▅▅▅▅▅▅  |
#+TBLFM: $10 = '(org-trim (shell-command-to-string "spark $2..$9")); L

It would be nice if in your package someone could support one of

    (sparkline-make-sparkline nil nil
                              '(1 20 12 13 141 13 24 90)) => "▁▁▁▁█▁▂▅"
    (sparkline-make-unicode 1 20 12 13 141 13 24 90) => "▁▁▁▁█▁▂▅"

to work like Zach Holman's Spark to replace the above TBLFM with one
of

    #+TBLFM: $10 = '(sparkline-make-sparkline nil nil '($2..$9)); L
    #+TBLFM: $10 = '(sparkline-make-unicode $2..$9); L

For completeness I would like to mention Thierry Banel's
orgtbl-ascii-plot which has been added to Org core meanwhile:
http://orgmode.org/worg/org-contrib/orgtbl-ascii-plot.html

Michael



reply via email to

[Prev in Thread] Current Thread [Next in Thread]