Improve graph quality with custom CSS

This commit is contained in:
nemunaire 2022-08-14 13:31:54 +02:00
commit c03e90d38a
2 changed files with 43 additions and 5 deletions

View file

@ -1,4 +1,5 @@
import os
from tempfile import NamedTemporaryFile
from PIL import Image, ImageDraw
@ -18,6 +19,35 @@ class Config:
self.fnt_RI_path = "/usr/share/fonts/TTF/LinBiolinum_RIah.ttf"
self.fnt_RB_path = "/usr/share/fonts/TTF/LinBiolinum_RBah.ttf"
self.css_overlay = NamedTemporaryFile()
with open(self.css_overlay.name, 'w') as f:
f.write('''
{{ id }} .bound {
font-size: 0.9em;
}
{{ id }} .gauge path {
fill-opacity: 1 !important;
}
{{ id }} .series .line {
stroke-width: 2 !important;
}
{{ id }} .x .guides .line {
stroke-width: 0 !important;
}
{{ id }} .y .guides .line {
stroke: #555;
stroke-width: 0.7;
}
{{ id }} .y .guides .line.axis {
stroke: #000;
stroke-width: 1;
}
''')
import pygal
self.pygal_config = pygal.Config()
self.pygal_config.css.append('file://' + self.css_overlay.name)
from pygal.style import Style
self.pygal_custom_style = Style(
background='white',