Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created two configs to allow use of logarithmic scale in each axis #460

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
33 changes: 17 additions & 16 deletions demo/moulinrouge/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,22 +289,23 @@ def interpolation():
'config': b64encode(pickle.dumps(config))
})

for params in [{'type': 'catmull_rom'}, {'type': 'finite_difference'},
{'type': 'cardinal',
'c': .25}, {'type': 'cardinal',
'c': .5}, {'type': 'cardinal', 'c': .75},
{'type': 'cardinal',
'c': 1.5}, {'type': 'cardinal',
'c': 2}, {'type': 'cardinal', 'c': 5},
{'type': 'kochanek_bartels', 'b': 1, 'c': 1,
't': 1}, {'type': 'kochanek_bartels', 'b': -1, 'c': 1,
't': 1}, {'type': 'kochanek_bartels', 'b': 1,
'c': -1, 't': 1},
{'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': -1}, {
'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': -1
}, {'type': 'kochanek_bartels', 'b': -1, 'c': -1,
't': 1}, {'type': 'kochanek_bartels', 'b': -1,
'c': -1, 't': -1}]:
for params in [
{'type': 'catmull_rom'}, {'type': 'finite_difference'},
{'type': 'cardinal', 'c': .25},
{'type': 'cardinal', 'c': .5},
{'type': 'cardinal', 'c': .75},
{'type': 'cardinal', 'c': 1.5},
{'type': 'cardinal', 'c': 2},
{'type': 'cardinal', 'c': 5},
{'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': 1},
{'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': 1},
{'type': 'kochanek_bartels', 'b': 1, 'c': -1, 't': 1},
{'type': 'kochanek_bartels', 'b': 1, 'c': 1, 't': -1},
{'type': 'kochanek_bartels', 'b': -1, 'c': 1, 't': -1},
{'type': 'kochanek_bartels', 'b': -1, 'c': -1, 't': 1},
{'type': 'kochanek_bartels', 'b': -1, 'c': -1, 't': -1}
]:

config.title = "Hermite interpolation with params %r" % params
config.interpolate = 'hermite'
config.interpolation_parameters = params
Expand Down
14 changes: 7 additions & 7 deletions demo/moulinrouge/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,13 +1160,13 @@ def test_legend_link_for(chart):
'href': 'http://en.wikipedia.org/wiki/Red'
}
}],
title={
'title': 'Red',
'tooltip': 'Cramoisi',
'xlink': {
'href': 'http://en.wikipedia.org/wiki/Red'
}
})
title={
'title': 'Red',
'tooltip': 'Cramoisi',
'xlink': {
'href': 'http://en.wikipedia.org/wiki/Red'
}
})

chart.add({
'title': 'Yellow',
Expand Down
16 changes: 8 additions & 8 deletions pygal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,20 @@
from pygal.graph.treemap import Treemap
from pygal.graph.xy import XY

CHARTS_BY_NAME = dict([
(k, v) for k, v in locals().items()
if isinstance(v, type) and issubclass(v, Graph) and v != Graph
])

CHARTS_BY_NAME = dict(
[(k, v) for k, v in locals().items()
if isinstance(v, type) and issubclass(v, Graph) and v != Graph])


from pygal.graph.map import BaseMap

for entry in entry_points(group="pygal.maps"):
try:
module = entry.load()
except Exception:
warnings.warn(
'Unable to load %s pygal plugin \n\n%s' %
(entry, traceback.format_exc()), Warning
)
warnings.warn('Unable to load %s pygal plugin \n\n%s' % (
entry, traceback.format_exc()), Warning)
continue
setattr(maps, entry.name, module)
for k, v in module.__dict__.items():
Expand All @@ -81,6 +80,7 @@


class PluginImportFixer(object):

"""
Allow external map plugins to be imported from pygal.maps package.

Expand Down
18 changes: 7 additions & 11 deletions pygal/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,8 @@ def h_to_rgb(h):
if 3 * h < 2:
return m1 + 6 * (2 / 3 - h) * (m2 - m1)
return m1

r, g, b = map(
lambda x: round(x * 255), map(h_to_rgb, (h + 1 / 3, h, h - 1 / 3))
)
r, g, b = map(lambda x: round(x * 255),
map(h_to_rgb, (h + 1 / 3, h, h - 1 / 3)))

return r, g, b

Expand All @@ -109,8 +107,7 @@ def parse_color(color):
assert len(color) == 8
type = type or '#rrggbbaa'
r, g, b, a = [
int(''.join(c), 16) for c in zip(color[::2], color[1::2])
]
int(''.join(c), 16) for c in zip(color[::2], color[1::2])]
a /= 255
elif color.startswith('rgb('):
type = 'rgb'
Expand All @@ -119,8 +116,8 @@ def parse_color(color):
elif color.startswith('rgba('):
type = 'rgba'
color = color[5:-1]
r, g, b, a = [int(c) for c in color.split(',')[:-1]
] + [float(color.split(',')[-1])]
r, g, b, a = [int(c) for c in color.split(',')[:-1]] + [
float(color.split(',')[-1])]
return r, g, b, a, type


Expand All @@ -137,9 +134,8 @@ def unparse_color(r, g, b, a, type):

if type == '#rgba':
if r % 17 == 0 and g % 17 == 0 and b % 17 == 0:
return '#%x%x%x%x' % (
int(r / 17), int(g / 17), int(b / 17), int(a * 15)
)
return '#%x%x%x%x' % (int(r / 17), int(g / 17), int(b / 17),
int(a * 15))
type = '#rrggbbaa'

if type == '#rrggbb':
Expand Down
Loading