Browse Source

Fix margin in log scale

pull/8/head
Florian Mounier 13 years ago
parent
commit
15985f1cf2
  1. 15
      demo/simple_test.py
  2. 2
      pygal/__init__.py
  3. 1
      pygal/test/utils.py
  4. 11
      pygal/view.py
  5. 2
      setup.py

15
demo/simple_test.py

@ -30,7 +30,7 @@ bar.add('test1', rng)
bar.add('test2', map(abs, rng))
bar.add('inc', [None, 1, None, 2])
bar.x_labels = map(str, rng)
bar.title = "Bar test"
bar.fill = True
bar.render_to_file('out-bar.svg')
@ -73,24 +73,25 @@ hstackedbar.add('--->', rng3)
hstackedbar.render_to_file('out-horizontalstackedbar.svg')
line = Line(Config(style=NeonStyle,
zero=1,
human_readable=True, logarithmic=not True))
zero=1, fill=True,
human_readable=True, logarithmic=True))
rng = range(-30, 31, 1)
# line.add('test1', [1000 ** cos(x / 10.) for x in rng])
# line.add('test2', [1000 ** sin(x / 10.) for x in rng])
# line.add('test3', [1000 ** (cos(x / 10.) - sin(x / 10.)) for x in rng])
rng = range(1, 2000, 25)
# rng = range(1, 2000, 25)
# line.add('x', rng)
# line.add('x', rng)
# line.add('10^10^x', map(lambda x: ((x / 333.) ** (x / 333.)), rng))
# line.add('None', [None, None, None, 12, 31, 11, None, None, 12, 14])
line.add('2', [None, None, 2, 4, 8, None, 14, 10, None])
line.add('1', [1, 5, 3, 4, 6, 12, 13, 7, 2])
# line.add('2', [None, None, 2, 4, 8, None, 14, 10, None])
# line.add('1', [1, 5, 3, 4, 6, 12, 13, 7, 2])
# line.add('1', [.000000091, .000000094, .000092])
line.add('_', [12, 200001, 12])
line.x_labels = map(str, rng)
line.title = "Line test"
line.interpolate = "cubic"
# line.interpolate = "cubic"
line.interpolation_precision = 200
line.render_to_file('out-line.svg')

2
pygal/__init__.py

@ -16,7 +16,7 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.9.16'
__version__ = '0.9.17'
from collections import namedtuple
from pygal.graph.bar import Bar

1
pygal/test/utils.py

@ -16,7 +16,6 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with pygal. If not, see <http://www.gnu.org/licenses/>.
from pygal import Line
from pyquery import PyQuery as pq

11
pygal/view.py

@ -54,7 +54,7 @@ class Box(object):
self.xmin, self.ymin = self.ymin, self.xmin
self.xmax, self.ymax = self.ymax, self.xmax
def fix(self):
def fix(self, with_margin=True):
if not self.width:
self.xmax = self.xmin + 1
if not self.height:
@ -63,9 +63,10 @@ class Box(object):
xmargin = self._margin * self.width
self.xmin -= xmargin
self.xmax += xmargin
ymargin = self._margin * self.height
self.ymin -= ymargin
self.ymax += ymargin
if with_margin:
ymargin = self._margin * self.height
self.ymin -= ymargin
self.ymax += ymargin
class View(object):
@ -110,7 +111,7 @@ class LogView(View):
self.ymax = self.box.ymax
self.log10_ymax = log10(self.box.ymax)
self.log10_ymin = log10(self.box.ymin)
self.box.fix()
self.box.fix(False)
def y(self, y):
if y == None:

2
setup.py

@ -21,7 +21,7 @@ from setuptools import setup, find_packages
setup(
name="pygal",
version='0.9.16',
version='0.9.17',
description="A python svg graph plotting library",
author="Kozea",
author_email="florian.mounier@kozea.fr",

Loading…
Cancel
Save