toyplot.style module¶
Functionality for working with CSS style information.
-
class
toyplot.style.
allowed
[source]¶ Bases:
object
Defines groups of allowable CSS property names.
-
fill
= {'fill', 'stroke', 'stroke-opacity', 'opacity', 'stroke-dasharray', 'fill-opacity', 'stroke-width'}¶ Allowable CSS property names for filling areas.
-
line
= {'stroke', 'stroke-linecap', 'stroke-opacity', 'opacity', 'stroke-dasharray', 'stroke-width'}¶ Allowable CSS property names for stroking lines.
-
marker
= {'fill', 'stroke', 'stroke-opacity', 'opacity', 'fill-opacity', 'stroke-width'}¶ Allowable CSS property names for Markers.
-
text
= {'fill', 'stroke', '-toyplot-text-layout-line-visibility', 'stroke-opacity', '-toyplot-anchor-shift', '-toyplot-text-layout-box-visibility', 'alignment-baseline', 'baseline-shift', '-toyplot-text-layout-visibility', 'opacity', 'text-shadow', 'font-size', 'line-height', '-toyplot-vertical-align', 'font-family', 'fill-opacity', 'font-weight', 'text-anchor', 'stroke-width'}¶ Allowable CSS property names for text.
-
-
toyplot.style.
combine
(*styles)[source]¶ Combine multiple style specifications into one.
Parameters: styles (sequence of dict
instances) – A collection of dicts containing CSS-compatible name-value pairs.Returns: styles Return type: dict
containing CSS-compatible name-value pairs.
-
toyplot.style.
require
(css, allowed)[source]¶ Validate that an object is usable as CSS style information.
Parameters: - css (dict or None) – The style dictionary to be validated. An exception will be raised if it is not a valid style dictionary or None.
- allowed (sequence of strings) – The set of allowed style properties. An exception will be raised if css contains any keys that aren’t in this sequence.
Returns: style – The validated style dictionary.
Return type: