How to use the scattertext.viz.BasicHTMLFromScatterplotStructure.PackedDataUtils function in scattertext

To help you get started, we’ve selected a few scattertext examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
d3_url_struct = D3URLs(d3_url, d3_scale_chromatic_url)
        ExternalJSUtilts.ensure_valid_protocol(protocol)
        javascript_to_insert = '\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(search_input_id, 'plotInterface'),
        ])
        html_template = (PackedDataUtils.full_content_of_default_html_template()
                         if html_base is None
                         else self._format_html_base(html_base))
        html_content = (
            html_template
                .replace('', javascript_to_insert, 1)
                .replace('',
                         PackedDataUtils.full_content_of_default_search_form(search_input_id), 1)
                .replace('', d3_url_struct.get_d3_url(), 1)
                .replace('', d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', self._get_packaged_file_content('d3.min.js'), 1)
        )

        '''
        if html_base is not None:
            html_file = html_file.replace('',
                                          html_base)
        '''

        extra_libs = ''
        if self.scatterplot_structure._save_svg_button:
            # extra_libs = ''
            extra_libs = ''
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
search_input_id : str
            Id of search input. Default is 'searchInput'.
        Returns
        -------
        str, the html file representation

        '''
        d3_url_struct = D3URLs(d3_url, d3_scale_chromatic_url)
        ExternalJSUtilts.ensure_valid_protocol(protocol)
        javascript_to_insert = '\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(search_input_id, 'plotInterface'),
        ])
        html_template = (PackedDataUtils.full_content_of_default_html_template()
                         if html_base is None
                         else self._format_html_base(html_base))
        html_content = (
            html_template
                .replace('', javascript_to_insert, 1)
                .replace('',
                         PackedDataUtils.full_content_of_default_search_form(search_input_id), 1)
                .replace('', d3_url_struct.get_d3_url(), 1)
                .replace('', d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', self._get_packaged_file_content('d3.min.js'), 1)
        )

        '''
        if html_base is not None:
            html_file = html_file.replace('',
                                          html_base)
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
html_base : str
            None by default.  HTML of semiotic square to be inserted above plot.
        search_input_id : str
            Id of search input. Default is 'searchInput'.
        Returns
        -------
        str, the html file representation

        '''
        d3_url_struct = D3URLs(d3_url, d3_scale_chromatic_url)
        ExternalJSUtilts.ensure_valid_protocol(protocol)
        javascript_to_insert = '\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(search_input_id, 'plotInterface'),
        ])
        html_template = (PackedDataUtils.full_content_of_default_html_template()
                         if html_base is None
                         else self._format_html_base(html_base))
        html_content = (
            html_template
                .replace('', javascript_to_insert, 1)
                .replace('',
                         PackedDataUtils.full_content_of_default_search_form(search_input_id), 1)
                .replace('', d3_url_struct.get_d3_url(), 1)
                .replace('', d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', self._get_packaged_file_content('d3.min.js'), 1)
        )

        '''
        if html_base is not None:
github JasonKessler / scattertext / scattertext / viz / PairPlotFromScattertextStructure.py View on Github external
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)
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
def _load_script_file_names(script_names):
        return '; \n \n '.join([PackedDataUtils.get_packaged_script_content(script_name)
                                for script_name in script_names])
github JasonKessler / scattertext / scattertext / viz / PairPlotFromScattertextStructure.py View on Github external
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('', javascript_to_insert, 1)
                .replace('', self.d3_url_struct.get_d3_url(), 1)
                .replace('', self.d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', self._get_packaged_file_content('d3.min.js'), 1)
github JasonKessler / scattertext / scattertext / viz / PairPlotFromScattertextStructure.py View on Github external
'''
        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('', javascript_to_insert, 1)
                .replace('', self.d3_url_struct.get_d3_url(), 1)
                .replace('', self.d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', 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))
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
def full_content_of_default_autocomplete_css():
        return PackedDataUtils.get_packaged_html_template_content(AUTOCOMPLETE_CSS_FILE_NAME)
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
.replace('', d3_url_struct.get_d3_scale_chromatic_url())
            # .replace('', self._get_packaged_file_content('d3.min.js'), 1)
        )

        '''
        if html_base is not None:
            html_file = html_file.replace('',
                                          html_base)
        '''

        extra_libs = ''
        if self.scatterplot_structure._save_svg_button:
            # extra_libs = ''
            extra_libs = ''

        autocomplete_css = PackedDataUtils.full_content_of_default_autocomplete_css()
        html_content = (html_content
                        .replace('/***AUTOCOMPLETE CSS***/', autocomplete_css, 1)
                        .replace('', extra_libs, 1)
                        .replace('http://', protocol + '://'))

        return html_content
github JasonKessler / scattertext / scattertext / viz / BasicHTMLFromScatterplotStructure.py View on Github external
None by default.
          URL of d3_scale_chromatic_url, to be inserted into