Beispiel #1
0
def test_freeze_js():
    html_content = """
        </style>
        <!-- build -->
        <script src="js/echarts/echarts.min.js"></script>
        <script src="js/echarts/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
Beispiel #2
0
def test_freeze_js():
    html_content = """
        </style>
        <!-- build -->
        <script src="js/echarts/echarts.min.js"></script>
        <script src="js/echarts/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
Beispiel #3
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 = utils.freeze_js(html)
        utils.write_utf8_html_file(path, html)
Beispiel #4
0
    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 = utils.freeze_js(html)
        utils.write_utf8_html_file(path, html)
Beispiel #5
0
    def render(self, path="render.html"):
        """ 渲染配置项并生成 html 文件

        :param path:
            文件保存路径
        """
        _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(my_option=my_option,
                          chart_id=self._chart_id,
                          script_list=script_list,
                          page_title=self._page_title,
                          my_width=self.width,
                          my_height=self.height)
        html = utils.freeze_js(html)
        utils.write_utf8_html_file(path, html)