我希望条形标签的样式具有与第一行或第二行标题相同的效果,我尝试了很多方法,都没有用,请看粗体部分(**) 的代码。**\ganttset{bar label/.append style=%canvas/.style={draw=none}, {fill=olive!20, rounded corners=2mm}}% \ganttbar[条形标签/.style={fill=olive!20, rounded corners=2mm}]
\documentclass[border=5pt]{standalone}%{article}
\usepackage{pgfgantt,tikz}
\usetikzlibrary{shadows}
\usetikzlibrary{shadings}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage[LoadFandol]{xeCJK}
\setCJKmainfont{SimSun}
\makeatletter
\ganttset{title/.append style=%canvas/.style={draw=none},
{fill=blue!20, rounded corners=2mm}}%, drop shadow
**\ganttset{bar label/.append style=%canvas/.style={draw=none},
{fill=olive!20, rounded corners=2mm}}**%, drop shadow
\makeatother
\begin{document}
\begin{ganttchart}[
x unit = 0.3cm,
y unit title=0.5cm,
y unit chart=0.7cm,
vgrid={*{2}{gray!60, dashed}, *1{black}},
hgrid,
title height=1,
title label font=\bfseries\footnotesize,
bar label font=\color{olive},
bar/.append style={fill=lime},
bar label font=\bfseries\footnotesize,
]{1}{39}
\gantttitle[]{2016}{12}
\gantttitle[]{2017}{27}\\
\gantttitlelist[
title/.style={inner color=red,rounded corners=2mm}%draw=none,
]{9,...,12,1,2,...,9}{3} \\
**\ganttbar[bar label/.style={fill=olive!20, rounded corners=2mm}]**{一}{1}{24} \\
\ganttbar{二}{19}{21} \\
\ganttbar{三}{22}{24} \\
\ganttbar{四}{22}{27}
\end{ganttchart}
\end{document}
如何调整垂直对齐的条形标签位置?如何缩放第二行标题以适合表格大小?
谢谢,
答案1
您现在编辑后提出的问题似乎与您最初提出的两个问题完全无关,我仍然不明白。
但要回答新的问题,bar label node
我认为你想修改的是风格,而不是风格bar label
。
\documentclass[border=5mm]{standalone}%{article}
\usepackage{pgfgantt}
\ganttset{title/.append style=%canvas/.style={draw=none},
{fill=blue!20, rounded corners=2mm}}%, drop shadow
\begin{document}
\begin{ganttchart}[
x unit = 0.3cm,
y unit title=0.5cm,
y unit chart=0.7cm,
vgrid={*{2}{gray!60, dashed}, *1{black}},
hgrid,
title height=1,
title label font=\bfseries\footnotesize,
bar label font=\color{olive},
bar/.append style={fill=lime},
bar label font=\bfseries\footnotesize,
bar label node/.append style={fill=olive!20, rounded corners=2mm} %% <--- this one
]{1}{39}
\gantttitle[]{2016}{12}
\gantttitle[]{2017}{27}\\
\gantttitlelist[
title/.style={inner color=red,rounded corners=2mm}%draw=none,
]{9,...,12,1,2,...,9}{3} \\
\ganttbar{A}{1}{24} \\
\ganttbar{B}{19}{21} \\
\ganttbar{C}{22}{24} \\
\ganttbar{D}{22}{27}
\end{ganttchart}
\end{document}