Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
This can then be placed inside an :code:`<svg>` tag to make a complete
SVG graphic.
See :meth:`.Chart.to_svg` for arguments.
"""
width = width or theme.default_width
height = height or theme.default_height
if not self._layers:
raise ValueError('You must add at least one series to the chart before rendering.')
if isinstance(theme.margin, float):
default_margin = width * theme.margin
margin = Box(
top=default_margin,
right=default_margin,
bottom=default_margin,
left=default_margin
)
elif isinstance(margin, int):
margin = Box(margin, margin, margin, margin)
elif not isinstance(margin, Box):
margin = Box(*margin)
# Root / background
root_group = ET.Element('g')
root_group.append(ET.Element('rect',
x=six.text_type(0),
y=six.text_type(0),</svg>
height = height or theme.default_height
if not self._layers:
raise ValueError('You must add at least one series to the chart before rendering.')
if isinstance(theme.margin, float):
default_margin = width * theme.margin
margin = Box(
top=default_margin,
right=default_margin,
bottom=default_margin,
left=default_margin
)
elif isinstance(margin, int):
margin = Box(margin, margin, margin, margin)
elif not isinstance(margin, Box):
margin = Box(*margin)
# Root / background
root_group = ET.Element('g')
root_group.append(ET.Element('rect',
x=six.text_type(0),
y=six.text_type(0),
width=six.text_type(width),
height=six.text_type(height),
fill=theme.background_color
))
# Margins
margin_group = ET.Element('g')
if not self._layers:
raise ValueError('You must add at least one series to the chart before rendering.')
if isinstance(theme.margin, float):
default_margin = width * theme.margin
margin = Box(
top=default_margin,
right=default_margin,
bottom=default_margin,
left=default_margin
)
elif isinstance(margin, int):
margin = Box(margin, margin, margin, margin)
elif not isinstance(margin, Box):
margin = Box(*margin)
# Root / background
root_group = ET.Element('g')
root_group.append(ET.Element('rect',
x=six.text_type(0),
y=six.text_type(0),
width=six.text_type(width),
height=six.text_type(height),
fill=theme.background_color
))
# Margins
margin_group = ET.Element('g')
margin_group.set('transform', svg.translate(margin.left, margin.top))
if not self._layers:
raise ValueError('You must add at least one series to the chart before rendering.')
if isinstance(theme.margin, float):
default_margin = width * theme.margin
margin = Box(
top=default_margin,
right=default_margin,
bottom=default_margin,
left=default_margin
)
elif isinstance(margin, int):
margin = Box(margin, margin, margin, margin)
elif not isinstance(margin, Box):
margin = Box(*margin)
# Root / background
root_group = ET.Element('g')
root_group.append(ET.Element('rect',
x=six.text_type(0),
y=six.text_type(0),
width=six.text_type(width),
height=six.text_type(height),
fill=theme.background_color
))
# Margins
margin_group = ET.Element('g')
margin_group.set('transform', svg.translate(margin.left, margin.top))