mirror of https://github.com/Kozea/pygal.git
Florian Mounier
10 years ago
22 changed files with 318 additions and 151 deletions
@ -1,10 +1,10 @@
|
||||
{% extends '_layout.jinja2' %} |
||||
|
||||
{% block section %} |
||||
{% for svg in svgs %} |
||||
{% for svg in svgs | sort(attribute='type') %} |
||||
<figure> |
||||
<embed src="{{ url_for('svg', type=svg.type, series=svg.series, config=svg.config) }}" type="image/svg+xml" width="{{ width }}" height="{{ height }}" /> |
||||
<figcaption></figcaption> |
||||
<figcaption>{{ svg.type }}</figcaption> |
||||
</figure> |
||||
{% endfor %} |
||||
{% endblock section %} |
||||
|
@ -0,0 +1,7 @@
|
||||
pygal.graph.dual module |
||||
======================= |
||||
|
||||
.. automodule:: pygal.graph.dual |
||||
:members: |
||||
:undoc-members: |
||||
:show-inheritance: |
@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*- |
||||
# This file is part of pygal |
||||
# |
||||
# A python svg graph plotting library |
||||
# Copyright © 2012-2015 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/>. |
||||
|
||||
"""Dual chart base. Dual means a chart with 2 scaled axis like xy""" |
||||
|
||||
from pygal.util import cut, compute_scale |
||||
from pygal._compat import is_str |
||||
from pygal.graph.graph import Graph |
||||
|
||||
|
||||
class Dual(Graph): |
||||
_dual = True |
||||
|
||||
def _compute_x_labels(self): |
||||
x_pos = compute_scale( |
||||
self._box.xmin, self._box.xmax, self.logarithmic, |
||||
self.order_min, self.min_scale, self.max_scale |
||||
) |
||||
if self.x_labels: |
||||
self._x_labels = [] |
||||
for i, x_label in enumerate(self.x_labels): |
||||
if isinstance(x_label, dict): |
||||
pos = float(x_label.get('value')) |
||||
title = x_label.get('label', self._format(pos)) |
||||
elif is_str(x_label): |
||||
pos = x_pos[i] |
||||
title = x_label |
||||
else: |
||||
pos = float(x_label) |
||||
title = self._x_format(x_label) |
||||
|
||||
self._x_labels.append((title, pos)) |
||||
self._box.xmin = min(self._box.xmin, min(cut(self._x_labels, 1))) |
||||
self._box.xmax = max(self._box.xmax, max(cut(self._x_labels, 1))) |
||||
|
||||
else: |
||||
self._x_labels = list(zip(map(self._x_format, x_pos), x_pos)) |
Loading…
Reference in new issue