Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion great_tables/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1445,7 +1445,7 @@ def nanoplot_options(
show_vertical_guides = True if show_vertical_guides is None else show_vertical_guides
show_y_axis_guide = True if show_y_axis_guide is None else show_y_axis_guide

interactive_data_values = interactive_data_values or True
interactive_data_values = True if interactive_data_values is None else interactive_data_values

# y_val_fmt_fn, y_axis_fmt_fn, and y_ref_line_fmt_fn
# are not assigned to a default value
Expand Down
30 changes: 30 additions & 0 deletions tests/test__utils_nanoplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,22 @@ def test_nanoplot_unknown_plot_type():
_generate_nanoplot(y_vals=[1, 2, 3], plot_type="unknown")


@pytest.mark.parametrize("interactive_data_values", [True, False])
def test_generate_nanoplot_interactive_data_values_toggles_hover_css(interactive_data_values):
svg = _generate_nanoplot(
y_vals=[1.0, 2.0, 3.0],
interactive_data_values=interactive_data_values,
)

assert _is_nanoplot_output(svg)

if interactive_data_values:
assert ".vert-line:hover rect" in svg
else:
assert ":hover" not in svg
assert ".vert-line rect" in svg


@pytest.mark.parametrize(
"n, bool_",
[
Expand Down Expand Up @@ -2061,3 +2077,17 @@ def test_noerror_list_of_strings() -> None:
show_data_area=False,
),
)


def test_nanoplot_options_interactive_data_values():
# When interactive_data_values is not set, it should default to True
opts_default = nanoplot_options()
assert opts_default["interactive_data_values"] is True

# When explicitly set to False, it should be respected (not overridden)
opts_false = nanoplot_options(interactive_data_values=False)
assert opts_false["interactive_data_values"] is False

# When explicitly set to True, it should remain True
opts_true = nanoplot_options(interactive_data_values=True)
assert opts_true["interactive_data_values"] is True