Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
item_group.set('transform', svg.translate(indent, y))
indent += item_width
legend_group.append(item_group)
legend_height = rows * (theme.legend_font_char_height + theme.legend_gap)
header_margin += legend_height
header_group.append(legend_group)
margin_group.append(header_group)
# Body
body_group = ET.Element('g')
body_group.set('transform', svg.translate(0, header_margin))
body_width = margin_width
body_height = margin_height - header_margin
margin_group.append(body_group)
# Axes
x_scale, x_axis = self._validate_dimension(X)
y_scale, y_axis = self._validate_dimension(Y)
bottom_margin = x_axis.estimate_label_margin(x_scale, 'bottom')
left_margin = y_axis.estimate_label_margin(y_scale, 'left')
canvas_width = body_width - left_margin
canvas_height = body_height - bottom_margin
body_height = margin_height - header_margin
margin_group.append(body_group)
# Axes
x_scale, x_axis = self._validate_dimension(X)
y_scale, y_axis = self._validate_dimension(Y)
bottom_margin = x_axis.estimate_label_margin(x_scale, 'bottom')
left_margin = y_axis.estimate_label_margin(y_scale, 'left')
canvas_width = body_width - left_margin
canvas_height = body_height - bottom_margin
axes_group = ET.Element('g')
axes_group.set('transform', svg.translate(left_margin, 0))
axes_group.append(x_axis.to_svg(canvas_width, canvas_height, x_scale, 'bottom'))
axes_group.append(y_axis.to_svg(canvas_width, canvas_height, y_scale, 'left'))
header_group.set('transform', svg.translate(left_margin, 0))
body_group.append(axes_group)
# Series
series_group = ET.Element('g')
palette = self._palette()
for series, shape in self._layers:
series_group.append(shape.to_svg(canvas_width, canvas_height, x_scale, y_scale, series, palette))
if len(self._layers) > 1 or isinstance(self._layers[0][0], CategorySeries):
legend_group = ET.Element('g')
legend_group.set('transform', svg.translate(0, header_margin))
indent = 0
rows = 1
palette = self._palette()
for series, shape in self._layers:
for item_group, item_width in shape.legend_to_svg(series, palette):
if indent + item_width > width:
indent = 0
rows += 1
y = (rows - 1) * (theme.legend_font_char_height + theme.legend_gap)
item_group.set('transform', svg.translate(indent, y))
indent += item_width
legend_group.append(item_group)
legend_height = rows * (theme.legend_font_char_height + theme.legend_gap)
header_margin += legend_height
header_group.append(legend_group)
margin_group.append(header_group)
# Body
body_group = ET.Element('g')
body_group.set('transform', svg.translate(0, header_margin))
label = ET.Element('text',
x=six.text_type(0),
y=six.text_type(0),
fill=theme.title_color
)
label.set('font-family', theme.title_font_family)
label.set('font-size', six.text_type(theme.title_font_size))
label.text = six.text_type(self._title)
header_group.append(label)
header_margin += theme.title_font_char_height + theme.title_gap
# Legend
if len(self._layers) > 1 or isinstance(self._layers[0][0], CategorySeries):
legend_group = ET.Element('g')
legend_group.set('transform', svg.translate(0, header_margin))
indent = 0
rows = 1
palette = self._palette()
for series, shape in self._layers:
for item_group, item_width in shape.legend_to_svg(series, palette):
if indent + item_width > width:
indent = 0
rows += 1
y = (rows - 1) * (theme.legend_font_char_height + theme.legend_gap)
item_group.set('transform', svg.translate(indent, y))
indent += item_width