def __init__(self, hex=False, **kwargs): self._hex = hex colorcet = Colorcet(name='colorcet') colorbrewer = ColorBrewerPalette(name='colorbrewer') diverging = DivergingPalette(name='diverging') sequential = SequentialPalette(name='sequential') cubehelix = CubeHelixPalette(name='cubehelix') sns_palette = SeabornPalette(name='sns_palette') button_labels = ['Diverging', 'Colorbrewer', 'Sequential', 'Cubehelix', 'Seaborn'] children=[colorcet,diverging, colorbrewer, sequential, cubehelix, sns_palette] self._name_trans = dict(zip(range(len(button_labels)),[c.name for c in children])) dash= ['t$N=master_palette_tabs&t=Colorcet,Diverging, Colorbrewer, Sequential,Cubehelix, Seaborn', children] Dashboard.__init__(self, dash,**kwargs) self.pal = self.diverging.pal self.cmap = self.diverging.cmap self.observe(self.update_masterpalette) self.update_masterpalette() selected = getattr(self, self.tab_selected) selected.as_cmap.value = True
def __init__(self, name='dash', box='5c', interact=None, mode=None, func=None, dash=None, group_n=3, **kwargs): self._group_n = group_n self.__dic_mode = mode self.__interact = interact if self.__interact and mode is None: self.__dic_mode = 'interactive' if not func is None: a = inspect.getargspec(func) c_kwargs = dict(zip(a.args[-len(a.defaults):], a.defaults)) c_kwargs.update(kwargs) else: c_kwargs = kwargs children = self.get_children_widgets(c_kwargs) self.name = name dash = dash or self.process_children_layout( box, children) #dash or [box+'$n='+name,children] #print(dash) Dashboard.__init__(self, dash, name=name, mode=mode) self._func = func self.observe(self.fun)
def __init__(self, data, max=None, min=None, step=None, low=None, high=None, description='plot_data', map_data = True, default_color='blue', **kwargs ): self._data = data self._description = description slicer = self._get_data_slicer(description=description) scaler = DataFrameScaler(slicer.output, max=max, min=min, step=step, low=low, high=high, name='data_scaler') self.output = pd.DataFrame(index=scaler.output.index, columns=[description]) cmap = ColormapPicker(name='cm_picker', mode='interactive') dash = ['r$N=main_row', [ slicer, ['c$N=aply_col',[scaler, ['r$N=apply_row',['Map Data$N=map_text','@'+str(map_data)+'$N=map_chk','[['+str(map_data)+']]$N=map_valid']] ]], ['c$N=color_col',[ cmap, '@cpicker$N=default_color&d=Default color&val='+default_color]] ] ] Dashboard.__init__(self, dash, **kwargs) self.link('map_chk','map_valid') self.map_chk.target.layout.width = "100%" self.map_valid.target.readout = 'Mapping disabled' self.observe(self.update) self.update()
def __init__(self, description='Cmap', **kwargs): dash = [ 'c$N=cmap_picker', [[ 'r$N=display_col', ['btn$N=cmap_btn&d=' + description, 'HTML$N=mini_display'] ], [ 'c$N=palette_col', [ MasterPalette(name='master_palette', mode='interactive'), 'btn$d=Close&N=close_btn' ] ]] ] Dashboard.__init__(self, dash, **kwargs) self.mini_display.target.layout.width = "20em" self.mini_display.target.layout.height = "2em" self.palette_col.visible = False self.cmap = self.master_palette.cmap self.pal = self.master_palette.pal self.cmap_btn.observe(self._on_cmap_click) self.close_btn.observe(self._on_close_click) self._on_close_click()
def __init__(self, ros_step=1, ras_step=1, sbt_step=1, lj_step=1, ras_range=(2, 4), ros_range=(2, 4), lj_range=(2, 4), sbt_range=(2, 4), **kwargs): multi = MultiDimTest(ros_step=ros_step, ras_step=ras_step, sbt_step=sbt_step, lj_step=lj_step, ras_range=ras_range, ros_range=ros_range, lj_range=lj_range, sbt_range=sbt_range, name="multi") wiki = Wikipedia2D(name='wiki') self.functions = {} dash = [ 'c$N=test_functions', [ multi, wiki, ["r$n=btn_col", ["togs$N=mode_sel&o=['wiki','multi']"]] ] ] Dashboard.__init__(self, dash, **kwargs) self.mode_sel.observe(self.update_layout) self.wiki.func_sel.observe(self.update) self.multi.update_btn.observe(self.update) self.update_layout() self.update()
def __init__(self, title='Font', family='Verdana', size=12, color='black', mode='interactive', **kwargs): fonts = matplotlib.font_manager.get_fontconfig_fonts() font_names = [ matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in fonts ] dash = [ 'c$n=font_manager', [ '###' + title + '$n=title', '@select$d=Family&o=' + str(font_names) + '&val=' + family, '@(1,50,1,' + str(size) + ')$d=Size', '@cpicker$d=Color&val=' + color ] ] Dashboard.__init__(self, dash, **kwargs) self.family.widget.layout.width = "20em" self.color.widget.layout.width = "20em" self.family.target.layout.width = "100%" self.color.target.layout.width = "100%"
def __init__(self, bordercolor='#444', visible=False, thickness=0.15, bgcolor='#fff', borderwidth=0, **kwargs): dash = [ 'c$N=range_slider_plotly', [ '###Slider$N=title_slider', [ 'r$N=row_1', [ '@cp$n=bgcolor&d=Color&val=' + bgcolor, '@cp$d=Border&n=bordercolor&val=' + bordercolor ] ], [ 'r$N=row_2', [ '@(0,50,1,' + str(borderwidth) + ')$d=Border width&N=borderwidth', '@(0.,1.,0.05,' + str(thickness) + ')$d=Thickness&N=thickness' ] ], ['@' + str([visible]) + '$d=Visible&n=slider_visible'] ] ] Dashboard.__init__(self, dash, **kwargs)
def __init__(self, default_params=None, **kwargs): if default_params is None: self.params = self.default_matrix_params() else: self.params = default_params dash = ['c$N=matrix_params', ['###Matrix params$N=matparams_title', ['r$N=body_box',[ ['c$N=mp_num_box',['@(-50.,50.,1.,'+str(float(self.params['norm_min']))+')$N=norm_min&d=Rescale min', '@(-50.,50.,1.,'+str(float(self.params['norm_max']))+')$N=norm_max&d=Rescale max', '@[-5e5,2e10,1.,'+str(float(self.params['clip_min']))+']$N=clip_min&d=Clip min', '@[-5e5,2e10,1.,'+str(float(self.params['clip_max']))+']$N=clip_max&d=Clip max' ] ], ['c$N=mp_target_box',[['@sel$N=target_selector&d=Transform matrix&o='+str(self.get_target_options())+'&val='+str(self.params['target'][0][0])], ['r$N=buttonbox',['btn$d=Add','btn$d=Delete']], ['@texta$N=target_display&val='+str(self.params['target'])] ] ] ] ] ] ] Dashboard.__init__(self, dash, **kwargs) self.add.observe(self.on_add_clicked) self.delete.observe(self.on_del_clicked) self.observe(self.update) self.update()
def __init__(self, default_params=None, metrics=None, target=None, **kwargs): if default_params is None: params = self.default_graph_params() else: params = default_params if metrics is None: metrics = self.default_node_metrics() if target is None: dict_target_attrs = self.default_target_attributes() else: dict_target_attrs = target options = {'Mst':'mst', 'Pmfg':'pmfg', 'Full Matrix':'full'} dash = ['c$N=graph_params',['###Graph params$N=gaphparams_title', '@togs$d=Graph type&o='+str(options)+'&val='+str(params['graph_type']), ['r$N=gparams_row',['@[0.,50e10,1,'+str(params['threshold'])+']$N=threshold&d=Abs val threshold', '@False$N=inverted&d=Invert distance' ] ], '@selmul$d=Metrics&o='+str(metrics), '@dd$N=target_attr&d=Target attribute&o='+str(dict_target_attrs)+'&val='+str(params['target_attr']) ] ] Dashboard.__init__(self, dash, **kwargs) self.metrics.value = tuple(metrics)
def __init__(self, panel4D,description='Panel', mode='interactive', **kwargs): self.panel4D = panel4D self.output = None if description == '': desc_title = '##'+description+'$N=pslicer_text&v=0' else: desc_title = '##'+description+'$N=pslicer_text' labels_slicer = ArraySlicer(panel4D.labels.values, name='labels_slicer', description='labels') items_slicer = ArraySlicer(panel4D.items.values, name='items_slicer', description='items') dash =['c$N=p4d_slicer', [ desc_title, ['r$N=p4d_slicer_row', [labels_slicer, items_slicer, ArraySlicer(panel4D.major_axis.values, name='major_axis_slicer', description='major_axis'), ArraySlicer(panel4D.minor_axis.values, name='minor_axis_slicer', description='minor_axis') ] ] ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.observe(self.update) self.update()
def __init__(self, l=80, r=80, b=80, t=100, pad=0, autoexpand=True, title='Margin', **kwargs): dash = [ 'c$n=margin_dash', [ '###' + title + '$N=margin_title', [ 'r$N=margin_row1', [ '@(0,250,1,' + str(l) + ')$d=l', '@(0,250,1,' + str(r) + ')$d=r', '@(0,250,1,' + str(b) + ')$d=b' ] ], [ 'r$N=margin_row2', [ '@(0,350,1,' + str(t) + ')$d=t', '@(0,250,1,' + str(pad) + ')$d=pad', '@' + str([autoexpand]) + '$d=autoexpand' ] ] ] ] Dashboard.__init__(self, dash, **kwargs) for slider in ['l', 'r', 'b', 't', 'pad']: getattr(self, slider).target.continuous_update = False
def __init__(self, name='dash', box='5c', interact=None, mode=None, func=None, dash=None, group_n=3, **kwargs): self._group_n = group_n self.__dic_mode = mode self.__interact = interact if self.__interact and mode is None: self.__dic_mode = 'interactive' if not func is None: a = inspect.getargspec(func) c_kwargs = dict(zip(a.args[-len(a.defaults):],a.defaults)) c_kwargs.update(kwargs) else: c_kwargs = kwargs children = self.get_children_widgets(c_kwargs) self.name = name dash = dash or self.process_children_layout(box,children)#dash or [box+'$n='+name,children] #print(dash) Dashboard.__init__(self,dash,name=name,mode=mode) self._func = func self.observe(self.fun)
def __init__(self, panel, description='Panel', mode='interactive', **kwargs): self.panel = panel self.output = None if description == '': desc_title = '##' + description + '$N=pslicer_text&v=0' else: desc_title = '##' + description + '$N=pslicer_text' dash = [ 'c$N=panel_slicer', [ desc_title, [ 'r$N=panel_slicer_row', [ ArraySlicer(panel.items.values, name='items_slicer', description='items'), ArraySlicer(panel.major_axis.values, name='major_axis_slicer', description='major_axis'), ArraySlicer(panel.minor_axis.values, name='minor_axis_slicer', description='minor_axis') ] ] ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.observe(self.update) self.update()
def __init__(self, data, mask, strf='%a\n%d\n%h\n%Y', font_size=20, pct_space=0.1, width="20em", height="3em", cmap=None, orient='horizontal', **kwargs): if cmap is None: colors = diverging_palette(h_neg=38, h_pos=167, s=99, l=66, sep=39, n=256, center='light') cmap = LinearSegmentedColormap.from_list("interactive", colors) cmap._init() cmap._set_extremes() self.cmap = cmap else: self.cmap = cmap self._width = width self._height = height self.data = data self.mask = mask if self.is_time_array(data): start = 'HTML$N=start&val=' + pd.to_datetime( self.data[0]).strftime(strf) end = 'HTML$N=end&val=' + pd.to_datetime( self.data[-1]).strftime(strf) #self.start = TimeDisplay(datetime=pd.to_datetime(self.data[0]), strf=self.strf.value) #self.end = TimeDisplay(datetime=pd.to_datetime(self.data[-1]), strf=self.strf.value) else: start = 'HTML$N=start&val=' + str(self.data[0]) end = 'HTML$N=end&val=' + str(self.data[-1]) self.strf = strf self.font_size = font_size self.pct_space = pct_space self.orient = orient plot = 'HTML$N=plot' dash = ['c$N=AxisPlot', [['r$N=plot_box', [start, plot, end]]]] Dashboard.__init__(self, dash, **kwargs) self.plot.value = self.plot_axis(data=self.data, idx=self.mask, cmap=self.cmap, strf=self.strf, fontsize=self.font_size, pct_space=self.pct_space) self.observe(self._trigger_update) self._trigger_update() self.update()
def __init__(self, showticklabels=True, nticks=6, ticksuffix="", showticksuffix='none', tickprefix='', showtickprefix='none', tickformat='', tickmode='auto', ticks='outside', ticklen=5, tickvals=[], ticktext=[], tickfont={'family':'Verdana'}, tickwidth=1, tick0=0, tickangle=-1, dtick=1, tickcolor='#444', title='Ticks', **kwargs): show_mode = ['all','first','all','none'] show_row = ['r$n=row_show',[ ['c$N=subcol_1',['@'+str(showticklabels)+'$d=Showticklabels']], ['c$N=subcol_2',['@dd$d=Show suffix&n=showticksuffix&o='+str(show_mode)+'&val='+str(showticksuffix), '@text$d=suffix&n=ticksuffix&val='+str(showticksuffix)]], ['c$N=subcol_3',['@dd$d=Show prefix&n=showtickprefix&o='+str(show_mode)+'&val='+str(showtickprefix), '@text$d=prefix&n=tickprefix&val='+str(showtickprefix)]] ]] tickmode_opts = ['auto','linear','array'] mode_row = ['r$N=mode_row',[['c$N=mscol_1',['@float_text$d=tick0&val='+str(tick0), '@(0,500,1,'+str(nticks)+')$d=nticks']], ['c$N=mscol_2',['@dd$d=tickmode&o='+str(tickmode_opts)+'&val='+str(tickmode), '(0.,500.,0.25,'+str(dtick)+')$d=dtick']], ] ] font_m = FontManager(name='tickfont',title='tickfont',mode='interactive') format_row = ['r$N=format_row',[font_m, ['c$N=fcol_1',['@dd$d=ticks&o=["outside","inside",""]', '@cp$d=tickcolor', '@(0,25,1,'+str(ticklen)+')$d=ticklen', '@(0,25,1,'+str(tickwidth)+')$d=tickwidth', '@(-1,360,1,'+str(tickangle)+')$d=tickangle', '@text$d=tickformat&val=""', ]] ] ] toggle_row = ['r$N=toggle_rowb',['[True]$d=show&n=show_togb&mode=passive','[True]$d=mode&n=mode_tog&mode=passive','[True]$d=format&n=format_togb&mode=passive']] dash = ['c$n=ticks_col_b',[['##'+title+'$N=ticks_title'], ['r$N=in_row',[['c$N=widget_row_a',[show_row, mode_row]],format_row]], toggle_row ] ] Dashboard.__init__(self, dash, **kwargs) for slider in ['dtick','ticklen','tickwidth','tickangle']: getattr(self,slider).target.continuous_update = False
def __init__(self, df, plot_kwargs=None,mode='interactive',theme='space', **kwargs): if plot_kwargs is None: self.plot_kwargs = {'title':'Bar'} else: self.plot_kwargs = plot_kwargs self._df = df col_opts = [''] + list(df.columns.values) col_opts_2 = col_opts.copy() col_opts_2[0] = "None" self._col_opts = dict(zip(col_opts_2,col_opts)) cmap = ColormapPicker(name='cmap', mode='interactive') layout = Layout(name='layout_d', mode='interactive') kind_opts = ["scatter","bar","box", "spread","ratio","heatmap", "surface","histogram", "bubble", "bubble3d","scatter3d","scattergeo","choroplet"] color_scales = list(cf.colors.get_scales().keys())+[None] dash = ['c$N=cufflinks', [ ['r$n=general_params',['@sm$d=columns&o='+str(col_opts[1:]),['c$n=aux_col_1',['@dd$d=Kind&o='+str(kind_opts),'@[False]$d=subplots', '@[False]$d=Shared xaxes','@[False]$d=Shared yaxes']], ['c$N=titles_col',["@text$d=Title","@text$d=xTitle","@text$d=yTitle","@text$d=zTitle"]], '@select$d=Theme&o='+str(cf.getThemes())+'&val='+theme, ['c$n=colorp_row',['@dd$d=categories&o='+str(self._col_opts),'@sm$d=secondary_y&o='+str(self._col_opts),'@dd$d=Color scale',cmap]] ] ], ['r$n=scatter_params',[['c$n=axis_col_xyz',['@dd$d=x&o='+str(self._col_opts),'@dd$d=y&o='+str(self._col_opts),'@dd$d=z&o='+str(self._col_opts)]], ['c$n=marker_prop_col',['@dd$d=text&o='+str(self._col_opts),'@(1,500,1,12)$d=Size', '@dd$d=Marker mode&o=["lines","markers","text","lines+markers","markers+text","lines+text","lines+markers+text"]']], '@False$d=fill','@dd$d=symbol&o=["dot","cross","square","triangle-down","triangle-right","triangle-left","triangle-up","x"]', '@dd$d=dash&o=["solid","dash","dashdot","dot"]' ]], ['r$N=barmode_row',['@ddown$d=barmode&o=["stack", "group", "overlay"]', ['c$N=mini_bar_col',['@togs$d=Orientation&n=ori&o=["v","h"]&val=v', "@(0.,1.,0.05,1.)$d=Bargap", "@(0.,1.,0.05,1.)$d=Bargroupgap"]], ['c$N=hist_col',["@(0,500,1,0)$d=Bins", '@dd$d=Histnorm&o=["frequency","percent","probaility","density","probability density"]', '@dd$d=Histfunc&o=["count","sum","avg","min","max"]']], ]], layout, ['r$n=btn_rows',['[False]$d=Layout&n=btn_layout','@False$d=Apply layout', '@btn$d=Update&n=update_btn'] ] ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.theme.target.layout.width = "100%" self.theme.widget.layout.width = "100%" self.url = ''#not used, but prepared for working online. self._init_widget_values() self.observe(self.update) self.btn_layout.observe(self._layout_toggle)
def __init__(self, data, max=None, min=None, step=None, low=None, high=None, description='plot data', map_data = True, default=None, fixed_active=False, **kwargs ): self._description = description self._data = data slicer = self._get_data_slicer(description=description) scaler = DataFrameScaler(slicer.output, max=max, min=min, step=step, low=low, high=high, name='data_scaler') self.output = pd.DataFrame(index=scaler.output.index, columns=[description]) if max is None: max = 100 if min is None: min = 0 if high is None: high = 100 if low is None: low = 0 if step is None: step = 1 if default is None: default = (high+low)*0.5 if np.isnan(default): def_widget='HTML$N=default_w&v=0' self.default_value = np.nan else: def_widget = '@('+str(min)+','+str(max)+','+str(step)+','+str(default)+')$d=Default value' dash = ['r$N=main_row', [ slicer, ['c$N=aply_col',[scaler, ['r$N=apply_row',['Map Data$N=map_text','@'+str(map_data)+'$N=map_chk','[['+str(map_data)+']]$N=map_valid']] ]], def_widget ] ] Dashboard.__init__(self, dash, **kwargs) if fixed_active: self.map_chk.visible = False self.map_valid.visible = False self.map_chk.target.disabled = True self.link('map_chk','map_valid') self.map_chk.target.layout.width = "100%" self.map_valid.target.readout = 'Mapping disabled' self.observe(self.update) self.update()
def __init__(self, G, default_params=None,mode='interactive', **kwargs): if default_params is None: self.params = self.default_layout_params() else: self.params = default_params self._G = G dim_opts = {'2D':'2d', '3D':'3d', 'Both':'both'} edges = G.edges()[0] ls_weights = list(G.edge[edges[0]][edges[1]].keys()) if 'exchange' not in ls_weights: ls_weights += ['exchange'] if 'weight' not in ls_weights: ls_weights += ['weight'] dash = ['c$N=layout_params', [ '###Layout Params$N=layout_param_title', ['r$N=body_row',['@sel$d=Layout&o='+str(self.available_layouts())\ +'&val='+str(self.params['layout']), ['c$N=layout_row_1', [ ['r$N=top_mini_box', ['@togs$d=Dimension&N=dim&o='+str(dim_opts)+'&val='+str(self.params['dim']), '@(1e-4,10e4,1,'+str(self.params['scale'])+')$d=Scale', 'text$d=Center&N=center_display&val='+str(self.params['center']) ] ], ['r$N=bot_mini_box',['@selmul$d=Root node&N=fixed_display&o='+str(list(G.nodes())+['None']), ['c$N=sub_box_layout', ['@dd$d=Weight&o='+str(ls_weights+['None'])+'&val='+str(self.params['weigth']), ['r$N=sub_subrow',['@(1,10e4,1,'+str(self.params['iterations'])+')$d=Iterations', '@dd$N=kmet&d=k&o='+str(ls_weights)+'&val='+str(self.params['k']), '@(0,1e4,1,0)$N=kfloat&d=k' ] ], '@togs$d=Prog&o=["neato", "twopi", "fdp", "dot", "circo"]&val='+str(self.params['prog']) ] ] ] ] ] ] ] ] ] ] Dashboard.__init__(self, dash,mode=mode, **kwargs) self.fixed_display.value = [str(self.params['fixed'])] self.observe(self.update_display) self.observe(self.update_value) self.layout.observe(self.on_layout_change) self.update_display() #Can inherit a target when not used as a widget self.update_value()
def __init__(self, matrix_panel, node_metrics, only_layout=False, mode='interactive', **kwargs): self.matrix_panel = matrix_panel self.node_metrics = node_metrics gp = GraphParams(name='gp', mode='interactive') mp = MatrixParams(name='mp', mode='interactive') self.gm = GraphMaker(self.matrix_panel, node_data=node_metrics, inv=gp.inverted.value, threshold=gp.threshold.value, matrix_params=mp.output, graph_type=gp.graph_type.value, target=gp.target_attr.value) self.G = self.gm.G dash = ['c$N=graphcalculator', ['###Graph Calculator$N=gc_title', ['r$N=body_row',[gp, mp, LayoutCalculator(self.G, name='layout', mode='interactive') ] ], ['r$N=buttons_row',['btn$d=Calculate', 'tog$N=toggle_gp&d=Creation', 'tog$N=toggle_mp&d=Matrix', 'tog$N=toggle_layout&d=Layout', 'HTML$N=display' ] ] ] ] Dashboard.__init__(self, dash, **kwargs) self.display.value = self.display_str('Select and click Calculate') if not only_layout: self.node_metrics = node_metrics self.init = True self.update() self.init = False self.calculate.observe(self.on_calculate_click) self.toggle_gp.observe(self.on_toggp_change) self.toggle_mp.observe(self.on_togmp_change) self.toggle_layout.observe(self.on_toglay_change) self.update() self.toggle_mp.value = False self.toggle_gp.value = True self.toggle_layout.value = True self.on_toggp_change() self.on_togmp_change() self.on_toglay_change()
def __init__(self, data, mask, strf='%a\n%d\n%h\n%Y', font_size=20, pct_space=0.1, width="20em", height="3em", cmap=None, orient='horizontal', **kwargs ): if cmap is None: colors = diverging_palette(h_neg=38, h_pos=167, s=99, l=66, sep=39, n=256, center='light') cmap = LinearSegmentedColormap.from_list("interactive", colors) cmap._init() cmap._set_extremes() self.cmap = cmap else: self.cmap = cmap self._width = width self._height = height self.data = data self.mask = mask if self.is_time_array(data): start = 'HTML$N=start&val='+pd.to_datetime(self.data[0]).strftime(strf) end ='HTML$N=end&val='+pd.to_datetime(self.data[-1]).strftime(strf) #self.start = TimeDisplay(datetime=pd.to_datetime(self.data[0]), strf=self.strf.value) #self.end = TimeDisplay(datetime=pd.to_datetime(self.data[-1]), strf=self.strf.value) else: start = 'HTML$N=start&val='+str(self.data[0]) end = 'HTML$N=end&val='+str(self.data[-1]) self.strf = strf self.font_size = font_size self.pct_space = pct_space self.orient = orient plot = 'HTML$N=plot' dash = ['c$N=AxisPlot', [ ['r$N=plot_box',[start, plot, end]] ] ] Dashboard.__init__(self, dash, **kwargs) self.plot.value = self.plot_axis(data=self.data, idx=self.mask, cmap=self.cmap, strf=self.strf, fontsize=self.font_size, pct_space=self.pct_space ) self.observe(self._trigger_update) self._trigger_update() self.update()
def __init__(self, G, default_params=None, mode='interactive', **kwargs): if default_params is None: self.params = self.default_layout_params() else: self.params = default_params self._G = G dim_opts = {'2D': '2d', '3D': '3d', 'Both': 'both'} edges = G.edges()[0] ls_weights = list(G.edge[edges[0]][edges[1]].keys()) if 'exchange' not in ls_weights: ls_weights += ['exchange'] if 'weight' not in ls_weights: ls_weights += ['weight'] dash = ['c$N=layout_params', [ '###Layout Params$N=layout_param_title', ['r$N=body_row',['@sel$d=Layout&o='+str(self.available_layouts())\ +'&val='+str(self.params['layout']), ['c$N=layout_row_1', [ ['r$N=top_mini_box', ['@togs$d=Dimension&N=dim&o='+str(dim_opts)+'&val='+str(self.params['dim']), '@(1e-4,10e4,1,'+str(self.params['scale'])+')$d=Scale', 'text$d=Center&N=center_display&val='+str(self.params['center']) ] ], ['r$N=bot_mini_box',['@selmul$d=Root node&N=fixed_display&o='+str(list(G.nodes())+['None']), ['c$N=sub_box_layout', ['@dd$d=Weight&o='+str(ls_weights+['None'])+'&val='+str(self.params['weigth']), ['r$N=sub_subrow',['@(1,10e4,1,'+str(self.params['iterations'])+')$d=Iterations', '@dd$N=kmet&d=k&o='+str(ls_weights)+'&val='+str(self.params['k']), '@(0,1e4,1,0)$N=kfloat&d=k' ] ], '@togs$d=Prog&o=["neato", "twopi", "fdp", "dot", "circo"]&val='+str(self.params['prog']) ] ] ] ] ] ] ] ] ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.fixed_display.value = [str(self.params['fixed'])] self.observe(self.update_display) self.observe(self.update_value) self.layout.observe(self.on_layout_change) self.update_display() #Can inherit a target when not used as a widget self.update_value()
def __init__(self, data, funcs=None, min=0, max=100, step=None, low=None, high=None, **kwargs): self.halt_update = False if funcs is None: self.funcs = { 'raw': lambda x: x, 'zscore': lambda x: (x - np.mean(x)) / np.std(x), 'log': np.log, 'rank': lambda x: pd.DataFrame(x).rank().values.flatten(), 'inv': lambda x: -x } else: self.funcs = funcs self._df = data.apply(self.categorical_to_num) if min is None: min = self._df.min().values[0] if max is None: max = self._df.max().values[0] if step is None: step = (max - min) / 100. if low is None: low = min if high is None: high = max self.halt_update = False self.output = None dash = [ 'c$N=df_scaler', [ '@(' + str(min) + ', ' + str(max) + ', ' + str(step) + ', (' + str(low) + ', ' + str(high) + '))$N=scale_slider&d=Scale', [ 'r$N=main_row', [ '@dd$d=Apply&N=dd_sel&val=raw&o=' + str(list(self.funcs.keys())), '@True$N=scale_chk&d=Scale' ] ] ] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) self.dd_sel.target.layout.width = "100%" self.scale_chk.widget.layout.padding = "0.25em" self.observe(self.update) self.update()
def __init__(self, **kwargs): self.init_funcs() self.functions = {} dash = [ "@selmul$d=Wikipedia test 2D&n=func_sel&o=" + str(list(self._all_funcs.keys())) ] Dashboard.__init__(self, dash, **kwargs) self.func_sel.value = tuple(self._all_funcs.keys()) self.observe(self.update) self.update()
def __init__(self, ros_step=1, ras_step=1, sbt_step=1, lj_step=1, ras_range=(2, 4), ros_range=(2, 4), lj_range=(2, 4), sbt_range=(2, 4), **kwargs): self.functions = {} dash = [ 'r$N=multim_test', [[ "c$n=ras_col", [ "[False]$d=Rastrigin&n=ras_tog", "(2,500,1," + str(ras_range) + ")$d=Dim range&n=ras_dim", "(1,99,1," + str(ras_step) + ")$d=Dim range&n=ras_step", ] ], [ "c$n=ros_col", [ "[False]$d=Rosenbrock&n=ros_tog", "(2,500,1," + str(ras_range) + ")$d=Dim range&n=ros_dim", "(1,99,1," + str(ros_step) + ")$d=Dim range&n=ros_step", ] ], [ "c$n=sbt_col", [ "[False]$d=StyblinskiTang&n=sbt_tog", "(2,500,1," + str(ras_range) + ")$d=Dim range&n=sbt_dim", "(1,99,1," + str(ros_step) + ")$d=Dim range&n=sbt_step", ] ], [ "c$n=lj_col", [ "[False]$d=LennardJones&n=lj_tog", "(2,500,1," + str(ras_range) + ")$d=Dim range&n=lj_dim", "(1,99,1," + str(ros_step) + ")$d=Dim range&n=lj_step", ] ], "[True]$d=DeVilliersGlasser02&n=dv2_tog", "btn$d=Update&n=update_btn"] ] Dashboard.__init__(self, dash, **kwargs) self.update_btn.observe(self.update) self.update()
def __init__(self, G, default_params=None, **kwargs ): if default_params is None: self.default_params = LayoutParams.default_layout_params() else: self.default_params = default_params self._G = G.copy() dash = ['c$N=layout_calculator',[LayoutParams(G, name='layout_params'),'btn$N=button&d=Run']] Dashboard.__init__(self, dash, **kwargs) self.button.observe(self.update) self.update()
def __init__(self, G, default_params=None, **kwargs): if default_params is None: self.default_params = LayoutParams.default_layout_params() else: self.default_params = default_params self._G = G.copy() dash = [ 'c$N=layout_calculator', [LayoutParams(G, name='layout_params'), 'btn$N=button&d=Run'] ] Dashboard.__init__(self, dash, **kwargs) self.button.observe(self.update) self.update()
def __init__(self, data, mode='interactive', **kwargs): self._data = data dash = ['c$N=tooltip', ['###Tolltip$N=title', '@selmul$n=tooltip_cols&d=Tooltip info&o='+str(tuple(data.columns.values)) ] ] self.output = data.copy() Dashboard.__init__(self, dash, mode=mode, **kwargs) self.tooltip_cols.value = tuple(data.columns.values) self.observe(self.update) self.update()
def __init__(self, df,description='DataFrame', **kwargs): self.df = df self.output = None dash =['r$N=df_slicer', [ '##'+description+'$N=description_text', ArraySlicer(df.index.values, name='index_slicer', description='index'), ArraySlicer(df.columns.values, name='columns_slicer', description='columns') ] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) self.observe(self.update) self.update()
def __init__(self, metaparam_dash, control_dash, title, **kwargs): self._metaparam_dash = metaparam_dash self._control_dash = control_dash dash = [ 'c$N=color_widget', [['r$N=row_title', ['#' + title + '$N=title']], ['r$N=row_controls', [self._metaparam_dash, self._control_dash]], 'HTML$n=fig_widget'] ] self.pal = [] self.cmap = self._init_mutable_colormap() Dashboard.__init__(self, dash, **kwargs) self.init_fig_widget()
def __init__(self, title='Axis', mode='interactive', **kwargs): ticks = Ticks(name='ticks', mode='interactive') non_ticks = AxisNonTick(name='non_ticks', mode='interactive') slider = RangeSlider(name='rangeslider', mode='interactive') dash = [ 'c$N=axis_parameters', [ '##' + title + '$n=axis_title', ticks, non_ticks, slider, 'togs$n=buttons&o=["Ticks","Generic","Slider"]&val=Generic&mode=passive' ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.buttons.observe(self.buttons_logic) self.buttons_logic()
def __init__(self, data, mode='interactive', **kwargs): self._data = data dash = [ 'c$N=tooltip', [ '###Tolltip$N=title', '@selmul$n=tooltip_cols&d=Tooltip info&o=' + str(tuple(data.columns.values)) ] ] self.output = data.copy() Dashboard.__init__(self, dash, mode=mode, **kwargs) self.tooltip_cols.value = tuple(data.columns.values) self.observe(self.update) self.update()
def __init__(self,title='Axis',mode='interactive', **kwargs): ticks = Ticks(name='ticks',mode='interactive') non_ticks = AxisNonTick(name='non_ticks',mode='interactive') slider = RangeSlider(name='rangeslider',mode='interactive') dash = ['c$N=axis_parameters',['##'+title+'$n=axis_title', ticks, non_ticks, slider, 'togs$n=buttons&o=["Ticks","Generic","Slider"]&val=Generic&mode=passive' ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs) self.buttons.observe(self.buttons_logic) self.buttons_logic()
def __init__(self,metaparam_dash,control_dash,title, **kwargs): self._metaparam_dash = metaparam_dash self._control_dash = control_dash dash = ['c$N=color_widget', [ ['r$N=row_title',['#'+title+'$N=title']], ['r$N=row_controls',[self._metaparam_dash, self._control_dash]], 'HTML$n=fig_widget' ] ] self.pal = [] self.cmap = self._init_mutable_colormap() Dashboard.__init__(self, dash, **kwargs) self.init_fig_widget()
def __init__(self, default_params=None, **kwargs): if default_params is None: self.params = self.default_matrix_params() else: self.params = default_params dash = [ 'c$N=matrix_params', [ '###Matrix params$N=matparams_title', [ 'r$N=body_box', [[ 'c$N=mp_num_box', [ '@(-50.,50.,1.,' + str(float(self.params['norm_min'])) + ')$N=norm_min&d=Rescale min', '@(-50.,50.,1.,' + str(float(self.params['norm_max'])) + ')$N=norm_max&d=Rescale max', '@[-5e5,2e10,1.,' + str(float(self.params['clip_min'])) + ']$N=clip_min&d=Clip min', '@[-5e5,2e10,1.,' + str(float(self.params['clip_max'])) + ']$N=clip_max&d=Clip max' ] ], [ 'c$N=mp_target_box', [[ '@sel$N=target_selector&d=Transform matrix&o=' + str(self.get_target_options()) + '&val=' + str(self.params['target'][0][0]) ], ['r$N=buttonbox', ['btn$d=Add', 'btn$d=Delete']], [ '@texta$N=target_display&val=' + str(self.params['target']) ]] ]] ] ] ] Dashboard.__init__(self, dash, **kwargs) self.add.observe(self.on_add_clicked) self.delete.observe(self.on_del_clicked) self.observe(self.update) self.update()
def __init__(self, bordercolor='#444', visible=False, thickness=0.15, bgcolor='#fff', borderwidth=0, **kwargs): dash = ['c$N=range_slider_plotly',['###Slider$N=title_slider',['r$N=row_1',['@cp$n=bgcolor&d=Color&val='+bgcolor,'@cp$d=Border&n=bordercolor&val='+bordercolor]], ['r$N=row_2',['@(0,50,1,'+str(borderwidth)+')$d=Border width&N=borderwidth', '@(0.,1.,0.05,'+str(thickness)+')$d=Thickness&N=thickness']], ['@'+str([visible])+'$d=Visible&n=slider_visible'] ] ] Dashboard.__init__(self,dash,**kwargs)
def __init__(self,title='Font',family='Verdana', size=12, color='black', mode='interactive', **kwargs): fonts = matplotlib.font_manager.get_fontconfig_fonts() font_names = [matplotlib.font_manager.FontProperties(fname=fname).get_name() for fname in fonts] dash = ['c$n=font_manager',['###'+title+'$n=title', '@select$d=Family&o='+str(font_names)+'&val='+family, '@(1,50,1,'+str(size)+')$d=Size', '@cpicker$d=Color&val='+color ] ] Dashboard.__init__(self, dash, **kwargs) self.family.widget.layout.width = "20em" self.color.widget.layout.width = "20em" self.family.target.layout.width = "100%" self.color.target.layout.width = "100%"
def __init__(self, objfunc, x0=None, max_reads=10000000, niter=100, T=1.0, stepsize=0.5, minimizer_kwargs=None, take_step=None, accept_test=None, callback=None, interval=50, disp=False, niter_success=None, **kwargs): def false(**kwargs): return False def true(**kwargs): return True self._outer_accept_test = true if accept_test is None else accept_test self.minimizer_kwargs = minimizer_kwargs self.take_step = take_step self.pot_func = objfunc self.x0 = x0 self.best_pos_so_far = None self.best_so_far = 1e20 self._ext_callback =lambda x,val,accept: False if callback is None else callback self._run_callback = false self.epoch=0 niter_success = 0 if niter_success is None else niter_success strats = ['best1bin','best1exp','rand1exp','randtobest1exp','best2exp','rand2exp','randtobest1bin','best2bin','rand2bin','rand1bin'] dash = ['r$N=differential_evolution',["##Basin-hopping$n=title", ['r$N=controls_row',[["c$N=first_row",["(0,100000,1,"+str(niter)+")$d=Niter&n=max_epoch", "(0,1e8,1,"+str(max_reads)+")$d=Max reads", "(0,1e4,1,"+str(int(niter_success))+")$d=niter_success"]], ["c$N=sec_row",["(0.,10000.,.01,"+str(T)+")$d=T", "(0,1e8,1,"+str(interval)+")$d=Interval", "(0.,100.,0.01,"+str(stepsize)+")$d=Stepsize"] ], ["c$n=btn_col",["["+str(bool(disp))+"]$d=Disp","btn$d=Run&n=run_btn"]]] ]]] Dashboard.__init__(self,dash,**kwargs) self.run_btn.observe(self.run)
def __init__(self, l=80, r=80, b=80, t=100, pad=0, autoexpand=True, title='Margin', **kwargs): dash = ['c$n=margin_dash',['###'+title+'$N=margin_title', ['r$N=margin_row1',['@(0,250,1,'+str(l)+')$d=l','@(0,250,1,'+str(r)+')$d=r','@(0,250,1,'+str(b)+')$d=b']], ['r$N=margin_row2',['@(0,350,1,'+str(t)+')$d=t','@(0,250,1,'+str(pad)+')$d=pad','@'+str([autoexpand])+'$d=autoexpand']] ] ] Dashboard.__init__(self, dash, **kwargs) for slider in ['l','r','b','t','pad']: getattr(self,slider).target.continuous_update = False
def __init__(self, df, description='DataFrame', **kwargs): self.df = df self.output = None dash = [ 'r$N=df_slicer', [ '##' + description + '$N=description_text', ArraySlicer(df.index.values, name='index_slicer', description='index'), ArraySlicer(df.columns.values, name='columns_slicer', description='columns') ] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) self.observe(self.update) self.update()
def __init__(self,description='Cmap', **kwargs): dash = ['c$N=cmap_picker', [ ['r$N=display_col',['btn$N=cmap_btn&d='+description, 'HTML$N=mini_display']], ['c$N=palette_col', [MasterPalette(name='master_palette',mode='interactive'),'btn$d=Close&N=close_btn'] ] ] ] Dashboard.__init__(self, dash, **kwargs) self.mini_display.target.layout.width = "20em" self.mini_display.target.layout.height = "2em" self.palette_col.visible = False self.cmap = self.master_palette.cmap self.pal = self.master_palette.pal self.cmap_btn.observe(self._on_cmap_click) self.close_btn.observe(self._on_close_click) self._on_close_click()
def __init__(self, data, funcs=None, min=0, max=100, step=None, low=None, high=None, **kwargs): if funcs is None: self.funcs = {'raw':lambda x: x, 'zscore': lambda x: (x-np.mean(x))/np.std(x), 'log': np.log, 'rank':lambda x: pd.DataFrame(x).rank().values.flatten(), 'inv': lambda x: -x, 'cut':lambda x: pd.cut(x,[-1001, 0.1,0.3, 0.6, 0.8, 1.0,1.5, 3.0, 6.0, 12, 1001],labels=False) } else: self.funcs = funcs self._df = data.apply(self.categorical_to_num) if min is None: min = self._df.min().values[0] if max is None: max = self._df.max().values[0] if step is None: step = (max-min)/100. if low is None: low = min if high is None: high = max self.output = None dash = ['c$N=df_scaler', ['@('+str(min)+', '+str(max)+', '+str(step)+', ('+str(low)+', '+str(high)+'))$N=scale_slider&d=Scale', ['r$N=main_row',['@dd$d=Apply&N=dd_sel&val=raw&o='+str(list(self.funcs.keys())),'@True$N=scale_chk&d=Scale']] ] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) self.dd_sel.target.layout.width = "100%" self.scale_chk.widget.layout.padding = "0.25em" self.observe(self.update) self.update()
def __init__(self, objfunc, strategy='best1bin', maxiter=1000, popsize=15, max_reads=150000, tol=0.01, mutation=(0.5, 1), recombination=0.7, seed=160290, callback=None, disp=False, polish=True, init='latinhypercube', **kwargs): def false(): return False self.pot_func = objfunc self.best_pos_so_far = None self.best_so_far = 1e20 self._ext_callback =lambda x,conv: False if callback is None else callback self._run_callback = false self.epoch=0 strats = ['best1bin','best1exp','rand1exp','randtobest1exp','best2exp','rand2exp','randtobest1bin','best2bin','rand2bin','rand1bin'] dash = ['r$N=differential_evolution',["##Differential evolution$n=title", ['r$N=controls_row',[["c$N=first_row",["(0,100000,1,"+str(maxiter)+")$d=Maxiter&n=max_epoch", "(0,1e8,1,"+str(max_reads)+")$d=Max reads", "(1,1e5,1,"+str(int(popsize))+")$d=Popsize"]], ["c$N=sec_row",["(0.,10.,.01,"+str(tol)+")$d=Tol", "(0.,100.,0.1,"+str(mutation)+")$d=Mutation", "(0,1e8,1,"+str(recombination)+")$d=Recombination"] ], ["c$N=third_row",["(0,1000000,1,"+str(seed)+")$d=seed", "dd$d=Strategy&o="+str(strats)+"&val="+str(strategy), "togs$d=Init&o=['latinhypercube','random']", ] ],["c$n=btn_col",["["+str(bool(polish))+"]$d=Polish","btn$d=Run&n=run_btn"]]] ]]] Dashboard.__init__(self,dash,**kwargs) self.run_btn.observe(self.run)
def __init__(self, panel, description='Panel', mode='interactive',output_mode=None, **kwargs): self.panel = panel dash = ['c$N=df_slicer', [ '##'+description+'$N=pts_description_text', ['r$N=mode_column',['@togs$N=index_tog&d=index&o=["items","major_axis","minor_axis"]&val=major_axis', '@rad$N=output_mode&d=Output&val=series&o=["series","matrix"]'] ], PanelSlicer(panel, name='panel_slicer', description='') ] ] Dashboard.__init__(self, dash, mode=mode, **kwargs ) if output_mode == 'series': self.output_mode.value = 'series' self.output_mode.visible = False elif output_mode == 'matrix': self.output_mode.value = 'matrix' self.output_mode.visible = False self.observe(self.update) self.update()
def init_filters(self): self.params = list(sorted(self.mapper_dict.keys())) filters = [] for param in self.params: kwargs = self.mapper_dict[param] if 'default_color' in kwargs.keys(): filters += [PlotCmapFilter(self._data, name=param,description=param, mode='interactive', **kwargs)] else: filters += [PlotDataFilter(self._data, name=param, description=param, mode='interactive', **kwargs)] marker = [Dashboard(['dd$d=Marker type&val=circle&o='+str(self._marker_opts)], name='marker' )] filters += marker return filters
def __init__(self,objfunc,select='Basin hopping',fractal_kwargs={},basinhopping_kwargs={},diffevo_kwargs={},**kwargs): differential_evolution = DifferentialEvolution(objfunc,name='differential_evolution',**diffevo_kwargs) basin_hopping = BasinHopping(objfunc,name='basin_hopping',**basinhopping_kwargs) dash = ["c$N=optimizer_dash",[differential_evolution, basin_hopping, ["r$n=btn_row", ["togs$N=algo_sel&o=['Differential evolution','Basin hopping']&val="+str(select), 'btn$d=Run&n=run_btn'] ] ] ] Dashboard.__init__(self,dash,**kwargs) self.algos = ['differential_evolution','basin_hopping'] self._last_eval = select.lower().replace(' ','_') self.algo_sel.observe(self.update_layout) self.run_btn.observe(self.run) self.update_layout()
def __init__(self, default_params=None, metrics=None, target=None, **kwargs): if default_params is None: params = self.default_graph_params() else: params = default_params if metrics is None: metrics = self.default_node_metrics() if target is None: dict_target_attrs = self.default_target_attributes() else: dict_target_attrs = target options = {'Mst': 'mst', 'Pmfg': 'pmfg', 'Full Matrix': 'full'} dash = [ 'c$N=graph_params', [ '###Graph params$N=gaphparams_title', '@togs$d=Graph type&o=' + str(options) + '&val=' + str(params['graph_type']), [ 'r$N=gparams_row', [ '@[0.,50e10,1,' + str(params['threshold']) + ']$N=threshold&d=Abs val threshold', '@False$N=inverted&d=Invert distance' ] ], '@selmul$d=Metrics&o=' + str(metrics), '@dd$N=target_attr&d=Target attribute&o=' + str(dict_target_attrs) + '&val=' + str(params['target_attr']) ] ] Dashboard.__init__(self, dash, **kwargs) self.metrics.value = tuple(metrics)
def __init__(self, title='', html_title='Layout', paper_bgcolor='#fff', aspectmode='auto', plot_bgcolor="#fff", height=680, width=1450, mode='interactive', **kwargs): aspectmode_opts = ["auto", "cube", "data", "manual"] titlefont = FontManager(name='titlefont', mode='interactive', title='Title font') layout_dash = [ 'r$n=main_row', [ [ 'c$N=layout_params', [ '##' + html_title + '$N=layout_title', '@text$d=Title&val=' + title, '@cp$d=Paper bgcolor&val=' + paper_bgcolor, '@(0,3840,1,' + str(height) + ')$d=height', '@(0,2160,1,' + str(width) + ')$d=width', '@cp$n=plot_bgcolor&d=Plot bgcolor&val=' + plot_bgcolor, #'dd$d=Aspectmode&val='+aspectmode+'&o='+str(aspectmode_opts) ] ], titlefont ] ] layout_params = Dashboard(dash=layout_dash, name='layout_params', mode=mode) for slider in ['width', 'height']: getattr(layout_params, slider).target.continuous_update = False xaxis = Axis(name='xaxis', mode='interactive') yaxis = Axis(name='yaxis', mode='interactive') margin = Margin(name='margin', mode='interactive') ToggleMenu.__init__(self, children=[xaxis, yaxis, margin, layout_params], **kwargs) self.observe(self.update)
def __init__(self, data, mask, strf='%a\n%d\n%h\n%Y', fontsize=20, pct_space=0.1, **kwargs ): self.data = data self.mask = mask if self.is_time_array(data): start = 'HTML$N=start&val='+pd.to_datetime(self.data[0]).strftime(strf) end ='HTML$N=end&val='+pd.to_datetime(self.data[-1]).strftime(strf) strf = '@text$N=strf&val='+strf #self.start = TimeDisplay(datetime=pd.to_datetime(self.data[0]), strf=self.strf.value) #self.end = TimeDisplay(datetime=pd.to_datetime(self.data[-1]), strf=self.strf.value) else: start = 'HTML$N=start&val='+str(self.data[0]) end = 'HTML$N=end&val='+str(self.data[-1]) strf = strf+'$N=strf&v=0' plot = 'HTML$N=plot' dash = ['c$N=AxisPlot', [ ['r$N=plot_box',[start, plot, end]], ['r$N=buttons_row',['@btn$d=Options&N=opt_button_open']], ['c$N=opt_box&v=0',[ ['r$N=opt_row_1',['@(1,25,1,18)$d=Font size', '@rad$N=vertical&d=Orient&o=["horizontal","vertical"]', strf, '@(0.,1.,0.02,0.1)$N=pct_space&d=Label spacing', ['c$N=mini_box',['@(1.,100.,0.05,8.75)$N=img_height&d=Height', '@(1.,100.,0.05,50.)$N=img_width&d=Width'] ] ] ], ['r$N=opt_row_2',['@btn$d=Cmap&N=cmap_button_open','@btn$d=Close&N=opt_button_close'] ] ] ], ['c$N=cmap_box&v=0',[MasterPalette(name='palette', mode='interactive'), '@btn$d=Close&N=cmap_button_close'] ] ] ] Dashboard.__init__(self, dash, **kwargs) for opt in self.palette.buttons.target.options.values(): setattr(getattr(getattr(self.palette,opt),'as_cmap'),'value',True) self.plot.value = self.plot_axis(data=self.data, idx=self.mask, cmap=self.palette.cmap, strf=self.strf.value, fontsize=self.font_size.value, pct_space=self.pct_space.value ) self.opt_button_open.observe(self._on_optopen_click) self.opt_button_close.observe(self._on_optclose_click) self.cmap_button_open.observe(self._on_cmopen_click) self.cmap_button_close.observe(self._on_cmclose_click) self.observe(self._trigger_update) self._trigger_update() self.update()
def __init__(self, data, start=0, end=-1, step=1, display='sliders', slice_mode='single', description='Slicer', strf='%d\n%h\n%Y\n%T', **kwargs): self.strf = strf if AxisPlotLight.is_time_array(data): st = str(self.strf) st = st.replace('\n',' ') time_data = [pd.to_datetime(x).strftime(st) for x in data] dd_sel = ['@sel$N=dd_selector&o='+str(list(time_data))] sel_sli = ['@selslider$N=sel_sli&o='+str(list(time_data))] self._data = time_data self._ast_vals = False elif isinstance(data[0],str): dd_sel = ['@sel$N=dd_selector&o='+str(list(data))] sel_sli = ['@selslider$N=sel_sli&o='+str(list(data))] self._data = data self._ast_vals = False else: self._data = [str(x) for x in data] dd_sel = ['@sel$N=dd_selector&o=["'+str(list(data)[0])+'"]'] sel_sli = ['@selslider$N=sel_sli&o=["'+str(list(data)[0])+'"]'] self._ast_vals = True if end==-1: end = len(data) self.idx = np.ones(len(data),dtype=bool) plot = AxisPlotLight(data,self.idx, name='plot',strf=strf) dash = ['c$N=array_slicer', [['###'+description+'$N=title_slicer'], ['r$N=plot_row',[plot]], dd_sel, sel_sli, ['r$N=controls_row',[['r$N=columns_mode_row',['@togs$N=slice_mode&o=["single", "slice"]&val='+str(slice_mode), ]], ['c$N=sliders_col',['@('+str(-len(data)+1)+','+str(end)+',1,'+str(start)+')$N=start_slider&d=Start', '@('+str(-len(data)+1)+','+str(end)+',1,'+str(end)+')$N=end_slider&d=End', '@(1,'+str(len(data)-1)+',1,'+str(step)+')$N=step_slider&d=Step' ] ], ] ] ] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) if self._ast_vals: self.dd_selector.target.options = [str(x) for x in data] self.sel_sli.target.options = [str(x) for x in data] self.sel_sli.target.continuous_update=False self.start_slider.target.continuous_update=False self.dd_selector.target.layout.width = "12em" self.dd_selector.observe(self._link_dropdown) self.sel_sli.observe(self._link_sel_sli) self.start_slider.observe(self._link_start_sli) self.observe(self.update) self.update() self.data = self._data.copy()
def __init__(self, titlefont={'family':'Verdana'}, title='', hoverformat='', zeroline=True, fixedrange=True, showline=True, showgrid=True, showexponent='all', mirror=False, categoryorder='trace', side='bottom', exponentformat='none', autorange=True, rangemode='normal', color='#444', zerolinecolor='#444', linecolor='#444', linewidth=1, zerolinewidth=1, position=0, gridwidth=1, mode='interactive', **kwargs ): col_font = ['c$N=col_font',[FontManager(name='titlefont',title='titlefont',mode='interactive')]] colors = ['c$n=colors_col',['@cp$d=Color&val='+color, '@cp$d=Linecolor&val='+linecolor, '@cp$n=zerolinecolor&d=Zeroline color&val='+zerolinecolor]] bools = ['c$n=bool_block',['@text$d=Title', #'@text$d=Title format&n=titleformat', ['r$n=brow_1',['@'+str([zeroline])+'$d=Zeroline','@'+str([fixedrange])+'$d=Fixedrange']], ['r$n=brow_2',['@'+str([showline])+'$d=Showline','@'+str([showgrid])+'$d=Showgrid']], ] ] sliders = ['c$n=slider_row_axis',['@(0,50,1,'+str(linewidth)+')$d=linewidth', '@(0,50,1,'+str(zerolinewidth)+')$d=zerolinewidth', '@(0.,1.,0.05,'+str(position)+')$d=position', '@(0,50,1,'+str(gridwidth)+')$d=gridwidth' ] ] showexponent_opts = ["all","first","last","none" ] mirror_opts = {'True': True, "ticks":"ticks",'False': False , "all":"all" , "allticks":"allticks"} categoryorder_opts = ["trace" , "category ascending" , "category descending" , "array" ] side_opts = ["top" , "bottom" , "left" , "right" ] exponentformat_opts = [ "none" , "e" , "E" , "power" , "SI" , "B" ] autorange_opts = {'True': True , 'False': False , "reversed":"reversed" } rangemode_opts = ["normal" , "tozero" , "nonnegative"] enum_opts = ['r$n=enum_row',[['c$n=eo_c1',['@dd$d=showexponent&o='+str(showexponent_opts)+'&val='+str(showexponent), '@dd$d=exponentformat&o='+str(exponentformat_opts)+'&val='+str(exponentformat), '@dd$d=categoryorder&o='+str(categoryorder_opts)+'&val='+str(categoryorder), '@dd$d=side&o='+str(side_opts)+'&val='+str(side)]], ['c$n=eo_c2',['@dd$d=mirror&o='+str(mirror_opts), '@dd$d=autorange&o='+str(autorange_opts), '@dd$d=rangemode&o='+str(rangemode_opts)+'&val='+str(rangemode)]] ] ] dash = ['c$N=non_tick_axis',['###Generic parameters$N=non_ticks_title', ['r$n=non_tick_axis_params',[bools,col_font,enum_opts, sliders, colors]] ] ] Dashboard.__init__(self, dash,mode=mode, **kwargs) self.autorange.value = autorange self.rangemode.value = rangemode
def __init__(self, data, mapper_dict=None, marker_opts=None, **kwargs): if marker_opts is None: self._marker_opts = [ 'circle', 'square', 'asterisk', 'circle_cross', 'circle_x', 'square_cross', 'square_x', 'triangle', 'diamond', 'cross', 'x', 'inverted_triangle', ] else: self._marker_opts = marker_opts self._data = data if isinstance(self._data, pd.DataFrame): if isinstance(self._data.index.values[0], (list, tuple, str)): old = self._data.index ix = [str(x) for x in self._data.index.values] self._data.index = ix self._data = self._data.reset_index() self._data.index = old else: ix = self._data.index self._data = self._data.reset_index() self._data.index = ix if mapper_dict is None: self.mapper_dict = self.get_default_mapper_dict() else: self.mapper_dict = mapper_dict self.params = list(sorted(self.mapper_dict.keys())) self.halt_update = True self.memory = {} cm = True da = True for p in self.params: if 'default_color' in self.mapper_dict[p].keys() and cm: cmap_filter = PlotCmapFilter(self._data, name='cmap_filter', description=p, mode='interactive', **self.mapper_dict[p]) cm = False self._firstcolor = p self._color_keys = [p] self.memory[p] = cmap_filter.selector_vals elif da: data_filter = PlotDataFilter(self._data, name='data_filter', description=p, mode='interactive', **self.mapper_dict[p]) da = False self._firstdata = p self.memory[p] = data_filter.selector_vals elif not da and not cm: break marker = Dashboard( ['dd$d=Marker type&val=circle&o=' + str(self._marker_opts)], name='marker') dash = [ 'c$N=plot_mapper', [ 'dd$d=Attribute&o=' + str(self.params), marker, cmap_filter, data_filter ] ] Dashboard.__init__(self, dash, **kwargs) self._current = self.attribute.value self.init_data() self.observe(self.update) self.attribute.observe(self._update_dropdown) self.halt_update = False #for p in self.params: # self.attribute.value = p self._update_dropdown() self.update()
def __init__(self, data, start=0, end=-1, step=1, display='sliders', slice_mode='single', description='Slicer', strf='%d\n%h\n%Y\n%T', **kwargs): self.strf = strf self.halt_update = False if AxisPlotLight.is_time_array(data): st = str(self.strf) st = st.replace('\n', ' ') time_data = [pd.to_datetime(x).strftime(st) for x in data] dd_sel = ['@sel$N=dd_selector&o=' + str(list(time_data))] sel_sli = ['@selslider$N=sel_sli&o=' + str(list(time_data))] self._data = time_data self._ast_vals = False elif isinstance(data[0], str): dd_sel = ['@sel$N=dd_selector&o=' + str(list(data))] sel_sli = ['@selslider$N=sel_sli&o=' + str(list(data))] self._data = data self._ast_vals = False else: self._data = [str(x) for x in data] dd_sel = ['@sel$N=dd_selector&o=["' + str(list(data)[0]) + '"]'] sel_sli = ['@selslider$N=sel_sli&o=["' + str(list(data)[0]) + '"]'] self._ast_vals = True if end == -1: end = len(data) self.idx = np.ones(len(data), dtype=bool) plot = AxisPlotLight(data, self.idx, name='plot', strf=strf) dash = [ 'c$N=array_slicer', [['###' + description + '$N=title_slicer'], ['r$N=plot_row', [plot]], dd_sel, sel_sli, [ 'r$N=controls_row', [ [ 'r$N=columns_mode_row', [ '@togs$N=slice_mode&o=["single", "slice"]&val=' + str(slice_mode), ] ], [ 'c$N=sliders_col', [ '@(' + str(-len(data) + 1) + ',' + str(end) + ',1,' + str(start) + ')$N=start_slider&d=Start', '@(' + str(-len(data) + 1) + ',' + str(end) + ',1,' + str(end) + ')$N=end_slider&d=End', '@(1,' + str(len(data) - 1) + ',1,' + str(step) + ')$N=step_slider&d=Step' ] ], ] ]] ] Dashboard.__init__(self, dash, mode='interactive', **kwargs) if self._ast_vals: self.dd_selector.target.options = [str(x) for x in data] self.sel_sli.target.options = [str(x) for x in data] self.sel_sli.target.continuous_update = False self.start_slider.target.continuous_update = False self.dd_selector.target.layout.width = "12em" self.dd_selector.observe(self._link_dropdown) self.sel_sli.observe(self._link_sel_sli) self.start_slider.observe(self._link_start_sli) self.observe(self.update) self.update() self.data = self._data.copy()