Example #1
0
    def get_layout(self):
        # table_panel, con_panel, uncon_panel, plot_panel = self.get_each_module()
        con_panel, uncon_panel, plot_panel_1, plot_panel_2, his_panel = self.get_each_module(
        )
        desc = Div(text=open(self.config['description_path']).read(),
                   sizing_mode="stretch_width")
        l1 = layout([[
            uncon_panel,
            Spacer(width=20), con_panel,
            Spacer(width=20), plot_panel_1,
            Spacer(width=20), plot_panel_2,
            Spacer(width=20), his_panel
        ]])
        # l1 = layout([[table_panel, Spacer(width=20),
        #               uncon_panel, Spacer(width=20),
        #               con_panel, Spacer(width=20),
        #               plot_panel, Spacer(width=20)]])
        # l2 = layout([[fig3]], sizing_mode='fixed')

        tab1 = Panel(child=l1, title="This is Tab 1")
        # tab2 = Panel(child=l2, title="This is Tab 2")
        # tabs = Tabs(tabs=[tab1, tab2])
        tabs = Tabs(tabs=[tab1])
        l = layout([[desc], [tabs]], sizing_mode="scale_both")
        curdoc().add_root(l)
        curdoc().title = "AI Explanation Tool"
Example #2
0
    def layout(self):
        panels = [None, None]

        # Main panel: data
        panels[0] = Panel(
            child=row(
                column(
                    self.data.layout(),
                    Spacer(height=10),
                    self.specials.layout(),
                    width=160,
                ),
                Spacer(width=10),
                column(
                    self.xaxis.layout([self.yaxis.widget]),
                    Spacer(height=10),
                    self.size.layout([self.color.widget]),
                ),
            ),
            title="data",
        )

        # Secondary panel: appearance
        panels[1] = Panel(child=Div(), title="appearance",)

        tabs = Tabs(tabs=panels)

        header = Div(
            text=f"""<img src="{LOGO_URL}"></img>""",
            css_classes=["header-image"],
            width=320,
            height=100,
        )

        return row(column(header, tabs), Spacer(width=10), self.plot)
Example #3
0
def _show_bofigure(axs, widgets, ncols=1, output='notebook', **kwargs):
    if output.lower() == 'notebook':
        boplt.output_notebook()
        notebook_handle = True
    elif output.lower() == 'file':
        import tempfile
        boplt.output_file(tempfile.mktemp('.html'))
        notebook_handle = False
    else:
        doc = boplt.curdoc()
        notebook_handle = False

    raw_tools = []
    for ax in axs:
        raw_tools = raw_tools + ax.toolbar.tools
        ax.x_range = axs[0].x_range

    for ax in axs[:-1]:
        ax.xaxis.visible = False

    axs[-1].plot_height += 15

    if kwargs.pop('RangeSelect', False):
        rs = make_RangeSelect(axs)
    else:
        rs = Spacer(width=1, height=1)

    if kwargs.pop('Cursor', False):
        button = make_cursors(axs, )
    else:
        button = None

    toolbar = ToolbarBox(tools=raw_tools,
                         logo=None,
                         toolbar_location='right',
                         merge_tools=True,
                         sizing_mode='stretch_both')

    sizing_mode = None
    if button is None:
        if rs is None:
            col = column(*axs)  #, sizing_mode='scale_width')
        else:
            col = column(*axs, rs)  #, sizing_mode='scale_width')
    else:
        if rs is None:
            col = column(button, *axs)  #, sizing_mode='scale_width')
        else:
            col = column(button, *axs, rs)  #, sizing_mode='scale_width')

    #layout = row(col, Spacer(width=40, height=300),toolbar, sizing_mode='stretch_both')
    layout = row(col, Spacer(width=40, height=300), toolbar)

    if output.lower() in ('notebook', 'file'):
        return boplt.show(layout, notebook_handle=notebook_handle), layout, axs
    else:
        doc.add_root(layout)
        return None
Example #4
0
 def _init_set_marker(self):
     self.marker_button = Button(label=u"Set", button_type="default", width=80, height=31, disabled=True)
     self.event_code_input = TextInput(value="8", title="Event code:", width=80, disabled=True)
     self.event_code_input.on_change('value', self._check_marker_value)
     self.marker_button.on_click(self._set_marker)
     return column([Spacer(width=170, height=5),
                   row([self.event_code_input,
                       column(Spacer(width=50, height=19), self.marker_button)], height=50, width=170)],
                   width=170, height=50, sizing_mode='fixed'
                   )
