/* Plots, graphs */
div.m-plot, div.m-graph { text-align: center; }
+div.m-graph { font-size: var(--font-size); }
div.m-plot svg, div.m-graph svg { max-width: 100%; }
div.m-plot .m-background { fill: var(--plot-background-color); }
/* Font sizes are hardcoded in m.plots, change there first! */
fill: #a5c9ea;
}
div.m-plot, div.m-graph { text-align: center; }
+div.m-graph { font-size: 16px; }
div.m-plot svg, div.m-graph svg { max-width: 100%; }
div.m-plot .m-background { fill: #34424d; }
div.m-plot svg .m-label { font-size: 11px; }
fill: #a5c9ea;
}
div.m-plot, div.m-graph { text-align: center; }
+div.m-graph { font-size: 16px; }
div.m-plot svg, div.m-graph svg { max-width: 100%; }
div.m-plot .m-background { fill: #34424d; }
div.m-plot svg .m-label { font-size: 11px; }
fill: #cb4b16;
}
div.m-plot, div.m-graph { text-align: center; }
+div.m-graph { font-size: 14px; }
div.m-plot svg, div.m-graph svg { max-width: 100%; }
div.m-plot .m-background { fill: #fbf0ec; }
div.m-plot svg .m-label { font-size: 11px; }
fill: #cb4b16;
}
div.m-plot, div.m-graph { text-align: center; }
+div.m-graph { font-size: 14px; }
div.m-plot svg, div.m-graph svg { max-width: 100%; }
div.m-plot .m-background { fill: #fbf0ec; }
div.m-plot svg .m-label { font-size: 11px; }
PLUGINS += ['m.dot']
M_DOT_FONT = 'Source Sans Pro'
-
-Set :py:`M_DOT_FONT` to a font that matches your CSS theme (it's Source Sans
-Pro for `builtin m.css themes <{filename}/css/themes.rst>`_), note that you
-*need to have the font installed* on your system, otherwise it will fall back
-to whatever system font it finds instead (for example DejaVu Sans) and the
-output won't look as expected. In addition you need the
+ M_DOT_FONT_SIZE = 16.0
+
+Set :py:`M_DOT_FONT` and :py:`M_DOT_FONT_SIZE` to a font that matches your CSS
+theme (it's Source Sans Pro at :css:`16px` for
+`builtin m.css themes <{filename}/css/themes.rst>`_), note that you *need to
+have the font installed* on your system, otherwise it will fall back to
+whatever system font it finds instead (for example DejaVu Sans) and the output
+won't look as expected. In addition you need the
`Graphviz <https://graphviz.org/>`_ library installed. Get it via your
distribution package manager, for example on Ubuntu:
_text_dst = ' style="font-size: {size}px;"'
_font = ''
-_font_size = 16.0 # TODO: avoid hardcoding this
+_font_size = 0.0
# The pt are actually px (16pt font is the same size as 16px), so just
# converting to rem here
-_pt2em = 1.0/_font_size
+def _pt2em(pt): return pt/_font_size
class Dot(rst.Directive):
has_content = True
# Remove preamble and fixed size
def patch_repl(match): return _patch_dst.format(
- width=_pt2em*float(match.group('width')),
- height=_pt2em*float(match.group('height')),
+ width=_pt2em(float(match.group('width'))),
+ height=_pt2em(float(match.group('height'))),
viewBox=match.group('viewBox'))
svg = _patch_src.sub(patch_repl, svg)
return Dot.run(self, 'strict graph "{}" {{\n{}}}'.format(self.arguments[0], '\n'.join(self.content)))
def configure(pelicanobj):
- global _font, _text_src
+ global _font, _font_size, _text_src
_font = pelicanobj.settings.get('M_DOT_FONT', 'Source Sans Pro')
+ _font_size = pelicanobj.settings.get('M_DOT_FONT_SIZE', 16.0)
_text_src = re.compile(_text_src_src.format(font=_font))
def register():