class_docstr: Graph super class containing generic common functions
class_docstr_tok: ["Graph","super","class","containing","generic","common","functions"]
docstr: Compute graph margins from set texts
code: def _compute_margin(self):
      """Compute graph margins from set texts"""
      self._legend_at_left_width = 0
      for series_group in (self.series, self.secondary_series):
          if self.show_legend and series_group:
              h, w = get_texts_box(
                  map(
                      lambda x: truncate(x, self.truncate_legend or 15),
                      [
                          serie.title["title"]
                          if isinstance(serie.title, dict)
                          else serie.title or ""
                          for serie in series_group
                      ],
                  ),
                  self.style.legend_font_size,
              )
              if self.legend_at_bottom:
                  h_max = max(h, self.legend_box_size)
                  cols = (
                      self._order // self.legend_at_bottom_columns
                      if self.legend_at_bottom_columns
                      else ceil(sqrt(self._order)) or 1
                  )
                  self.margin_box.bottom += (
                      self.spacing
                      + h_max * round(cols - 1) * 1.5
                      + h_max
                  )
              else:
                  if series_group is self.series:
                      legend_width = (
                          self.spacing + w + self.legend_box_size
                      )
                      self.margin_box.left += legend_width
                      self._legend_at_left_width += legend_width
                  else:
                      self.margin_box.right += (
                          self.spacing + w + self.legend_box_size
                      )
  
      self._x_labels_height = 0
      if (self._x_labels or self._x_2nd_labels) and self.show_x_labels:
          for xlabels in (self._x_labels, self._x_2nd_labels):
              if xlabels:
                  h, w = get_texts_box(
                      map(
                          lambda x: truncate(
                              x, self.truncate_label or 25
                          ),
                          cut(xlabels),
                      ),
                      self.style.label_font_size,
                  )
                  self._x_labels_height = self.spacing + max(
                      w * abs(sin(rad(self.x_label_rotation))), h
                  )
                  if xlabels is self._x_labels:
                      self.margin_box.bottom += self._x_labels_height
                  else:
                      self.margin_box.top += self._x_labels_height
                  if self.x_label_rotation:
                      if self.x_label_rotation % 180 < 90:
                          self.margin_box.right = max(
                              w * abs(cos(rad(self.x_label_rotation))),
                              self.margin_box.right,
                          )
                      else:
                          self.margin_box.left = max(
                              w * abs(cos(rad(self.x_label_rotation))),
                              self.margin_box.left,
                          )
  
      if self.show_y_labels:
          for ylabels in (self._y_labels, self._y_2nd_labels):
              if ylabels:
                  h, w = get_texts_box(
                      cut(ylabels), self.style.label_font_size
                  )
                  if ylabels is self._y_labels:
                      self.margin_box.left += self.spacing + max(
                          w * abs(cos(rad(self.y_label_rotation))), h
                      )
                  else:
                      self.margin_box.right += self.spacing + max(
                          w * abs(cos(rad(self.y_label_rotation))), h
                      )
  
      self._title = split_title(
          self.title, self.width, self.style.title_font_size
      )
  
      if self.title:
          h, _ = get_text_box(
              self._title[0], self.style.title_font_size
          )
          self.margin_box.top += len(self._title) * (self.spacing + h)
  
      self._x_title = split_title(
          self.x_title,
          self.width - self.margin_box.x,
          self.style.title_font_size,
      )
  
      self._x_title_height = 0
      if self._x_title:
          h, _ = get_text_box(
              self._x_title[0], self.style.title_font_size
          )
          height = len(self._x_title) * (self.spacing + h)
          self.margin_box.bottom += height
          self._x_title_height = height + self.spacing
  
      self._y_title = split_title(
          self.y_title,
          self.height - self.margin_box.y,
          self.style.title_font_size,
      )
  
      self._y_title_height = 0
      if self._y_title:
          h, _ = get_text_box(
              self._y_title[0], self.style.title_font_size
          )
          height = len(self._y_title) * (self.spacing + h)
          self.margin_box.left += height
          self._y_title_height = height + self.spacing
  
      # Inner margin
      if self.print_values_position == "top":
          gh = self.height - self.margin_box.y
          alpha = (
              1.1 * (self.style.value_font_size / gh) * self._box.height
          )
          if self._max and self._max > 0:
              self._box.ymax += alpha
          if self._min and self._min < 0:
              self._box.ymin -= alpha
  
imports: from math import ceil, cos, sin, sqrt
  from pygal import stats
  from pygal._compat import is_list_like
  from pygal.graph.public import PublicApi
  from pygal.interpolate import INTERPOLATIONS
  from pygal.util import cached_property, compute_scale, cut, decorate, filter_kwargs, get_text_box, get_texts_box, majorize, rad, reverse_text_len, split_title, truncate
  from pygal.view import LogView, ReverseView, View, XYLogView
label_desc: Use image node_id 27 for calling the Graph obj's underlying member method code with example usage: obj._compute_margin() without return types