Example #5
0
def showGridPlot():
    # Create plots
    p1 = irisPlot("petal_width", "petal_length")
    p2 = irisPlot("sepal_width", "sepal_length")
    p3 = simplePlot()
    p4 = logAxisPlot()
    p5 = sliderPlot()
    p6 = plotColorsAndSizes()
    p7 = stepLinePlot()
    p8 = multipleLinesPlot()
    p9 = missingPointsPlot()
    p10 = stackedLinesPlot()
    p11 = vbarPlot()
    p12 = hbarPlot()
    p13 = rectanglesPlot()
    p14 = rotatedRectanglesPlot()
    p15 = hexTilePlot()
    p16 = hexBinPlot()
    p17 = directedAreaPlot()
    p18 = stackedAreaPlot()
    p19 = colorMappedImagePlot()
    p20 = dateTimePlot()
    p21 = interactiveLegend()
    p22 = sliderPowerPlot()
    p23 = transferSelection()

    # Define column and row spacers
    # Spacer: margin - property type: Tuple ( Int , Int , Int , Int )
    # Allows to create additional space around the component.
    # The values in the tuple are ordered as follows - Margin-Top, Margin-Right, Margin-Bottom and Margin-Left
    sp1 = Spacer(margin=(10, 10, 10, 10))
    sp2 = Spacer(margin=(10, 10, 10, 10))
    rowsp = Spacer(margin=(10, 800, 10, 800))

    # Create a grid layout of plots
    plotLayout = layout([
        [p1, sp1, p2, sp2, p3],
        [rowsp],
        [p4, sp1, p5, sp2, p6],
        [rowsp],
        [p7, sp1, p8, sp2, p9],
        [rowsp],
        [p10, sp1, p11, sp2, p12],
        [rowsp],
        [p13, sp1, p14, sp2, p15],
        [rowsp],
        [p16, sp1, p17, sp2, p18],
        [rowsp],
        [p19, sp1, p20],
        [rowsp],
        [p21, sp1, p22],
        [rowsp],
        [p23],
    ])
    return json.dumps(json_item(plotLayout))
Example #6
0
    def __init__(self, data_file=None):

        # This is to have a default / test data file to show. But we probably
        # want to change this, or remove the default when we "release"!
        if data_file is None:
            deli_path = pathlib.Path(__file__).parent.absolute()
            data_file = deli_path / 'data' / 'TESS-Gaia-mini.csv'

        # The data file can be any file format that astropy.table can read:
        data = at.Table.read(data_file)
        dataset = data.to_pandas()

        # Things the user can plot - now the labels are the same as the table
        # column names! We may want to make these nicer for things like "ra"?
        parameters = OrderedDict((col, col) for col in sorted(dataset.columns))

        self.dataset = dataset

        # Instantiate the plots
        self.primary = PrimaryPlot(dataset, parameters)
        self.secondary = SecondaryPlot(self.primary)

        # Display things on the page
        inputs_left = column(
            self.primary.data.layout(),
            Spacer(height=10),
            self.primary.specials.layout(),
            width=160,
        )
        inputs_right = column(
            self.primary.xaxis.layout([self.primary.yaxis.widget]),
            Spacer(height=10),
            self.primary.size.layout([self.primary.color.widget]),
        )
        header = Div(
            text=f"""<img src="{LOGO_URL}"></img>""",
            css_classes=["header-image"],
            width=320,
            height=100,
        )
        inputs = column(header,
                        row(inputs_left, Spacer(width=10), inputs_right))
        layout = column(row(inputs, Spacer(width=10), self.primary.plot),
                        self.secondary.plot,)

        # Load and display the data
        self.primary.callback(None, None, None)

        # Go!
        curdoc().add_root(layout)
        curdoc().title = "delicatessen"
Example #7
0
    def __init__(self,
                 flexname: str = "Default",
                 name: str = "OvioSlit",
                 display=fakedisplay,
                 width=200):  # BokehOVIOSlit::__init__()
        """Initialize this class."""
        #super().__init__()
        # (wg-python-property-variables)
        self.display = display
        self.flexname = flexname  # the name of the instrument for this instance
        self.name = name  # the name of the device in this instrument
        self.wwidth = width  # display width for its Bokeh widgets
        self.slit = "20"  # initial condition
        self.state = 'undefined'  # haven't started yet
        self.lamp = 0  # the illumination lamp associated
        self.validp = False  # wake up in false position
        self.spacer = Spacer(width=self.wwidth, height=5, background='black')
        self.slitlamp = RadioGroup(
            labels=[f"Illuminator Off", f"Illuminator On"],
            active=0,
            height=50,
            #orientation='horizontal',
            width=self.wwidth)

        self.slitchoices = Select(title=f"OVIO Slits",
                                  value='20',
                                  options=self.oviodropdowns,
                                  width=self.wwidth)
        self.slitchoices.on_change(
            'value',
            lambda attr, old, new: self.update_dropdown(attr, old, new))
        self.slitlamp.on_change(
            'active',
            lambda attr, old, new: self.radio_handler(attr, old, new))
        self.send_state()  # set the initial state.
Example #8
0
    def get_std_parameter_tab_layout(self):
        """Return list of bokeh column layouts."""
        def pan_title(string):
            return string.split()[0].replace('_CTD', '')

        columns = []

        if self.multi_sensors:
            for params in zip(('x1', 'x2', 'x3'), ('x4', 'x5', 'x6'),
                              ('COMBO_TEMP', 'COMBO_SALT', 'COMBO_DOXY')):
                pans = []
                for p in params:
                    if p in self.figures:
                        tab_cols = []
                        if p in self.flag_widgets:
                            tab_cols.append(self.flag_widgets[p])
                        else:
                            tab_cols.append(Spacer(width=20, height=41))
                        tab_cols.append(self.figures[p])
                        tab = column(tab_cols)
                        pan = Panel(child=tab,
                                    title=pan_title(
                                        self.plot_parameters_mapping.get(p)
                                        or p))
                        pans.append(pan)
                columns.append(column([Tabs(tabs=pans)]))
        else:
            for p1 in ('x1', 'x2', 'x3'):
                columns.append(
                    column([self.flag_widgets[p1], self.figures[p1]]))

        return columns
