Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .git_hooks
Submodule .git_hooks deleted from 209008
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

6 changes: 4 additions & 2 deletions pygal/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
from copy import deepcopy

from pygal import formatters
from pygal.css import CSS_GRAPH
from pygal.css import CSS_STYLE
from pygal.interpolate import INTERPOLATIONS
from pygal.style import DefaultStyle, Style

Expand All @@ -37,7 +39,7 @@ class Key(object):
a category, a documentation, an optional longer documentatation
and an optional subtype for list style option.

Most of these informations are used in cabaret to auto generate
Most of these information are used in cabaret to auto generate
forms representing these options.
"""

Expand Down Expand Up @@ -240,7 +242,7 @@ class Config(CommonConfig):
DefaultStyle, Style, "Style", "Style holding values injected in css")

css = Key(
('file://style.css', 'file://graph.css'), list, "Style",
('template://{}'.format(CSS_STYLE), 'template://{}'.format(CSS_GRAPH)), list, "Style",
"List of css file",
"It can be any uri from file:///tmp/style.css to //domain/style.css",
str)
Expand Down
26 changes: 26 additions & 0 deletions pygal/css/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library
# Copyright © 2012-2018 Kozea
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.

"""CSS package containing all needed styles"""

from pygal.css.base import CSS as CSS_BASE
from pygal.css.graph import CSS as CSS_GRAPH
from pygal.css.style import CSS as CSS_STYLE

__all__ = ('CSS_BASE', 'CSS_GRAPH', 'CSS_STYLE',)
24 changes: 23 additions & 1 deletion pygal/css/base.css → pygal/css/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
/*
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library
# Copyright © 2012-2018 Kozea
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.

"""Base styles"""

CSS = """/*
* This file is part of pygal
*
* A python svg graph plotting library
Expand Down Expand Up @@ -67,3 +88,4 @@
font-family: {{ style.no_data_font_family }};
font-size: {{ style.no_data_font_size }}px;
}
"""
24 changes: 23 additions & 1 deletion pygal/css/graph.css → pygal/css/graph.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
/*
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library
# Copyright © 2012-2018 Kozea
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.

"""Graph styles"""

CSS = """/*
* This file is part of pygal
*
* A python svg graph plotting library
Expand Down Expand Up @@ -150,3 +171,4 @@
stroke: {{ style.background }};
stroke-width: 2px;
}
"""
24 changes: 23 additions & 1 deletion pygal/css/style.css → pygal/css/style.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
/*
# -*- coding: utf-8 -*-
# This file is part of pygal
#
# A python svg graph plotting library
# Copyright © 2012-2018 Kozea
#
# This library is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.

"""Styles"""

CSS = """/*
* This file is part of pygal
*
* A python svg graph plotting library
Expand Down Expand Up @@ -172,3 +193,4 @@
{{ colors }}

{{ strokes }}
"""
16 changes: 15 additions & 1 deletion pygal/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
coord_abs_project, coord_diff, coord_dual, coord_format, coord_project,
minify_css, template)

from pygal.css import CSS_BASE

nearly_2pi = 2 * pi - .00001


Expand Down Expand Up @@ -92,7 +94,7 @@ def add_styles(self):
colors = self.graph.style.get_colors(self.id, self.graph._order)
strokes = self.get_strokes()
all_css = []
auto_css = ['file://base.css']
auto_css = ['template://{}'.format(CSS_BASE)]

if self.graph.style._google_fonts:
auto_css.append(
Expand All @@ -104,7 +106,19 @@ def add_styles(self):
css_text = None
if css.startswith('inline:'):
css_text = css[len('inline:'):]

elif css.startswith('template://'):
css = css[len('template://'):]
css_text = template(
css,
style=self.graph.style,
colors=colors,
strokes=strokes,
id=self.id
)

elif css.startswith('file://'):

css = css[len('file://'):]

if not os.path.exists(css):
Expand Down