コード例 #1
0
 def _get_javascript_to_insert(self):
     return '\n'.join([
         PackedDataUtils.full_content_of_javascript_files(),
         self.scatterplot_structure._visualization_data.to_javascript(),
         self.scatterplot_structure.get_js_to_call_build_scatterplot(),
         PackedDataUtils.javascript_post_build_viz('termSearch', 'plotInterface'),
         self.graph_renderer.get_javascript()
     ])
コード例 #2
0
    def to_html(self):
        '''
        Returns
        -------
        str, the html file representation

        '''
        javascript_to_insert = '\n'.join([
            PackedDataUtils.full_content_of_javascript_files(),
            self.category_scatterplot_structure._visualization_data.to_javascript('getCategoryDataAndInfo'),
            self.category_scatterplot_structure.get_js_to_call_build_scatterplot(self.category_plot_interface),
            self.term_scatterplot_structure._visualization_data.to_javascript('getTermDataAndInfo'),
            self.term_scatterplot_structure.get_js_to_call_build_scatterplot(self.term_plot_interface),
        ])
        html_template = self._get_html_template()
        html_content = (
            html_template
                .replace('<!-- INSERT SCRIPT -->', javascript_to_insert, 1)
                .replace('<!--D3URL-->', self.d3_url_struct.get_d3_url(), 1)
                .replace('<!--D3SCALECHROMATIC-->', self.d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('<!-- INSERT D3 -->', self._get_packaged_file_content('d3.min.js'), 1)
        )
        html_content = (html_content.replace('http://', self.protocol + '://'))
        if self.show_halo:
            axes_labels = self.category_projection.get_nearest_terms(
                num_terms=self.num_terms
            )
            for position, terms in axes_labels.items():
                html_content = html_content.replace('{%s}' % position, self._get_lexicon_html(terms))
        return html_content.replace('{width}', str(self.category_width)).replace('{height}', str(self.category_height))
コード例 #3
0
    def to_html(self):
        '''
        Returns
        -------
        str, the html file representation

        '''
        javascript_to_insert = '\n'.join([
            PackedDataUtils.full_content_of_javascript_files(),
            self.category_scatterplot_structure._visualization_data.
            to_javascript('getCategoryDataAndInfo'),
            self.category_scatterplot_structure.
            get_js_to_call_build_scatterplot(self.category_plot_interface),
            self.term_scatterplot_structure._visualization_data.to_javascript(
                'getTermDataAndInfo'),
            self.term_scatterplot_structure.get_js_to_call_build_scatterplot(
                self.term_plot_interface),
            PackedDataUtils.javascript_post_build_viz(
                'categorySearch', self.category_plot_interface),
            PackedDataUtils.javascript_post_build_viz(
                'termSearch', self.term_plot_interface),
        ])
        autocomplete_css = PackedDataUtils.full_content_of_default_autocomplete_css(
        )
        html_template = self._get_html_template()
        html_content = (
            html_template.replace(
                '/***AUTOCOMPLETE CSS***/', autocomplete_css, 1).replace(
                    '<!-- INSERT SCRIPT -->', javascript_to_insert, 1).replace(
                        '<!--D3URL-->', self.d3_url_struct.get_d3_url(),
                        1).replace(
                            '<!--D3SCALECHROMATIC-->',
                            self.d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('<!-- INSERT D3 -->', self._get_packaged_file_content('d3.min.js'), 1)
        )
        html_content = (html_content.replace('http://', self.protocol + '://'))
        if self.show_halo:
            axes_labels = self.category_projection.get_nearest_terms(
                num_terms=self.num_terms)
            for position, terms in axes_labels.items():
                html_content = html_content.replace(
                    '{%s}' % position, self._get_lexicon_html(terms))
        return html_content.replace('{width}',
                                    str(self.category_width)).replace(
                                        '{height}', str(self.category_height))
コード例 #4
0
    def to_html(self):
        '''
        Returns
        -------
        str, the html file representation

        '''
        javascript_to_insert = self._get_javascript_to_insert()
        autocomplete_css = PackedDataUtils.full_content_of_default_autocomplete_css()
        html_template = self._get_html_template()
        html_content = self._replace_html_template(autocomplete_css, html_template, javascript_to_insert)
        return html_content
コード例 #5
0
    def to_html(self):
        '''
        Returns
        -------
        str, the html file representation

        '''
        javascript_to_insert = '\n'.join([
            PackedDataUtils.full_content_of_javascript_files(),
            self.category_scatterplot_structure._visualization_data.
            to_javascript('getCategoryDataAndInfo'),
            self.category_scatterplot_structure.
            get_js_to_call_build_scatterplot(self.category_plot_interface),
            self.term_scatterplot_structure._visualization_data.to_javascript(
                'getTermDataAndInfo'),
            self.term_scatterplot_structure.get_js_to_call_build_scatterplot(
                self.term_plot_interface),
        ])
        html_template = PackedDataUtils.get_packaged_html_template_content(
            PAIR_PLOT_HTML_VIZ_FILE_NAME)
        html_content = (
            html_template.replace(
                '<!-- INSERT SCRIPT -->', javascript_to_insert, 1).replace(
                    '<!--D3URL-->', self.d3_url_struct.get_d3_url(),
                    1).replace('<!--D3SCALECHROMATIC-->',
                               self.d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('<!-- INSERT D3 -->', self._get_packaged_file_content('d3.min.js'), 1)
        )
        html_content = (html_content.replace('http://', self.protocol + '://'))
        axes_labels = self.category_projection.get_nearest_terms(
            num_terms=self.num_terms)
        for position, terms in axes_labels.items():
            html_content = html_content.replace('{%s}' % position,
                                                self._get_lexicon_html(terms))
        return html_content.replace('{width}',
                                    str(self.category_width)).replace(
                                        '{height}', str(self.category_height))
コード例 #6
0
 def _get_html_template(self):
     if self.show_halo:
         return PackedDataUtils.get_packaged_html_template_content(PAIR_PLOT_HTML_VIZ_FILE_NAME)
     return PackedDataUtils.get_packaged_html_template_content(PAIR_PLOT_WITHOUT_HALO_HTML_VIZ_FILE_NAME)
コード例 #7
0
 def _get_html_template(self):
     if self.show_halo:
         return PackedDataUtils.get_packaged_html_template_content(PAIR_PLOT_HTML_VIZ_FILE_NAME)
     return PackedDataUtils.get_packaged_html_template_content(PAIR_PLOT_WITHOUT_HALO_HTML_VIZ_FILE_NAME)
コード例 #8
0
 def _get_html_template(self):
     return PackedDataUtils.get_packaged_html_template_content(self.template_file_name)