I would like to make partially colored cells as is shown in the answers here Partially coloring cell background with histograms.
TikZ example does not work for me and I would rather use the answer without TikZ.
The problem I have is that I have column headers and then the coloring does not start at the left border of the cell any more.
Here is an minimal working example I have made from the answer above:
\documentclass{article}
\usepackage[table]{xcolor}% http://ctan.org/pkg/xcolor
\usepackage[nomessages]{fp}% http://ctan.org/pkg/fp
\newlength{\maxlen}
\newcommand{\databar}[3][green!50]{%
\settowidth{\maxlen}{#2}%
\addtolength{\maxlen}{\dimexpr2\tabcolsep-\arrayrulewidth}%
\FPeval\result{round(#3/#2:4)}%
\rlap{\color{#1}\hspace*{\dimexpr-\tabcolsep+.5\arrayrulewidth}\rule[-.05\ht\strutbox]{\result\maxlen}{.95\ht\strutbox}}%
\makebox[\dimexpr\maxlen-2\tabcolsep+\arrayrulewidth][r]{#3}%
}
\begin{document}
\begin{tabular}{ | l | r |}
\hline
Name & Value column which is much wider \\
\hline
name1 & \databar{10.0}{1} \\
name2 & \databar{10.0}{2} \\
name3 & \databar{10.0}{3} \\
name4 & \databar{10.0}{4} \\
name5 & \databar{10.0}{5} \\
name6 & \databar{10.0}{6} \\
name7 & \databar{10.0}{8} \\
name8 & \databar{10.0}{8} \\
name9 & \databar{10.0}{9} \\
name10 & \databar{10.0}{10} \\
\hline
\end{tabular}
\end{document}
I would like the bars to extend over the whole column and not just on the right side of it. How can I do that? Thanks!
r
tol
. The other thing is that the column width is driven by the column title width, not the data.