コード例 #1
0
ファイル: base.py プロジェクト: xclu/pyecharts
    def render(self, path="render.html"):
        """ Render the options string, generate the html file

        :param path:
            path of render html file
        """
        temple = "template.html"
        series = self._option.get("series")
        for s in series:
            if s.get('type') == "wordCloud":
                temple = "wd.html"
                break
            if s.get('type') == "liquidFill":
                temple = "lq.html"
                break
        my_option = json.dumps(self._option, indent=4, ensure_ascii=False)
        tmp = self._jinja2_env.get_template(temple)
        html = tmp.render(myOption=my_option, myWidth=self._width, myHeight=self._height)
        html = template.freeze_js(html)
        if PY2:
            html = html.encode('utf-8')
            with open(path, "w+") as fout:
                fout.write(html)
        else:
            with open(path, "w+", encoding="utf-8") as fout:
                fout.write(html)
コード例 #2
0
ファイル: base.py プロジェクト: shuxiang/pyecharts
    def render(self, path="render.html"):
        """ Render the options string, generate the html file

        :param path:
            path of render html file
        """
        temple = "template.html"
        series = self._option.get("series")
        for s in series:
            if s.get('type') == "wordCloud":
                temple = "wd.html"
                break
            if s.get('type') == "liquidFill":
                temple = "lq.html"
                break
        my_option = json_dumps(self._option, indent=4)
        tmp = self._jinja2_env.get_template(temple)
        html = tmp.render(myOption=my_option,
                          chart_id=uuid.uuid4().hex,
                          myWidth=self._width, myHeight=self._height)
        html = template.freeze_js(html)
        if PY2:
            html = html.encode('utf-8')
            with open(path, "w+") as fout:
                fout.write(html)
        else:
            with open(path, "w+", encoding="utf-8") as fout:
                fout.write(html)
コード例 #3
0
ファイル: page.py プロジェクト: zhouliyfly/pyecharts
 def render(self, path="render.html"):
     template_name = "multicharts.html"
     chart_content = self.render_embed()
     tmp = template.JINJA2_ENV.get_template(template_name)
     html = tmp.render(multi_chart_content=chart_content)
     html = template.freeze_js(html)
     template.write_utf8_html_file(path, html)
コード例 #4
0
def test_freeze_js():
    html_content = """
        </style>
        <!-- build -->
        <script src="js/echarts.min.js"></script>
        <script src="js/echarts-wordcloud.min.js"></script>
        <!-- endbuild -->
    </head><body>"""

    html_content = freeze_js(html_content)
    assert 'exports.echarts' in html_content
    assert 'echarts-wordcloud' in html_content
コード例 #5
0
    def render(self, path="render.html"):
        """
        Produce rendered charts in a html file

        :param path:
        :return:
        """
        template_name = "multicharts.html"
        chart_content = self.render_embed()
        tmp = template.JINJA2_ENV.get_template(template_name)
        html = tmp.render(multi_chart_content=chart_content)
        html = template.freeze_js(html)
        template.write_utf8_html_file(path, html)
コード例 #6
0
ファイル: base.py プロジェクト: zhanghao4171/pyecharts
    def render(self, path="render.html"):
        """ Render the options dict, generate the html file

        :param path:
            path of render html file
        """
        _tmp = "local.html"
        my_option = json_dumps(self._option, indent=4)
        tmp = template.JINJA2_ENV.get_template(_tmp)
        html = tmp.render(myOption=my_option,
                          chart_id=uuid.uuid4().hex,
                          myWidth=self._width, myHeight=self._height)
        html = template.freeze_js(html)
        template.write_utf8_html_file(path, html)
コード例 #7
0
    def render(self, path="render.html"):
        """
        Produce rendered charts in a html file

        :param path:
        :return:
        """
        template_name = "multicharts.html"
        chart_content = self.render_embed()
        dependencies = self._merge_dependencies()
        script_list = produce_html_script_list(dependencies)
        tmp = template.JINJA2_ENV.get_template(template_name)
        html = tmp.render(multi_chart_content=chart_content,
                          script_list=script_list)
        html = template.freeze_js(html)
        template.write_utf8_html_file(path, html)
コード例 #8
0
ファイル: base.py プロジェクト: Xusen93/pyecharts
    def render(self, path="render.html"):
        """ Render the options dict, generate the html file

        :param path:
            path of render html file
        """
        _tmp = "local.html"
        my_option = json_dumps(self._option, indent=4)
        tmp = template.JINJA2_ENV.get_template(_tmp)
        script_list = template.produce_html_script_list(self._js_dependencies)
        html = tmp.render(myOption=my_option,
                          chart_id=self._chart_id,
                          script_list=script_list,
                          myWidth=self._width,
                          myHeight=self._height)
        html = template.freeze_js(html)
        template.write_utf8_html_file(path, html)
コード例 #9
0
ファイル: base.py プロジェクト: shuxiaxia/pyecharts
    def render(self, path="render.html"):
        """ Render the options dict, generate the html file

        :param path:
            path of render html file
        """
        _tmp = "template.html"
        series = self._option.get("series")
        for s in series:
            if s.get('type') == "wordCloud":
                _tmp = "wd.html"
                break
            if s.get('type') == "liquidFill":
                _tmp = "lq.html"
                break
        my_option = json_dumps(self._option, indent=4)
        tmp = template.JINJA2_ENV.get_template(_tmp)
        html = tmp.render(myOption=my_option,
                          chart_id=uuid.uuid4().hex,
                          myWidth=self._width,
                          myHeight=self._height)
        html = template.freeze_js(html)
        template.write_utf8_html_file(path, html)