Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 = ''
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)
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:
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)
def _load_script_file_names(script_names):
return '; \n \n '.join([PackedDataUtils.get_packaged_script_content(script_name)
for script_name in script_names])
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)
'''
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))
def full_content_of_default_autocomplete_css():
return PackedDataUtils.get_packaged_html_template_content(AUTOCOMPLETE_CSS_FILE_NAME)
.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
None by default.
URL of d3_scale_chromatic_url, to be inserted into