pygal.util module

Various utility functions

pygal.util.alter(node, metadata)[source]

Override nodes attributes from metadata node mapping

class pygal.util.cached_property(getter, doc=None)[source]

Bases: object

Memoize a property

pygal.util.compose(f, g)[source]

Chain functions

pygal.util.compute_logarithmic_scale(min_, max_, min_scale, max_scale)[source]

Compute an optimal scale for logarithmic

pygal.util.compute_scale(min_, max_, logarithmic, order_min, min_scale, max_scale)[source]

Compute an optimal scale between min and max

pygal.util.coord_abs_project(center, rho, theta)[source]
pygal.util.coord_diff(x, y)[source]
pygal.util.coord_dual(r)[source]
pygal.util.coord_format(x)[source]
pygal.util.coord_project(rho, alpha)[source]
pygal.util.cut(list_, index=0)[source]

Cut a list by index or arg

pygal.util.decorate(svg, node, metadata)[source]

Add metedata next to a node

pygal.util.deg(radiants)[source]

Convert radiants in degrees

pygal.util.filter_kwargs(fun, kwargs)[source]
pygal.util.float_format(number)[source]

Format a float to a precision of 3, without zeroes or dots

pygal.util.get_text_box(text, fs)[source]

Approximation of text bounds

pygal.util.get_texts_box(texts, fs)[source]

Approximation of multiple texts bounds

pygal.util.ident(x)
pygal.util.majorize(values)[source]

Filter sequence to return only major considered numbers

pygal.util.merge(dict1, dict2)[source]
pygal.util.mergextend(list1, list2)[source]
pygal.util.minify_css(css)[source]

Little css minifier

pygal.util.rad(degrees)[source]

Convert degrees in radiants

pygal.util.reverse_text_len(width, fs)[source]

Approximation of text length

pygal.util.round_to_float(number, precision)[source]

Round a float to a precision

pygal.util.round_to_int(number, precision)[source]

Round a number to a precision

pygal.util.round_to_scale(number, precision)[source]

Round a number or a float to a precision

pygal.util.safe_enumerate(iterable)[source]

Enumerate which does not yield None values

pygal.util.split_title(title, width, title_fs)[source]

Split a string for a specified width and font size

pygal.util.swap(tuple_)
pygal.util.template(string, **kwargs)[source]

Format a string using double braces

pygal.util.text_len(length, fs)[source]

Approximation of text width

pygal.util.truncate(string, index)[source]

Truncate a string at index and add ...