class_docstr: Create object used for visualizing graph using Pyvis library.
class_docstr_tok: ["Create","object","used","for","visualizing","graph","using","Pyvis","library","."]
docstr: Embed legend to html file generated by pyvis.
docstr_tok: ["Embed","legend","to","html","file","generated","by","pyvis","."]
code: def _add_legend(self, path):
      """Embed legend to html file generated by pyvis."""
      f = open(path, "r")
      content = self.BeautifulSoup(f, "html.parser")
  
      legend = """
              <div style="display: inline-block; font-size: 1vw; font-family: verdana;
                  vertical-align: top; padding: 1vw;">
          """
      # iterate through graph styles to get legend
      for component in self.graph_styles.keys():
          legend += self._get_legend_line(component_name=component)
  
      legend += "</div>"
  
      legend_div = self.BeautifulSoup(legend, "html.parser")
  
      content.div.insert_after(legend_div)
  
      html = content.prettify()
  
      with open(path, "w", encoding="utf8") as file:
          file.write(html)
  
imports: from __future__ import absolute_import
  from datetime import datetime
  from enum import Enum
  from typing import Any, Optional, Union, List, Dict
  from json import dumps
  from re import sub, search
  from sagemaker.utils import get_module
  from sagemaker.lineage._utils import get_resource_name_from_arn
label_desc: Use image node_id 5 for calling the PyvisVisualizer obj's underlying member method code with example usage: obj._add_legend(path) without return types