Skip to content

Commit 6c79110

Browse files
committed
Jupyter histogram: resolve small fixmes
1 parent 4f4d191 commit 6c79110

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/ndv/views/_jupyter/_array_view.py

+14-11
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,21 @@ def __init__(self, channel: ChannelKey = None) -> None:
9292
tooltip="View Histogram",
9393
layout=widgets.Layout(width="40px"),
9494
)
95+
96+
histogram_ctrl_width = 40
9597
self._log = widgets.ToggleButton(
9698
value=False,
9799
description="log",
98100
button_style="", # 'success', 'info', 'warning', 'danger' or ''
99101
tooltip="Apply logarithm (base 10, count+1) to bins",
100-
layout=widgets.Layout(width="40px"),
102+
layout=widgets.Layout(width=f"{histogram_ctrl_width}px"),
101103
)
102104
self._reset_histogram = widgets.Button(
103105
description="",
104106
button_style="", # 'success', 'info', 'warning', 'danger' or ''
105107
icon="expand",
106108
tooltip="Reset histogram view",
107-
layout=widgets.Layout(width="40px"),
109+
layout=widgets.Layout(width=f"{histogram_ctrl_width}px"),
108110
)
109111

110112
# LAYOUT
@@ -118,29 +120,30 @@ def __init__(self, channel: ChannelKey = None) -> None:
118120
self._histogram_btn,
119121
]
120122
)
121-
# FIXME:
122-
self._histogram_btns = widgets.VBox(
123+
124+
histogram_ctrls = widgets.VBox(
123125
[self._log, self._reset_histogram],
124126
layout=widgets.Layout(
125127
# Avoids scrollbar on buttons
126-
# FIXME: Can this be programmatically computed?
127-
min_width="50px",
128+
min_width=f"{histogram_ctrl_width + 10}px",
128129
# Floats buttons to the bottom
129130
justify_content="flex-end",
130131
),
131132
)
133+
132134
self._histogram_container = widgets.HBox(
133-
[self._histogram_btns],
135+
# Note that we'll add a histogram here later
136+
[histogram_ctrls],
134137
layout=widgets.Layout(
135138
# Constrains histogram to 100px tall
136139
max_height="100px",
137-
# Avoids nearly-useless vertical scrollbar from
140+
# Avoids vertical scrollbar from
138141
# histogram being *just a bit* too tall
139-
# FIXME: Is there a better way?
140-
overflow="hidden",
142+
overflow="visible",
143+
# Hide histogram initially
144+
display="none",
141145
),
142146
)
143-
self._histogram_container.layout.display = "none"
144147
self.layout = widgets.VBox([lut_ctrls, self._histogram_container])
145148

146149
# CONNECTIONS

0 commit comments

Comments
 (0)