all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Brand <michael.ch.brand@gmail.com>
To: Willem Rein Oudshoorn <woudshoo@xs4all.nl>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: Table formula and text properties
Date: Thu, 8 Jan 2015 18:26:50 +0100	[thread overview]
Message-ID: <CALn3zoicim1Sj6mCdG96c+y-arxyH8NdnR_Zukh4a8ODQxCprg@mail.gmail.com> (raw)
In-Reply-To: <m1y4pewm6a.fsf@Wims-MBP.fritz.box>

Hi Wim

On Wed, Jan 7, 2015 at 6:11 PM, Willem Rein Oudshoorn
<woudshoo@xs4all.nl> 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	other threads:[~2015-01-08 17:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-07 17:11 Table formula and text properties Willem Rein Oudshoorn
2015-01-08 17:26 ` Michael Brand [this message]
2015-01-08 18:52   ` Willem Rein Oudshoorn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALn3zoicim1Sj6mCdG96c+y-arxyH8NdnR_Zukh4a8ODQxCprg@mail.gmail.com \
    --to=michael.ch.brand@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=woudshoo@xs4all.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.