4

I am trying to make something like excel databars in context TABLE enviroment. I have created overlay, that should draw the databar, but I can't figure out, how to pass data into that overlay.

Is it possible to make something like

\defineoverlay[demo circle #1][\useMPgraphic{demo circle}{color=#1}]

??? or is there any other way, how to draw cell background of TBALE (\bTD) by Metapost and pass in data, that will be accessible by \MPvar?

minimal working example:

\mainlanguage[cz]
\setuppapersize[A4][A4]
\setuplayout[topspace=2cm,backspace=2cm,width=middle,height=middle,header=0.6cm,footer=0.7cm,footerdistance=0.2cm,headerdistance=0.2cm]
\setupcolors[state=start]

\startuseMPgraphic{demo circle}
path p ;
p := fullcircle xscaled \overlaywidth yscaled \overlayheight ;
fill p withcolor .85white ;
draw p withpen pencircle scaled 2pt withcolor \MPvar{color} ;
\stopuseMPgraphic

\defineoverlay[demo circle #1][\useMPgraphic{demo circle}{color=#1}]

\starttext

\placetable{Test}{\bTABLE
\bTR \bTD[background=demo circle blue] aaaaa \eTD \bTD[background=demo circle red] bbbbb \eTD \eTR
\bTR \bTD[background=demo circle green] cccccc \eTD \bTD[background=demo circle black] dddddd \eTD \eTR
\eTABLE}
\stoptext
3
  • Please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – cfr
    Dec 28, 2014 at 3:58
  • 2
    @cfr: I agree with the spirit of your comment (the need for a MWE), but note that this is a question related to ConTeXt, so there will be no \documentclass{...} ... \end{document}.
    – Aditya
    Dec 28, 2014 at 7:25
  • @Aditya Oops. Indeed. I cut-and-pasted the standard comment block without thinking about it, but you are obviously right.
    – cfr
    Dec 28, 2014 at 14:22

1 Answer 1

4

The standard way to pass color options to a frame is to use the framecolor key. The value of that key can be accessed using \overlaylinecolor. For example:

\setupcolors[state=start]

\startuseMPgraphic{demo circle}
   newpath p ;
   p := fullcircle xscaled \overlaywidth yscaled \overlayheight ;
   fill p withcolor .85white ;
   draw p withpen pencircle scaled 2pt withcolor \MPcolor{\overlaylinecolor} ;
\stopuseMPgraphic

\defineoverlay[demo circle][\useMPgraphic{demo circle}]

\starttext

\placetable{Test}
  {\bTABLE
      \bTR 
          \bTD[background=demo circle, framecolor=red]
              aaaaa
          \eTD
          \bTD[background=demo circle, framecolor=red]
              bbbbb 
          \eTD 
      \eTR
      \bTR 
          \bTD[background=demo circle, framecolor=green]
              cccccc
          \eTD 
          \bTD[background=demo circle, framecolor=green]
              dddddd 
          \eTD 
      \eTR
  \eTABLE}
\stoptext

which gives

enter image description here

You can use frame=off to avoid the default frames.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .