Skip to content

hover_text_html_template unintuitively ignored in several situations #150

@richardmillson

Description

@richardmillson

Setup:

from pathlib import Path

import datamapplot
import numpy as np
import pandas as pd

data_map = np.random.uniform(size=[10, 2])
label_layers = ["a"] * data_map.shape[0]
extra_point_data = pd.DataFrame({"col" : ["b"] * data_map.shape[0]})
hover_text_html_template = """
<div>
  From hover_text_html_template
</div>
"""
plot = datamapplot.create_interactive_plot(
    data_map,
    label_layers,
    hover_text_html_template=hover_text_html_template,
)
Path("test.html").write_text(plot._html_str)

No hover.

hover_text_html_template = """
<div>
  From hover_text_html_template
</div>
"""
plot = datamapplot.create_interactive_plot(
    data_map,
    label_layers,
    hover_text=label_layers,
    hover_text_html_template=hover_text_html_template,
)

Displays hover_text not hover_text_html_template.

hover_text_html_template = """
<div>
  From hover_text_html_template: {col}
</div>
"""
plot = datamapplot.create_interactive_plot(
    data_map,
    label_layers,
    extra_point_data=extra_point_data,
    hover_text_html_template=hover_text_html_template,
)

Raises Uncaught (in promise) TypeError: this.metaData[this.searchField] is undefined if extra_point_data is specified without hover_text.

hover_text_html_template = """
<div>
  From hover_text_html_template: {hover_text}
</div>
"""
plot = datamapplot.create_interactive_plot(
    data_map,
    label_layers,
    hover_text=label_layers,
    hover_text_html_template=hover_text_html_template,
)

Displays hover_text and not hover_text_html_template.

extra_point_data = pd.DataFrame({"col" : ["b"] * data_map.shape[0]})
hover_text_html_template = """
<div>
  From hover_text_html_template: {col}
</div>
"""
plot = datamapplot.create_interactive_plot(
    data_map,
    label_layers,
    extra_point_data=extra_point_data,
    hover_text=label_layers,
    hover_text_html_template=hover_text_html_template,
)

Displays correctly. Here hover_text must be specified for hover_text_html_template to work even though it will be overridden by hover_text_html_template.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions