VisJS network interface#
VisJS offers nice graph displays.
- gismap.gisgraphs.builder.make_vis(lab, **kwargs)[source]#
Generate HTML visualization of a lab’s collaboration network.
- Parameters:
lab (
LabMap) – Lab to display.uid (
str, optional) – Unique identifier for DOM elements. Auto-generated if not provided.vis_url (
str, optional) – URL to vis-network library.groups (
dict, optional) – Group styling configuration.draw_legend (
bool, optional) – Whether to draw the legend. Defaults to True if multiple groups.physics (
dict, optional) – Physics engine configuration.nodes_options (
dict, optional) – Node styling options.edges_options (
dict, optional) – Edge styling options.interaction_options (
dict, optional) – Interaction settings.style (
string.Template, optional) – CSS template.script (
string.Template, optional) – JavaScript template.theme (
str, default=”auto”) – Initial color theme:"auto"follows the host (Jupyter / Sphinx),"light"or"dark"force a palette. Switchable at runtime from the menu.inline_images (
bool, default=True) – If True, fetch each node image and embed it as adata:URI so the canvas stays clean and PNG export works. Images that fail to download or exceedmax_inline_bytesare demoted to the initials fallback (no external URL is ever left on a node).max_inline_bytes (
int, default=200_000) – Skip inlining for any image larger than this (e.g. uncropped LDAP portraits). The node is demoted to initials.
- Returns:
HTML code as a string.
- Return type:
- gismap.gisgraphs.graph.initials(name)[source]#
- Parameters:
name (
str) – Person’s name.- Returns:
Person’s initials. Composite first names keep all their initials, while the common
First Lastcase stays two letters.- Return type:
Examples
>>> initials("Fabien Mathieu") 'FM' >>> initials("Jean-François Laslier") 'JFL' >>> initials("Jérôme Lang") 'JL' >>> initials("Élie de Panafieu") 'ÉP' >>> initials("Madonna") 'M'
- gismap.gisgraphs.graph.lab_to_graph(lab)[source]#
- Parameters:
lab (
LabMap) – A lab populated with authors and publications.- Returns:
(nodes, edges, publications)wherenodesandedgescarry only display data pluspub_keysreferences, andpublicationsis a dict keyed by publication key with the full per-pub payload (title, authors, venue, year, url, abstract, bib). Modal HTML is built JS-side from this shared dict, so each publication is shipped only once even when it touches many authors and pairs.- Return type:
Examples
>>> from gismap.lab import ListMap as Map >>> lab = Map(author_list=['Tixeuil Sébastien', 'Mathieu Fabien'], name='mini', dbs="hal") >>> lab.update_authors() >>> lab.update_publis() >>> len(lab.authors) 2 >>> 320 < len(lab.publications) < 430 True >>> nodes, edges, pubs = lab_to_graph(lab) >>> nodes[0]['group'] 'mini' >>> edges[0]['hover'] 'Show joint publications from Mathieu Fabien and Tixeuil Sébastien' >>> sample = next(iter(pubs.values())) >>> {'title', 'authors', 'bib'} <= set(sample) True >>> html = lab.html(groups={"mini": {"color": "#777"}})
- gismap.gisgraphs.graph.node_labels(names, max_len=5)[source]#
Compute display labels (initials) for a set of authors, disambiguating collisions.
- Parameters:
names (
dict) – Mappingkey -> full name.max_len (
int, default=5) – Hard cap on label length. Disambiguation stops extending a label once it reaches this length, even if a collision remains — this keeps labels readable when names cannot be told apart (e.g. a source that yields “Surname Firstname” makes shared first names look like a shared surname). Set higher to allow longer disambiguation suffixes.
- Returns:
Mapping
key -> label. When several authors share the same base initials, their labels are extended with lowercase letters from the surname until distinct (or untilmax_lenis reached).- Return type:
Examples
>>> labels = node_labels({1: "Jérôme Lang", 2: "Julien Lesca", 3: "Jean-François Laslier"}) >>> [labels[k] for k in (1, 2, 3)] ['JLa', 'JLe', 'JFL'] >>> node_labels({1: "Fabien Mathieu"})[1] 'FM'
- gismap.gisgraphs.graph.to_node(s, pub_keys, label=None)[source]#
- Parameters:
s (
LabAuthor) – Author.pub_keys (
list) – Publication keys associated with this author, year-desc order.label (
str, optional) – Pre-computed (and possibly disambiguated) initials for this node. Falls back toinitials()when not provided.
- Returns:
Display-ready data for the node. Modal HTML is rendered on click by the JS layer using
pub_keysand the shared publications dict.- Return type:
- gismap.gisgraphs.groups.is_ego(lab)[source]#
True when
labis an EgoMap (checked by name to avoid a circular import).
- class gismap.gisgraphs.widget.GismapWidget[source]#
A simple widget to test the production of LabMaps and EgoMaps.
Examples
This is a doctest example. Use a notebook to play with the widget.
>>> gw = GismapWidget() VBox(children=(HTML(value=''), Output(), HBox(children=(Textarea(value='', ... >>> gw.names.value = "Fabien Mathieu" >>> gw.dbs.value = "HAL" >>> gw.size.value = 3 >>> gw.compute_function(gw.compute, show=False) >>> gw.save_link.value[:30] "<a href='data:text/html;base64" >>> gw.names.value = "Diego Perino, Laurent Viennot" >>> gw.compute_function(gw.compute, show=False) >>> gw.save_link.value[:30] "<a href='data:text/html;base64"