Example #9
0
def statechart(metric, metricname):
    p = figure(x_axis_type='datetime',
               plot_height=400,
               sizing_mode='stretch_width',
               title=metricname,
               toolbar_location='above',
               tools=[
                   HoverTool(tooltips=[
                       ('Date', '@Date{%F}'),
                       ('Average ' + metricname, '@' + metric + '_avg{0,}'),
                       ('Daily ' + metricname, '@' + metric + '{0,}'),
                   ],
                             formatters={'@Date': 'datetime'})
               ])
    p.line(x='Date',
           y=metric,
           source=source,
           color='grey',
           legend_label='Daily')
    p.line(x='Date',
           y=metric + '_avg',
           source=source,
           color='blue',
           width=2,
           legend_label='7-day average')
    p.yaxis.formatter = NumeralTickFormatter(format="0,")
    p.legend.location = "top_left"
    padding = Spacer(width=30, height=10, sizing_mode='fixed')
    return (row([p, padding]))
Example #10
0
def catchform(request):
    if request.method == 'POST':
        try:
            catchment = Catchment.objects.get(pk=request.POST['station'])
            form = CatchForm(instance=catchment)

            x = [2, 5, 10, 20, 50, 100, 200]
            y = [
                catchment.dr2,
                catchment.dr5,
                catchment.dr10,
                catchment.dr20,
                catchment.dr50,
                catchment.dr100,
                catchment.dr200,
            ]

            tooltips = [("Year", "@x"), ("Rainfall Depth (mm)", "@y")]

            source = ColumnDataSource(data=dict(x=x, y=y))

            plot = figure(
                title='Design Rainfall Depths',
                sizing_mode='stretch_width',
                tools=['pan', 'box_zoom', 'save', 'reset', 'wheel_zoom'],
                y_range=Range1d(min(y) * 0.8,
                                max(y) * 1.1,
                                bounds=(min(y) * 0.5, max(y) * 1.15)),
                x_range=Range1d(min(x) - 1,
                                max(x) + 50,
                                bounds=(min(x) - 1, max(x) + 50)),
                x_axis_type="log",
                x_axis_label="Return Period (1:x year)",
                y_axis_label="Rainfall Depth (mm)",
                # plot_width=450,
                plot_height=400,
                id='rain_fig',
                tooltips=tooltips,
                active_drag=None,
                active_scroll=None)
            plot.line('x', 'y', source=source)
            plot.circle(x, y, fill_color="white", size=8)
            plot.toolbar.logo = None
            t = Spacer()
            layout = row(t, plot)  # , slider

            script, div = components(layout, CDN)

        except ObjectDoesNotExist:
            form = CatchForm()
            script = "<h4>No Graph to display</h4>"
            div = ""
            y = []

        return render(request, 'gaugedata/catch_data.html', {
            'form': form,
            'x_list': y,
            "bokeh_script": script,
            "bokeh_div": div
        })
Example #11
0
    def _init_recorder(self):
        self.rec_button = Toggle(label=u"\u25CF  Record",
                                 button_type="default",
                                 active=False,
                                 width=210)
        self.file_name_widget = TextInput(value="test_file",
                                          title="File name:",
                                          width=210)
        self.file_type_widget = RadioGroup(labels=["EDF (BDF+)", "CSV"],
                                           active=0,
                                           width=210)

        columns = [
            widgets.TableColumn(
                field='timer',
                title="Record time",
                formatter=widgets.StringFormatter(text_align='center'))
        ]
        self.timer = widgets.DataTable(source=self._timer_source,
                                       index_position=None,
                                       sortable=False,
                                       reorderable=False,
                                       header_row=False,
                                       columns=columns,
                                       width=210,
                                       height=50,
                                       css_classes=["timer_widget"])

        self.rec_button.on_click(self._toggle_rec)
        return column(Spacer(width=210, height=5), self.file_name_widget,
                      self.file_type_widget, self.rec_button, self.timer)
Example #12
0
 def _init_push2lsl(self):
     push2lsl_title = Div(text="""Push to LSL""", width=170, height=10)
     self.push2lsl_button = Toggle(label=u"\u25CF  Start", button_type="default", active=False,
                                   width=170, height=35)
     self.push2lsl_button.on_click(self._toggle_push2lsl)
     return column([Spacer(width=170, height=30), push2lsl_title, self.push2lsl_button],
                   width=170, height=200, sizing_mode='fixed')
