From 90f78ac65f21ef8a7bc73254b7c937c79faf2b9e Mon Sep 17 00:00:00 2001 From: Like Ma Date: Wed, 18 Sep 2019 15:48:18 +0800 Subject: [PATCH] Add plot_title_font_family and plot_title_font_size. --- docs/documentation/custom_styles.rst | 2 ++ pygal/css/base.css | 5 +++++ pygal/graph/graph.py | 2 +- pygal/style.py | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/documentation/custom_styles.rst b/docs/documentation/custom_styles.rst index 9cdbad93..25305cad 100644 --- a/docs/documentation/custom_styles.rst +++ b/docs/documentation/custom_styles.rst @@ -51,6 +51,7 @@ Properties Description ``value_label_font_family`` The ``print_labels`` font family ``tooltip_font_family`` The tooltip font family ``title_font_family`` The title font family +``plot_title_font_family`` The main title font family ``legend_font_family`` The legend font family ``no_data_font_family`` The no data text font family ``guide_stroke_dasharray`` The dasharray for guide line @@ -61,6 +62,7 @@ Properties Description ``value_label_font_size`` The ``print_labels`` font size ``tooltip_font_size`` The tooltip font size ``title_font_size`` The title font size +``plot_title_font_size`` The main title font size ``legend_font_size`` The legend font size ``no_data_font_size`` The no data font size ``opacity`` The opacity of chart element diff --git a/pygal/css/base.css b/pygal/css/base.css index 01f5d5b2..b4cacaf4 100644 --- a/pygal/css/base.css +++ b/pygal/css/base.css @@ -33,6 +33,11 @@ font-size: {{ style.title_font_size }}px; } +{{ id }}.plot_title { + font-family: {{ style.plot_title_font_family }}; + font-size: {{ style.plot_title_font_size }}px; +} + {{ id }}.legends .legend text { font-family: {{ style.legend_font_family }}; font-size: {{ style.legend_font_size }}px; diff --git a/pygal/graph/graph.py b/pygal/graph/graph.py index c2867dc9..5e860843 100644 --- a/pygal/graph/graph.py +++ b/pygal/graph/graph.py @@ -485,7 +485,7 @@ def _make_title(self): 'text', class_='title plot_title', x=self.width / 2, - y=i * (self.style.title_font_size + self.spacing) + y=i * (self.style.plot_title_font_size + self.spacing) ).text = title_line def _make_x_title(self): diff --git a/pygal/style.py b/pygal/style.py index 9b4b3914..9e4ed3a1 100644 --- a/pygal/style.py +++ b/pygal/style.py @@ -45,6 +45,7 @@ class Style(object): value_label_font_family = None tooltip_font_family = None title_font_family = None + plot_title_font_family = None legend_font_family = None no_data_font_family = None @@ -54,6 +55,7 @@ class Style(object): value_label_font_size = 10 tooltip_font_size = 14 title_font_size = 16 + plot_title_font_size = 18 legend_font_size = 14 no_data_font_size = 64