How to do to draw a Tikz tree layout graph background

I try to draw a background on a tree layout graph but whatever the method I use, lualatex throws this error: Dimension too large.

I test show background rectangle, fit, local boonding box with scope environnement methods but i got the same error.

I suspect that this methods are called before the graphs are drawn. But I don't know how to do to draw a background on it.

\documentclass[a4paper,landscape]{article} \usepackage{tikz} \usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit} \usegdlibrary{trees}  \begin{document} \begin{tikzpicture}[local bounding box=bb, tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,      site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]     \node [label=center:Internet] (internet) {};     \node [label=center:SDSL] (sdsl) {};     \node [label=center:CORE] (core) {};     \node [label=center:Site 1, site] (site01) {};      \graph [use existing nodes] {         core -- sdsl;         core -- internet;         sdsl -- site01     };     %\node[fill=black!20,fit=(internet) (core) (sdsl) (site01)] {};     \node[fill=black!20,fit=(bb)] {}; \end{tikzpicture} \end{document} 

I use pgf 3.0.0 with lualatex.

Replay

This is not an answer because I don't know what happens. But in case you could use it, a possible workaround consists in drawing a transparent node around your figure with remember picture help.

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}

\begin{document}
\begin{tikzpicture}[remember picture, local bounding box=bb, tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
     site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
    \node [label=center:Internet] (internet) {};
    \node [label=center:SDSL] (sdsl) {};
    \node [label=center:CORE] (core) {};
    \node [label=center:Site 1, site] (site01) {};

    \graph [use existing nodes] {
        core -- sdsl;
        core -- internet;
        sdsl -- site01
    };
\end{tikzpicture}

\begin{tikzpicture}[remember picture,overlay]
    \node[fill=black!20,fit=(internet) (site01), opacity=.3] {};
\end{tikzpicture}
\end{document}

How to do to draw a Tikz tree layout graph background

And a second workaround could be to use a tcbox (from tcolorbox package)

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}
\usepackage{tcolorbox}

\begin{document}
\tcbox{
\begin{tikzpicture}[tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
     site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
    \node [label=center:Internet] (internet) {};
    \node [label=center:SDSL] (sdsl) {};
    \node [label=center:CORE] (core) {};
    \node [label=center:Site 1, site] (site01) {};

    \graph [use existing nodes] {
        core -- sdsl;
        core -- internet;
        sdsl -- site01
    };
\end{tikzpicture}
}
\end{document}

How to do to draw a Tikz tree layout graph background

You may use some scopes to work around this feature/bug(?) of graphdrawing library:

\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{graphs, graphdrawing, backgrounds, positioning, fit}
\usegdlibrary{trees}

\begin{document}
\begin{tikzpicture}
  \begin{scope}[local bounding box=bb,tree layout, level distance=2cm, sibling sep=.5em, sibling distance=1cm,
    site/.style={draw=blue!50, fill=blue!20, thick, inner sep=0pt, minimum size=2cm}]
    \node [label=center:Internet] (internet) {};
    \node [label=center:SDSL] (sdsl) {};
    \node [label=center:CORE] (core) {};
    \node [label=center:Site 1, site] (site01) {};

    \graph [use existing nodes] {
      core -- sdsl;
      core -- internet;
      sdsl -- site01
    };
  \end{scope}
  \begin{scope}[on background layer]
    \node[fill=black!20,fit=(bb)] {};
  \end{scope}
\end{tikzpicture}
\end{document}

Category: tikz pgf Time: 2015-02-12 Views: 7
Tags: tikz pgf

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.188 (s). 12 q(s)