def get_comp_results(company, period):

    # renaming arguments to more informative variable names
    cname = company
    histstr = period

    # getting blocks
    text_block = get_text_div(cname, histstr)
    empty_block = Div(text=" ", width=10)
    improvement_block = get_met_block("cust_sent_improvement", cname, histstr)
    resolution_block = get_met_block("issue_was_resolved", cname, histstr)

    return row([
        text_block,
        Spacer(width=100), resolution_block,
        Spacer(width=10), improvement_block
    ])
Example #14
0
    def __init__(self,
                 flexname: str = "Default",
                 name: str = "Collimator",
                 display=fakedisplay,
                 position: str = "0.0",
                 maxrange: float = 1.5,
                 width: int = 200):  # Collimator::__init__()
        """Initialize this class."""
        #super().__init__()
        # (wg-python-property-variables)
        self.flexname = flexname
        self.name = name
        self.display = display
        self.wwidth = width
        self.position = float(position)
        self.speed = 0.10
        self.maxrange = float(maxrange)
        self.direction = 1
        self.homestate = 0
        self.spacer = Spacer(width=self.wwidth, height=5,
                             background='black')  #None #

        self.collimator = Slider(title=f"Collimator Position",
                                 bar_color='firebrick',
                                 value=self.position,
                                 start=0,
                                 end=self.maxrange,
                                 step=0.01,
                                 format="0.000f",
                                 width=self.wwidth)
        self.collimatorspeed = Slider(title=f"Collimator Speed",
                                      bar_color='firebrick',
                                      value=self.speed,
                                      start=0,
                                      end=1,
                                      step=.01,
                                      width=self.wwidth)
        self.stepin = Button(label="Step In",
                             disabled=False,
                             button_type="warning",
                             width=self.wwidth // 2)
        self.stepout = Button(label="Step Out",
                              disabled=False,
                              button_type="warning",
                              width=self.wwidth // 2)
        self.homebutton = Button(label="Home",
                                 disabled=False,
                                 button_type="danger",
                                 width=self.wwidth)

        self.collimator.on_change(
            'value',
            lambda attr, old, new: self.update_collimator(attr, old, new))
        self.collimatorspeed.on_change(
            'value', lambda attr, old, new: self.update_speed(attr, old, new))
        self.stepin.on_click(lambda: self.update_stepin())
        self.stepout.on_click(lambda: self.update_stepout())
        self.homebutton.on_click(lambda: self.update_homebutton())
Example #15
0
    def _init_controls(self):
        """Initialize all controls in the dashboard"""
        # EEG/ECG Radio button
        self.mode_control = widgets.Select(title="Signal", value='EEG', options=MODE_LIST, width=170, height=50)
        self.mode_control.on_change('value', self._change_mode)

        self.t_range = widgets.Select(title="Time window", value="10 s", options=list(TIME_RANGE_MENU.keys()),
                                      width=170, height=50)
        self.t_range.on_change('value', self._change_t_range)
        self.y_scale = widgets.Select(title="Y-axis Scale", value="1 mV", options=list(SCALE_MENU.keys()),
                                      width=170, height=50)
        self.y_scale.on_change('value', self._change_scale)

        # Create device info tables
        columns = [widgets.TableColumn(field='heart_rate', title="Heart Rate (bpm)")]
        self.heart_rate = widgets.DataTable(source=self._heart_rate_source, index_position=None, sortable=False,
                                            reorderable=False,
                                            columns=columns, width=170, height=50)

        columns = [widgets.TableColumn(field='firmware_version', title="Firmware Version")]
        self.firmware = widgets.DataTable(source=self._firmware_source, index_position=None, sortable=False,
                                          reorderable=False,
                                          columns=columns, width=170, height=50)

        columns = [widgets.TableColumn(field='battery', title="Battery (%)")]
        self.battery = widgets.DataTable(source=self._battery_source, index_position=None, sortable=False,
                                         reorderable=False,
                                         columns=columns, width=170, height=50)

        columns = [widgets.TableColumn(field='temperature', title="Device temperature (C)")]
        self.temperature = widgets.DataTable(source=self.temperature_source, index_position=None, sortable=False,
                                             reorderable=False, columns=columns, width=170, height=50)

        columns = [widgets.TableColumn(field='light', title="Light (Lux)")]
        self.light = widgets.DataTable(source=self.light_source, index_position=None, sortable=False, reorderable=False,
                                       columns=columns, width=170, height=50)
        if self.mode == 'signal':
            widget_list = [Spacer(width=170, height=30), self.mode_control, self.y_scale, self.t_range, self.heart_rate,
                           self.battery, self.temperature, self.firmware]
        elif self.mode == 'impedance':
            widget_list = [Spacer(width=170, height=40), self.battery, self.temperature, self.firmware]

        widget_box = widgetbox(widget_list, width=175, height=450, sizing_mode='fixed')
        return widget_box
def create_document(directory, chat_titles):

    (message_df, reacts, title, participants) = parse_json_messages(directory)

    # -------------------------------------------------------------------------
    # Plot Message Timeseries:
    # -------------------------------------------------------------------------

    # Create a color palette to use in plotting:
    """ Might raise an error when number of people in the group chat is > 20"""
    colour_palette = Category20[20][0:len(participants)]

    message_panel = create_message_timeseries_panel(message_df, title, participants, colour_palette)

    # --------------------------------------------------------------------------+
    # Plot Reaction Panel:
    # --------------------------------------------------------------------------+

    reacts_panel = create_react_breakdown_panel(reacts, title, participants, colour_palette)

    # --------------------------------------------------------------------------+
    # Create Panel to Summarise Individual Statistics:
    # --------------------------------------------------------------------------+

    message_log_panel = create_message_log_panel(message_df, title, participants, colour_palette)

    # --------------------------------------------------------------------------+
    # Compile Bokeh Application:
    # --------------------------------------------------------------------------+

    tabs = Tabs(tabs=[message_panel, reacts_panel, message_log_panel])

    directory_search = AutocompleteInput(completions = list(chat_titles.keys()), width = 400, height = 30, sizing_mode = "fixed", align = 'end')
    directory_search.on_change("value", update_data)

    search_text = Div(
        text = "<i>Search Chats:</i>",
        height_policy = "max",
        sizing_mode = "scale_both",
        align = "end",
        style = {"font-family": 'Verdana', "font-size": "17px"}
    )

    # A title which could be included in the top left of the document
    title = Div(
        text = "<b>Messenger Analysis</b>",
        height_policy = "max",
        sizing_mode = "fixed",
        align = "start",
        style = {"font-family": 'Verdana', "font-size": "16px"}
    )

    layout = column(row(search_text,directory_search, Spacer(
            width=35, height=40, sizing_mode="fixed"), align = "end"), tabs, sizing_mode = "scale_width")

    return layout
    def __init__(self, controller):
        """Initialize object.

        First part of two-part initialization.
        Put initialization code here that's very unlikely to fail.
        """
        self.controller = controller
        self.state = None
        self.state_src = None

        # State maop of the US.
        self.stateusmap = figure(
            title="""Electoral college votes by time and geography""",
            x_axis_location=None,
            y_axis_location=None,
            x_axis_type="""linear""",
            sizing_mode="""stretch_both""")
        self.stateusmap.xgrid.visible = False
        self.stateusmap.ygrid.visible = False

        # The date for charting.
        self.choosethedatefordisplay = DateSlider(
            title="""Choose the date for display""",
            start="""2018-11-13T20:20:39+00:00""",
            end="""2025-11-13T20:20:39+00:00""",
            step=24 * 60 * 60 * 1000,
            value="""2018-11-13T20:20:39+00:00""",
            sizing_mode="stretch_width")

        # Layout the widgets
        row1 = row(children=[
            Spacer(width=10), self.choosethedatefordisplay,
            Spacer(width=10)
        ],
                   sizing_mode='stretch_width')
        self.layout = column(children=[
            self.stateusmap, row1,
            Spacer(height=75, sizing_mode='scale_width')
        ],
                             sizing_mode='stretch_both')
        self.panel = Panel(child=self.layout, title='Forecast by geography')
Example #18
0
    def _init_doc(self, doc):
        self.doc = doc
        self.doc.title = "Explore Dashboard"
        with open(os.path.join(os.path.dirname(__file__), 'templates', 'index.html')) as f:
            index_template = Template(f.read())
        doc.template = index_template
        self.doc.theme = Theme(os.path.join(os.path.dirname(__file__), 'theme.yaml'))
        self._init_plots()
        m_widgetbox = self._init_controls()

        # Create tabs
        if self.mode == "signal":
            exg_tab = Panel(child=self.exg_plot, title="ExG Signal")
            orn_tab = Panel(child=column([self.acc_plot, self.gyro_plot, self.mag_plot], sizing_mode='scale_width'),
                            title="Orientation")
            fft_tab = Panel(child=self.fft_plot, title="Spectral analysis")
            self.tabs = Tabs(tabs=[exg_tab, orn_tab, fft_tab], width=400, sizing_mode='scale_width')
            self.recorder_widget = self._init_recorder()
            self.push2lsl_widget = self._init_push2lsl()
            self.set_marker_widget = self._init_set_marker()
            self.baseline_widget = CheckboxGroup(labels=['Baseline correction'], active=[0])

        elif self.mode == "impedance":
            imp_tab = Panel(child=self.imp_plot, title="Impedance")
            self.tabs = Tabs(tabs=[imp_tab], width=500, sizing_mode='scale_width')
        banner = Div(text=""" <a href="https://www.mentalab.com"><img src=
        "https://images.squarespace-cdn.com/content/5428308ae4b0701411ea8aaf/1505653866447-R24N86G5X1HFZCD7KBWS/
        Mentalab%2C+Name+copy.png?format=1500w&content-type=image%2Fpng" alt="Mentalab"  width="225" height="39">""",
                     width=1500, height=50, css_classes=["banner"], align='center', sizing_mode="stretch_width")
        heading = Div(text=""" """, height=2, sizing_mode="stretch_width")
        if self.mode == 'signal':
            layout = column([heading,
                             banner,
                             row(m_widgetbox,
                                 Spacer(width=10, height=300),
                                 self.tabs,
                                 Spacer(width=10, height=300),
                                 column(Spacer(width=170, height=50), self.baseline_widget, self.recorder_widget,
                                        self.set_marker_widget, self.push2lsl_widget),
                                 Spacer(width=50, height=300)),
                             ],
                            sizing_mode="stretch_both")

        elif self.mode == 'impedance':
            layout = column(banner,
                            Spacer(width=600, height=20),
                            row([m_widgetbox, Spacer(width=25, height=500), self.tabs])
                            )
        self.doc.add_root(layout)
        self.doc.add_periodic_callback(self._update_fft, 2000)
        self.doc.add_periodic_callback(self._update_heart_rate, 2000)
        if self.stream_processor:
            self.stream_processor.subscribe(topic=TOPICS.filtered_ExG, callback=self.exg_callback)
            self.stream_processor.subscribe(topic=TOPICS.raw_orn, callback=self.orn_callback)
            self.stream_processor.subscribe(topic=TOPICS.device_info, callback=self.info_callback)
            self.stream_processor.subscribe(topic=TOPICS.marker, callback=self.marker_callback)
            self.stream_processor.subscribe(topic=TOPICS.env, callback=self.info_callback)
            self.stream_processor.subscribe(topic=TOPICS.imp, callback=self.impedance_callback)
Example #19
0
 def _plot(self):
     header_row = row(Spacer(width=260), self._app_title.figure)
     title_row = row(Spacer(width=40), self._input_header.figure,
                     Spacer(width=110), self._prob_header.figure,
                     Spacer(width=70), self._alignment_header.figure)
     family_prob_table = column(self._family_prob_1.figure,
                                self._family_prob_2.figure,
                                self._family_prob_3.figure,
                                self._family_prob_4.figure,
                                self._family_prob_5.figure)
     left_text_input_col = column(self._ti.widget,
                                  self._input_button.widget)
     right_console_col = column(Spacer(height=5),
                                family_prob_table,
                                width=80)
     alignment_row = row(Spacer(width=185), self._alignment_img.widget)
     fig_row = row(left_text_input_col, Spacer(width=210),
                   right_console_col, Spacer(width=50), alignment_row)
     layout = column(header_row, Spacer(height=30), title_row, fig_row)
     return layout
Example #20
0
    def get_tab_layout(self):
        """Return bokeh tab widget."""
        fig_tabs = [
            Panel(child=column([Spacer(height=30, width=20), self.ts]),
                  title="TS")
        ]
        for p, item in self.figures.items():
            if (self.multi_sensors and p not in ['x1', 'x2', 'x3', 'x4', 'x5', 'x6',
                                                 'COMBO_TEMP', 'COMBO_SALT', 'COMBO_DOXY']) \
                    or (not self.multi_sensors and p not in ['x1', 'x2', 'x3']):
                tab_layout = column([self.flag_widgets[p], item])
                tab_name = self.plot_parameters_mapping.get(
                    p).split()[0].replace('_CTD', '')
                pan = Panel(child=tab_layout, title=tab_name)
                fig_tabs.append(pan)

        return Tabs(tabs=fig_tabs)
Example #21
0
    def getConsole(self):

        self.analytics_div = Div(text="""Analytics HTML""",
                                 width=200,
                                 height=100)
        self.console = Div(text="""System Out console:""",
                           width=200,
                           height=100)
        #(Compute Nodes, Running Experiments, Queue and History, Orders & Advice )
        financePlot = self.time_graphic.getBokehComponent()

        j_tab1 = Panel(child=layout([financePlot], sizing_mode='fixed'),
                       title="Analytics")
        j_tab2 = Panel(child=layout([Div(height=500, width=500)],
                                    sizing_mode='fixed'),
                       title="System Out")
        j_tab3 = Panel(child=layout([Div(height=500, width=500)],
                                    sizing_mode='fixed'),
                       title="Log Data")
        j_tab4 = Panel(child=layout([Div(height=500, width=500)],
                                    sizing_mode='fixed'),
                       title="Job Code")
        j_tabs = Tabs(tabs=[j_tab1, j_tab2, j_tab3, j_tab4], width=700)

        l1 = layout([[[self.pt.getBokehComponent()]], [self.getControlPanel()],
                     [self.console]],
                    sizing_mode='fixed')

        l2 = layout([
            [[self.et.getBokehComponent()],
             Spacer(width=20), []],
            [self.getControlPanel(), j_tabs],
            [self.analytics_div],
        ],
                    sizing_mode='fixed')

        tab1 = Panel(child=l1, title="System Processes")
        tab2 = Panel(child=l2, title="Running Experiments")
        tab3 = Panel(child=Div(height=300, width=600),
                     title="Orders & Integration")
        tabs = Tabs(tabs=[tab1, tab2, tab3])
        return tabs
Example #22
0
    def __init__(self, **kwargs):
        super(TextInputWidget, self).__init__()
        self['name'] = kwargs.get('name')

        self['text_obj'] = TextInput(value="None",
                                     title=kwargs.get('label') or "Label:",
                                     width=300)
        self['text_obj'].js_on_change(
            "value",
            CustomJS(code="""
            console.log('text_input: value=' + this.value, this.toString())
        """))
        self['button'] = Button(label=kwargs.get('button_label') or 'Save',
                                width=50,
                                button_type='success')
        self['button'].on_event(ButtonClick,
                                partial(self.callback, text=self['text_obj']))

        self.layout = row(
            [self['text_obj'],
             column([Spacer(height=18), self['button']])])
Example #23
0
def index_toolbar_menu(w, doc_layout, args):
    w.add(
        "b_login",
        Button(label="LOGIN",
               width=GUI.TITLEBAR_LOGIN_BTN_WIDTH,
               css_classes=['b_submit']))

    title = app.config["app"]["title"]
    doc_layout.children.append(
        row(Div(text="""<h1>{}</h1>""".format(title),
                width=GUI.TITLEBAR_TITLE_WIDTH),
            Spacer(width=GUI.TITLEBAR_SPACER),
            w.get("b_login"),
            sizing_mode="fixed"))

    w.add_css("b_login",
              {'button': {
                  'background-color': '#98FB98',
                  'min-width': '50px'
              }})
    w.add_css("toolbarclass", {'div': {'background-color': '#5F9EA0'}})
 def _make_doc_layout(self):
     """
     Constructs the document layout object.
     
     Note: Row and Column are experimental features. The positions of 
     the widgets could be hardcoded.
     
     Returns:
     --------
     doc_layout : bokeh.layouts.layout object
         Grid layout of bokeh models.
     """
     top_row = Row(self.widgets['add'], Spacer(width=25),
                   self.widgets['clear'])
     right_column = Column(self.widgets['method'],
                           self.widgets['num_train_inst'],
                           self.widgets['color'],
                           self.widgets['change_color'],
                           self.widgets['start'])
     doc_layout = layout([top_row, [self.fig, right_column]])
     return doc_layout
Example #25
0
    def __init__(self,
                 flexname: str = "Default",
                 name="Shutter",
                 display=fakedisplay,
                 pangle: str = "0.0",
                 width=200):  # FlexShutter::__init__()
        """Initialize this class."""
        #super().__init__()
        # (wg-python-property-variables)
        self.flexname = flexname
        self.name = name
        self.display = display
        self.wwidth = width
        self.pangle = float(pangle)
        self.openshutter = 0
        self.closeshutter = 0
        self.spacer = Spacer(width=self.wwidth, height=5, background='black')

        self.parallacticangle = Slider(title=f"Shutter",
                                       bar_color='firebrick',
                                       value=self.pangle,
                                       start=0,
                                       end=180,
                                       step=0.1,
                                       width=self.wwidth)
        self.openbutton = Button(label="Open",
                                 disabled=False,
                                 button_type="danger",
                                 width=self.wwidth // 2)
        self.closebutton = Button(label="Close",
                                  disabled=False,
                                  button_type="success",
                                  width=self.wwidth // 2)

        self.parallacticangle.on_change(
            'value', lambda attr, old, new: self.update_parallacticangle(
                attr, old, new))

        self.openbutton.on_click(lambda: self.update_openbutton())
        self.closebutton.on_click(lambda: self.update_closebutton())
Example #26
0
    def __init__(self,
                 flexname: str = "Default",
                 name="IMU",
                 display=fakedisplay,
                 pangle: str = "0.0",
                 width=200):  # FlexOrientation::__init__()
        """Initialize this class."""
        #super().__init__()
        # (wg-python-property-variables)
        self.flexname = flexname
        self.name = name
        self.display = display
        self.wwidth = width
        self.pangle = float(pangle)
        self.home = 0
        self.read = 0
        self.spacer = Spacer(width=self.wwidth, height=5, background='black')

        self.parallacticangle = Slider(title=f"Parallactic Angle",
                                       bar_color='firebrick',
                                       value=self.pangle,
                                       start=0,
                                       end=180,
                                       step=0.1,
                                       width=self.wwidth)
        self.readbutton = Button(label="Read",
                                 disabled=False,
                                 button_type="warning",
                                 width=self.wwidth // 2)
        self.homebutton = Button(label="Home",
                                 disabled=False,
                                 button_type="danger",
                                 width=self.wwidth // 2)

        self.parallacticangle.on_change(
            'value', lambda attr, old, new: self.update_parallacticangle(
                attr, old, new))

        self.readbutton.on_click(lambda: self.update_readbutton())
        self.homebutton.on_click(lambda: self.update_homebutton())
Example #27
0
    def get_layout(self):
        """Return the complete bokeh layout."""
        tabs = self.get_tab_layout()
        tab_kwargs = {
            'Data': [
                'text_index_selection',
                ('select_all_button', 'deselect_all_button'),
                'pressure_slider', 'text_multi_serie_flagging',
                'parameter_selector', 'multi_flag_widget'
            ],
            'Metadata': [
                'text_meta', 'comnt_visit', 'comnt_visit_button', 'comnt_samp',
                'comnt_samp_selector', 'comnt_samp_button'
            ],
            'Info': ['info_block']
        }
        if not self.as_standalone:
            tab_kwargs['Import'] = ['text_import', 'file_button']
            tab_kwargs['Export'] = ['text_export', 'download_button']

        meta_tabs = self.get_tabs(**tab_kwargs)
        std_parameter_tabs = self.get_std_parameter_tab_layout()
        widgets_1 = column(
            [self.month_selector, self.spacer, self.selected_series],
            sizing_mode="fixed",
            height=400,
            width=200)
        widgets_2 = column([Spacer(height=10, width=125)],
                           sizing_mode="fixed",
                           height=10,
                           width=125)
        widgets_3 = column([meta_tabs],
                           sizing_mode="stretch_both",
                           height=100,
                           width=100)
        return grid([
            row([self.map, widgets_1, widgets_2, widgets_3]),
            row([*std_parameter_tabs, column([tabs])])
        ])
Example #28
0
def page_toolbar_menu(w, doc_layout, args, user, buttons=[]):
    url = urlparse(args.get("windowUrl", ""))

    _new_menu = copy.deepcopy(_page_toolbar_menu)
    sub_title = ""

    # remove menu item for the page that we are already on or user doesn't have priviliage
    for entry in _page_toolbar_menu:
        if url.path == entry["url"]:
            _new_menu.remove(entry)
            sub_title = entry[
                "title"]  # this is the page we are on, add to toolbar row display

        if entry.get("role", False) and not RolesUsers.user_has_role(
                user, entry["role"]):
            _new_menu.remove(entry)

    _new_menu = [x["entry"] for x in _new_menu]

    w.add(
        "toolbar_menu",
        Dropdown(label=user.username,
                 menu=_new_menu,
                 width=GUI.TITLEBAR_MENU_WIDTH,
                 css_classes=['toolbar_menu']))
    w.init()

    title = app.config["app"]["title"]
    _tool_bar_row = [
        Div(text="""<h1>{} - {}</h1>""".format(title, sub_title),
            width=GUI.TITLEBAR_TITLE_WIDTH)
    ]
    _tool_bar_row.append(w.get("toolbar_menu"))
    for button in buttons:
        _tool_bar_row.append(Spacer(width=GUI.TITLEBAR_SPACER))
        _tool_bar_row.append(button)
    doc_layout.children.append(row(_tool_bar_row))

    w.add_css("toolbarclass", {'div': {'background-color': '#5F9EA0'}})
Example #29
0
    def __init__(self, flexname : str = "Default",
                 name : str = "Guider",
                 display = fakedisplay,
                 position : str = "0.0",
                 maxrange : float = 1.5, width : int = 200):  # Guider::__init__()
        """Initialize this class."""
        #super().__init__()
        # (wg-python-property-variables)
        self.flexname    = flexname          # name of this instrument
        self.name        = name              # name this instance recognizes
        self.display     = display           # where to put debug info

        self.position    = float(position)   # state variables
        self.direction   = 1                 # tied to step/in step/out buttons
        self.speed       = 0.10              # fraction of the speed to move
        self.homestate   = 0                 # a tristate by convention

        self.wwidth      = width             # interval variables
        self.maxrange    = float(maxrange)

        self.spacer      = Spacer(width=self.wwidth, height=5, background='black') # None #

        self.guider      = Slider    (title=f"Guider Position", bar_color='firebrick',
                                           value = self.position, start = 0,  end = self.maxrange,
                                           step = 0.01, format="0.000f",width=self.wwidth)
        self.guiderspeed = Slider    (title=f"Guider Speed", bar_color='firebrick',
                                           value = self.speed, start = 0,  end = 1,
                                           step = .01, width=self.wwidth)
        self.stepin      = Button    ( label="Step In",  disabled=False, button_type="warning", width=self.wwidth//2)
        self.stepout     = Button    ( label="Step Out", disabled=False, button_type="warning", width=self.wwidth//2)
        self.homebutton  = Button    ( label="Home",     disabled=False, button_type="danger", width=self.wwidth)

        self.guider       .on_change ('value', lambda attr, old, new: self.update_guider      (attr, old, new))
        self.guiderspeed  .on_change ('value', lambda attr, old, new: self.update_speed       (attr, old, new))
        self.stepin       .on_click  (lambda : self.update_stepin()     )
        self.stepout      .on_click  (lambda : self.update_stepout()    )
        self.homebutton   .on_click  (lambda : self.update_homebutton() )
show_button = Button(label="Show components", button_type="success")
show_button.on_click(createTwoComponents)

how_button = Button(label="Reset", button_type="success")
how_button.on_click(reset)

lang_button = Button(label="Zu Deutsch wechseln", button_type="success")
lang_button.on_click(changeLanguage)

###################################
# Page Layout
###################################

description_filename = join(dirname(__file__), "description.html")
description = LatexDiv(text=open(description_filename).read(),
                       render_as_text=False,
                       width=1200)

## Send to window
curdoc().add_root(
    column(
        row(Spacer(width=920), lang_button), description,
        column(
            row(
                p, (Spacer(width=40)),
                column(LineVector1Slider, LineVector2Slider,
                       AngleVector1Slider, Vector1Slider, show_button,
                       how_button, value_plot)))))
curdoc().title = "Vector Decomposition"