Example #1
0
    def render_notebook(self):
        """ Render the options string, displayed in the jupyter notebook

        :return:
        """
        from IPython.display import HTML

        divid = datetime.datetime.now()
        my_option = json.dumps(self._option, indent=4)
        temple = Tp._template_notebook
        series = self._option.get("series")
        for s in series:
            if s.get('type') == "wordCloud":
                temple = Tp._template_wd_notebook
                break
            if s.get('type') == "liquidFill":
                temple = Tp._template_lq_notebook
                break
            if s.get('type') == 'map':
                temple = Tp.get_map(self._option.get('series')[0].get('mapType'))
                break
        tmp = Template(temple)
        try:
            html = tmp.render(myOption=my_option, chartId=divid, myWidth=self._width, myHeight=self._height)
        except:
            html = tmp.render(mtOption=my_option.decode('utf8'), chartId=divid, myWidth=self._width,
                              myHeight=self._height)
        return HTML(html)
Example #2
0
    def render_notebook(self):
        """ Render the options string, displayed in the jupyter notebook

        :return:
        """
        from IPython.display import HTML

        divid = datetime.datetime.now()
        my_option = json.dumps(self._option, indent=4)
        temple = Tp._template_notebook
        series = self._option.get("series")
        for s in series:
            if s.get('type') == "wordCloud":
                temple = Tp._template_wd_notebook
                break
            if s.get('type') == "liquidFill":
                temple = Tp._template_lq_notebook
                break
            if s.get('type') == 'map':
                temple = Tp.get_map(
                    self._option.get('series')[0].get('mapType'))
                break
        tmp = Template(temple)
        try:
            html = tmp.render(myOption=my_option,
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height)
        except:
            html = tmp.render(mtOption=my_option.decode('utf8'),
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height)
        return HTML(html)
Example #3
0
    def _repr_html_(self):
        """ Render the options string, displayed in the jupyter notebook

        :return:
        """
        divid = datetime.datetime.now()
        my_option = json_dumps(self._option, indent=4)
        temple = 'notebook.html'
        series = self._option.get("series")
        map_keywords = {}
        for s in series:
            if s.get('type') == "wordCloud":
                temple = 'wd_notebook.html'
                break
            if s.get('type') == "liquidFill":
                temple = 'lq_notebook.html'
                break
            # Avoid loading too many maps at once, make sure notebook can show map chart normally.
            if s.get('type') == 'map':
                temple = "map_notebook.html"
                map_keywords = template.get_map(
                    self._option.get('series')[0].get('mapType'))
                break
        tmp = self._jinja2_env.get_template(temple)
        try:
            html = tmp.render(
                myOption=my_option, chartId=divid, myWidth=self._width,
                myHeight=self._height, **map_keywords)
        except:
            html = tmp.render(
                mtOption=my_option.decode('utf8'), chartId=divid,
                myWidth=self._width, myHeight=self._height, **map_keywords)
        return html
Example #4
0
    def _repr_html_(self):
        """ Render the options dict, displayed in the jupyter notebook

        :return:
        """
        divid = datetime.datetime.now()
        my_option = json_dumps(self._option, indent=4)
        _tmp = 'notebook.html'
        series = self._option.get("series")
        map_keywords = {}
        for s in series:
            # Avoid loading too many maps at once, make sure notebook can show map chart normally.
            if s.get('type') == 'map':
                _tmp = "notebook_map.html"
                map_keywords = template.get_map(
                    self._option.get('series')[0].get('mapType'))
                break
        tmp = template.JINJA2_ENV.get_template(_tmp)
        try:
            html = tmp.render(myOption=my_option,
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height,
                              **map_keywords)
        except:
            html = tmp.render(mtOption=my_option.decode('utf8'),
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height,
                              **map_keywords)
        return html
Example #5
0
    def render_notebook(self):
        """ Render the options string, displayed in the jupyter notebook

        :return:
        """
        from IPython.display import HTML

        divid = datetime.datetime.now()
        my_option = json.dumps(self._option, indent=4)
        temple = 'notebook.html'
        series = self._option.get("series")
        map_keywords = {}
        for s in series:
            if s.get('type') == "wordCloud":
                temple = 'wd_notebook.html'
                break
            if s.get('type') == "liquidFill":
                temple = 'lq_notebook.html'
                break
            # Avoid loading too many maps at once, make sure notebook can show map chart normally.
            if s.get('type') == 'map':
                temple = "map_notebook.html"
                map_keywords = template.get_map(
                    self._option.get('series')[0].get('mapType'))
                break
        tmp = self._jinja2_env.get_template(temple)
        try:
            html = tmp.render(myOption=my_option,
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height,
                              **map_keywords)
        except:
            html = tmp.render(mtOption=my_option.decode('utf8'),
                              chartId=divid,
                              myWidth=self._width,
                              myHeight=self._height,
                              **map_keywords)
        return HTML(html)