Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Define the widget components
_widget_f = vue.Select(items=['identity', 'log', 'log10', 'log1p'], v_model=f or 'identity', label='Transform')
_widget_selection = widgets.ToggleButtons(options=['default'], description='selection')
_items = [{'text': xexpr, 'value': i} for i, xexpr in enumerate(x)]
_widget_selection_space = vue.Select(items=_items, v_model=0, label='Expression')
_widget_selection_mode = widgets.ToggleButtons(options=['replace', 'and', 'or', 'xor', 'subtract'],
value='replace',
description='mode')
_widget_selection_undo = widgets.Button(description='undo', icon='arrow-left')
_widget_selection_redo = widgets.Button(description='redo', icon='arrow-right')
_widget_history_box = widgets.HBox(children=[widgets.Label('history', layout={'width': '80px'}),
_widget_selection_undo,
_widget_selection_redo])
# Put them together in the control-widget: this is what is contained within the navigation drawer
control_widget = vue.Layout(pa_1=True, column=True, children=[_widget_f,
_widget_selection_space,
_widget_selection,
_widget_selection_mode,
_widget_history_box])
# The output widget
_widget_output = widgets.Output()
# The widget for the temporary output of the progressbar
_widget_progress_output = widgets.Output()
if isinstance(x, list) is False:
x = [x]
x = _ensure_strings_from_expressions(x)
num_traces = len(x)
# make consistency checks
args = self._arg_len_check(num_traces, shape=shape, color=color, lw=lw, ls=ls,
label=label, selection=selection)
marks = self.fig.marks
self.fig.marks = []
self.fig.marks = marks
# def _ipython_display_(self):
# display(widgets.VBox([self.fig, self.output]))
class VizHistogramBqplot(VizBaseBqplot):
type_name = 'Histogram'
icon = ICON_HISTOGRAM
state = traitlets.Instance(VizHistogramState)
normalize = traitlets.Bool(False)
class Control(v.Layout):
def __init__(self, viz):
super(type(self), self).__init__(column=True)
self.viz = viz
self.ds = self.viz.state.ds
column_names = self.ds.get_column_names()
self.x = v.Select(items=column_names, v_model=self.viz.state.x_expression, label='x axis')
widgets.link((self.viz.state, 'x_expression'), (self.x, 'v_model'))
self.normalize = v.Checkbox(v_model=self.viz.normalize, label='normalize')
widgets.link((self.viz, 'normalize'), (self.normalize, 'v_model'))
self.min = widgets.FloatText(description='min')
self.max = widgets.FloatText(description='max')
widgets.link((self.viz.state, 'x_min'), (self.min, 'value'))
widgets.link((self.viz.state, 'x_max'), (self.max, 'value'))
description='progress')
_widget_f = vue.Select(items=['identity', 'log', 'log10', 'log1p'], v_model=f or 'identity', label='Transform')
_widget_vmin = widgets.FloatSlider(value=0, min=0, max=100, step=0.1, description='vmin%')
_widget_vmax = widgets.FloatSlider(value=100, min=0, max=100, step=0.1, description='vmax%')
_widget_selection = widgets.ToggleButtons(options=['default'], description='selection')
_widget_selection_mode = widgets.ToggleButtons(options=['replace', 'and', 'or', 'xor', 'subtract'],
value='replace',
description='mode')
_widget_selection_undo = widgets.Button(description='undo', icon='arrow-left')
_widget_selection_redo = widgets.Button(description='redo', icon='arrow-right')
_widget_history_box = widgets.HBox(children=[widgets.Label('history', layout={'width': '80px'}),
_widget_selection_undo,
_widget_selection_redo])
# Put them together in the control-widget: this is what is contained within the navigation drawer
control_widget = vue.Layout(pa_1=True, column=True, children=[_widget_f,
_widget_vmin,
_widget_vmax,
_widget_selection,
_widget_selection_mode,
_widget_history_box])
# The output widget
_widget_output = widgets.Output()
# The widget for the temporary output of the progressbar
_widget_progress_output = widgets.Output()
# Creating the plotly figure, which is also a widget
x = _ensure_string_from_expression(x)
y = _ensure_string_from_expression(y)
binby = []
for expression in [y, x]:
def control(self):
if self._control is None:
self._control = type(self).Control(self)
return self._control
def _ipython_display_(self):
display(self.widget)
class VizHeatmapBqplot(VizBaseBqplot):
type_name = 'Heatmap'
icon = ICON_HEATMAP
state = traitlets.Instance(VizHeatmapState)
normalize = traitlets.Bool(False)
class Control(v.Layout):
def __init__(self, viz):
super(type(self), self).__init__(column=True)
self.viz = viz
self.ds = self.viz.state.ds
column_names = self.ds.get_column_names()
self.x = v.Select(items=column_names, v_model=self.viz.state.x_expression, label='x axis')
widgets.link((self.viz.state, 'x_expression'), (self.x, 'v_model'))
self.y = v.Select(items=column_names, v_model=self.viz.state.y_expression, label='y axis')
widgets.link((self.viz.state, 'y_expression'), (self.y, 'v_model'))
self.normalize = v.Checkbox(label='normalize', v_model=self.viz.normalize)
widgets.link((self.viz, 'normalize'), (self.normalize, 'v_model'))
self.children = [self.x, self.y, self.normalize]
fig = go.FigureWidget(data=traces, layout=layout)
# Define the widget components
_widget_selection = widgets.ToggleButtons(options=['default'], description='selection')
_items = [{'text': xexpr + ' -vs- ' + yexpr, 'value': i} for i, (xexpr, yexpr) in enumerate(zip(x, y))]
_widget_selection_space = vue.Select(items=_items, v_model=0, label='selection space')
_widget_selection_mode = widgets.ToggleButtons(options=['replace', 'and', 'or', 'xor', 'subtract'],
value='replace',
description='mode')
_widget_selection_undo = widgets.Button(description='undo', icon='arrow-left')
_widget_selection_redo = widgets.Button(description='redo', icon='arrow-right')
_widget_history_box = widgets.HBox(children=[widgets.Label('history', layout={'width': '80px'}),
_widget_selection_undo,
_widget_selection_redo])
# Put them together in the control-widget: this is what is contained within the navigation drawer
control_widget = vue.Layout(pa_1=True, column=True, children=[_widget_selection_space,
_widget_selection,
_widget_selection_mode,
_widget_history_box])
# The output widget
_widget_output = widgets.Output()
# Set up all the links and interactive actions
@_widget_output.capture(clear_output=True)
def _selection(trace, points, selector):
i = _widget_selection_space.v_model
if isinstance(selector, plotly.callbacks.BoxSelector):
limits = [selector.xrange, selector.yrange]
print(i, x, y, limits)
self.df.select_rectangle(x=x[i], y=y[i], limits=limits, mode=_widget_selection_mode.value)
elif isinstance(selector, plotly.callbacks.LassoSelector):
self.df.select_lasso(expression_x=x[i], expression_y=y[i],