diff --git a/docker-compose.yaml b/docker-compose.yaml index 8e35255..107927f 100755 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -34,5 +34,12 @@ services: - GF_LOG_FILTERS=rendering:debug renderer: image: grafana/grafana-image-renderer:latest + environment: + # Recommendation of grafana-image-renderer for optimal performance + # https://grafana.com/docs/grafana/latest/setup-grafana/image-rendering/#configuration + - RENDERING_MODE=clustered + - RENDERING_CLUSTERING_MODE=browser + - RENDERING_CLUSTERING_MAX_CONCURRENCY=5 + - RENDERING_CLUSTERING_TIMEOUT=60 ports: - 8081 diff --git a/go.mod b/go.mod index f5262aa..9e60e1c 100755 --- a/go.mod +++ b/go.mod @@ -7,6 +7,7 @@ toolchain go1.21.3 require ( github.com/google/uuid v1.5.0 github.com/grafana/grafana-plugin-sdk-go v0.199.0 + github.com/magefile/mage v1.15.0 github.com/smartystreets/goconvey v1.8.1 ) @@ -45,7 +46,6 @@ require ( github.com/jtolds/gls v4.20.0+incompatible // indirect github.com/klauspost/compress v1.15.15 // indirect github.com/klauspost/cpuid/v2 v2.2.3 // indirect - github.com/magefile/mage v1.15.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattetti/filebuffer v1.0.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect diff --git a/pkg/plugin/texTemplate.go b/pkg/plugin/texTemplate.go index 86e0af9..1fb15ee 100644 --- a/pkg/plugin/texTemplate.go +++ b/pkg/plugin/texTemplate.go @@ -5,49 +5,63 @@ const ( %use square brackets as golang text templating delimiters \documentclass{article} \usepackage{graphicx} -\usepackage[margin=1in]{geometry} +[[- if .IsLandscapeOrientation]] + \usepackage[landscape,margin=0.1in]{geometry} +[[- else]] + \usepackage[margin=0.1in]{geometry} +[[- end]] \graphicspath{ {images/} } \begin{document} -\title{[[.Title]] [[if .VariableValues]] \\ \large [[.VariableValues]] [[end]] [[if .Description]] \\ \small [[.Description]] [[end]]} -\date{[[.FromFormatted]]\\to\\[[.ToFormatted]]} -\maketitle -\begin{center} -[[range .Panels]][[if .IsSingleStat]]\begin{minipage}{0.3\textwidth} -\includegraphics[width=\textwidth]{image[[.Id]]} -\end{minipage} -[[else]]\par -\vspace{0.5cm} -\includegraphics[width=\textwidth]{image[[.Id]]} -\par -\vspace{0.5cm} -[[end]][[end]] -\end{center} -\end{document} -` +\title{ + [[.Title]] + [[- if .VariableValues]] + \\ \large [[.VariableValues]] + [[- end]] + [[- if .Description]] + \\ \small [[.Description]] + [[- end]] +} - defaultGridTemplate = ` -%use square brackets as golang text templating delimiters -\documentclass{article} -\usepackage{graphicx} -\usepackage[margin=0.5in]{geometry} +\date{ + [[.From]]\\ + to\\ + [[.To]] +} -\graphicspath{ {images/} } -\begin{document} -\title{[[.Title]] [[if .VariableValues]] \\ \large [[.VariableValues]] [[end]] [[if .Description]] \\ \small [[.Description]] [[end]]} -\date{[[.FromFormatted]]\\to\\[[.ToFormatted]]} \maketitle + \begin{center} -[[range .Panels]][[if .IsPartialWidth]]\begin{minipage}{[[.Width]]\textwidth} -\includegraphics[width=\textwidth]{image[[.Id]]} -\end{minipage} -[[else]]\par -\vspace{0.5cm} -\includegraphics[width=\textwidth]{image[[.Id]]} -\par -\vspace{0.5cm} -[[end]][[end]] + +[[- if .IsGridLayout]] + [[- range .Panels]] + [[- if .IsPartialWidth]] + \begin{minipage}{[[.Width]]\textwidth} + \includegraphics[width=\textwidth]{image[[.Id]]} + \end{minipage} + [[- else]]\par + \vspace{0.5cm} + \includegraphics[width=\textwidth]{image[[.Id]]} + \par + \vspace{0.5cm} + [[- end]] + % + [[- end]] +[[else]] + [[- range .Panels]] + [[- if .IsSingleStat]] + \begin{minipage}{0.3\textwidth} + \includegraphics[width=\textwidth]{image[[.Id]]} + \end{minipage} + [[- else]]\par + \vspace{0.5cm} + \includegraphics[width=\textwidth]{image[[.Id]]} + \par + \vspace{0.5cm} + [[- end]] + [[- end]] +[[- end]] \end{center} \end{document}