gencharts/__init__.py
def html(self, slug, name, chart_obj, filepath=None,
             html_before="", html_after=""):
        """
        Generate html from an Altair chart object and optionally write it to a file
        """
        try:
            html = ""
            if name:
                html = "<h3>" + name + "</h3>"
            json_data = chart_obj.to_json()
            json_data = self._patch_json(json_data)
            html = html_before + html +\
                self._json_to_html(slug, json_data) + html_after
        except Exception as e:
            tr.new(e)
            tr.check()
        # generate file
        if filepath is not None:
            self._write_file(slug, filepath, html)
            return None
        else:
            return html
def html(self, slug, name, chart_obj, filepath=None,
             html_before="", html_after=""):
        """
        Generate html from an Altair chart object and optionally write it to a file
        """
        try:
            html = ""
            if name:
                html = "<h3>" + name + "</h3>"
            json_data = chart_obj.to_json()
            json_data = self._patch_json(json_data)
            html = html_before + html +\
                self._json_to_html(slug, json_data) + html_after
        except Exception as e:
            tr.new(e)
            tr.check()
        # generate file
        if filepath is not None:
            self._write_file(slug, filepath, html)
            return None
        else:
            return html
Generate html from an Altair chart object and optionally write it to a file