Exemplo n.º 1
0
 def serve_plot(self):
     {
         'full': self.generate_full_res_plot,
         'daily': self.generate_full_res_plot,
         '5min': self.generate_5min_stats_plot
     }[self.interval]()
     curdoc().add_root(self.plot)
Exemplo n.º 2
0
def animate():
    global callback_id
    if button.label == '► Play':
        button.label = '❚❚ Pause'
        callback_id = curdoc().add_periodic_callback(animate_update, 400)
    else:
        button.label = '► Play'
        curdoc().remove_periodic_callback(callback_id)
def animate():
    global callback_id
    if button.label == '► Play':
        slider.value = 0
        button.label = '❚❚ Pause'  #PLAY ANIMATION
        callback_id = curdoc().add_periodic_callback(animate_update,
                                                     100)  #miliseconds
    else:
        button.label = '► Play'  #PAUSE ANIMATION
        curdoc().remove_periodic_callback(callback_id)
 def tearDown(self):
     Store.current_backend = self.previous_backend
     bokeh_renderer.last_plot = None
     Callback._callbacks = {}
     with param.logging_level('ERROR'):
         Renderer.notebook_context = self.nbcontext
     state.curdoc = None
     curdoc().clear()
     set_curdoc(self.doc)
     time.sleep(1)
Exemplo n.º 5
0
def update_plot(attr, old, new):
    severity = select.value
    new_data = json_data(severity)
    #input_field
    geosource.geojson = new_data
    hover = HoverTool(
        tooltips=[('Municipality',
                   '@Mun_Name'), (severity + ' risk', '@' + severity)])
    p = make_plot(severity)
    layout = column(p, widgetbox(select))
    curdoc().clear()
    curdoc().add_root(layout)
def update_plot(attr, old, new):
    # The input mth is the month selected from the slider
    mth = slider.value + datem
    new_data = json_data(mth)

    # Update the plot based on the changed inputs
    p = make_plot(input_field)

    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(slider))
    curdoc().clear()
    curdoc().add_root(layout)

    # Update the data
    geosource.geojson = new_data
Exemplo n.º 7
0
def update_plot(attr, old, new):
    
    # The input cr is the criteria selected from the select box
    cr = select.value
    print(cr)
    input_field = format_df.loc[format_df['verbage'] == cr, 'field'].iloc[0]
    print(input_field)
    # Update the plot based on the changed inputs
    p = make_plot(input_field)
    
    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(select))
    curdoc().clear()
    curdoc().add_root(layout)
    
    p.source.data = data
Exemplo n.º 8
0
    def test_patch_notification(self) -> None:
        d = document.Document()
        assert not d.roots
        m = ColumnDataSource(data=dict(a=[10, 11], b=[20, 21]))
        d.add_root(m)
        assert len(d.roots) == 1
        assert curdoc() is not d
        events = []
        curdoc_from_listener = []

        def listener(event):
            curdoc_from_listener.append(curdoc())
            events.append(event)

        d.on_change(listener)
        m.patch(dict(a=[(0, 1)], b=[(0, 0), (1, 1)]))
        assert events
        event = events[0]
        assert isinstance(event, ModelChangedEvent)
        assert isinstance(event.hint, ColumnsPatchedEvent)
        assert event.document == d
        assert event.model == m
        assert event.hint.column_source == m
        assert event.hint.patches == dict(a=[(0, 1)], b=[(0, 0), (1, 1)])
        assert event.attr == 'data'
        # old == new because stream events update in-place
        assert event.old == dict(a=[1, 11], b=[0, 1])
        assert event.new == dict(a=[1, 11], b=[0, 1])
        assert len(curdoc_from_listener) == 1
        assert curdoc_from_listener[0] is d
Exemplo n.º 9
0
 def post_check():
     newdoc = curdoc()
     # script is supposed to edit the doc not replace it
     if newdoc is not doc:
         raise RuntimeError(
             "%s at '%s' replaced the output document" %
             (self._origin, self._runner.path))
Exemplo n.º 10
0
 def test_change_notification(self):
     d = document.Document()
     assert not d.roots
     m = AnotherModelInTestDocument()
     d.add_root(m)
     assert len(d.roots) == 1
     assert m.bar == 1
     assert curdoc() is not d
     events = []
     curdoc_from_listener = []
     def listener(event):
         curdoc_from_listener.append(curdoc())
         events.append(event)
     d.on_change(listener)
     m.bar = 42
     assert events
     event = events[0]
     assert isinstance(event, ModelChangedEvent)
     assert event.document == d
     assert event.model == m
     assert event.attr == 'bar'
     assert event.old == 1
     assert event.new == 42
     assert len(curdoc_from_listener) == 1
     assert curdoc_from_listener[0] is d
Exemplo n.º 11
0
 def test_stream_notification(self):
     d = document.Document()
     assert not d.roots
     m = ColumnDataSource(data=dict(a=[10], b=[20]))
     d.add_root(m)
     assert len(d.roots) == 1
     assert curdoc() is not d
     events = []
     curdoc_from_listener = []
     def listener(event):
         curdoc_from_listener.append(curdoc())
         events.append(event)
     d.on_change(listener)
     m.stream(dict(a=[11, 12], b=[21, 22]), 200)
     assert events
     event = events[0]
     assert isinstance(event, ModelChangedEvent)
     assert isinstance(event.hint, ColumnsStreamedEvent)
     assert event.document == d
     assert event.model == m
     assert event.hint.column_source == m
     assert event.hint.data == dict(a=[11, 12], b=[21, 22])
     assert event.hint.rollover == 200
     assert event.attr == 'data'
     # old == new because stream events update in-place
     assert event.old == dict(a=[10, 11, 12], b=[20, 21, 22])
     assert event.new == dict(a=[10, 11, 12], b=[20, 21, 22])
     assert len(curdoc_from_listener) == 1
     assert curdoc_from_listener[0] is d
Exemplo n.º 12
0
 def test_patch_notification(self):
     d = document.Document()
     assert not d.roots
     m = ColumnDataSource(data=dict(a=[10,11], b=[20,21]))
     d.add_root(m)
     assert len(d.roots) == 1
     assert curdoc() is not d
     events = []
     curdoc_from_listener = []
     def listener(event):
         curdoc_from_listener.append(curdoc())
         events.append(event)
     d.on_change(listener)
     m.patch(dict(a=[(0, 1)], b=[(0,0), (1,1)]))
     assert events
     event = events[0]
     assert isinstance(event, ModelChangedEvent)
     assert isinstance(event.hint, ColumnsPatchedEvent)
     assert event.document == d
     assert event.model == m
     assert event.hint.column_source == m
     assert event.hint.patches == dict(a=[(0, 1)], b=[(0,0), (1,1)])
     assert event.attr == 'data'
     # old == new because stream events update in-place
     assert event.old == dict(a=[1, 11], b=[0, 1])
     assert event.new == dict(a=[1, 11], b=[0, 1])
     assert len(curdoc_from_listener) == 1
     assert curdoc_from_listener[0] is d
Exemplo n.º 13
0
    def test_change_notification(self) -> None:
        d = document.Document()
        assert not d.roots
        m = AnotherModelInTestDocument()
        d.add_root(m)
        assert len(d.roots) == 1
        assert m.bar == 1
        assert curdoc() is not d
        events = []
        curdoc_from_listener = []

        def listener(event):
            curdoc_from_listener.append(curdoc())
            events.append(event)

        d.on_change(listener)
        m.bar = 42
        assert events
        event = events[0]
        assert isinstance(event, ModelChangedEvent)
        assert event.document == d
        assert event.model == m
        assert event.attr == 'bar'
        assert event.old == 1
        assert event.new == 42
        assert len(curdoc_from_listener) == 1
        assert curdoc_from_listener[0] is d
Exemplo n.º 14
0
    def modify_document(self, doc):
        '''

        '''
        if self.failed:
            return

        module = self._runner.new_module()

        # One reason modules are stored is to prevent the module
        # from being gc'd before the document is. A symptom of a
        # gc'd module is that its globals become None. Additionally
        # stored modules are used to provide correct paths to
        # custom models resolver.
        sys.modules[module.__name__] = module
        doc._modules.append(module)

        old_doc = curdoc()
        set_curdoc(doc)
        old_io = self._monkeypatch_io()

        try:
            def post_check():
                newdoc = curdoc()
                # script is supposed to edit the doc not replace it
                if newdoc is not doc:
                    raise RuntimeError("%s at '%s' replaced the output document" % (self._origin, self._runner.path))
            self._runner.run(module, post_check)
        finally:
            self._unmonkeypatch_io(old_io)
            set_curdoc(old_doc)
Exemplo n.º 15
0
    def test_stream_notification(self) -> None:
        d = document.Document()
        assert not d.roots
        m = ColumnDataSource(data=dict(a=[10], b=[20]))
        d.add_root(m)
        assert len(d.roots) == 1
        assert curdoc() is not d
        events = []
        curdoc_from_listener = []

        def listener(event):
            curdoc_from_listener.append(curdoc())
            events.append(event)

        d.on_change(listener)
        m.stream(dict(a=[11, 12], b=[21, 22]), 200)
        assert events
        event = events[0]
        assert isinstance(event, ModelChangedEvent)
        assert isinstance(event.hint, ColumnsStreamedEvent)
        assert event.document == d
        assert event.model == m
        assert event.hint.column_source == m
        assert event.hint.data == dict(a=[11, 12], b=[21, 22])
        assert event.hint.rollover == 200
        assert event.attr == 'data'
        # old == new because stream events update in-place
        assert event.old == dict(a=[10, 11, 12], b=[20, 21, 22])
        assert event.new == dict(a=[10, 11, 12], b=[20, 21, 22])
        assert len(curdoc_from_listener) == 1
        assert curdoc_from_listener[0] is d
Exemplo n.º 16
0
    def test_patch_notification(self) -> None:
        d = document.Document()
        assert not d.roots
        m = ColumnDataSource(data=dict(a=[10, 11], b=[20, 21]))
        d.add_root(m)
        assert len(d.roots) == 1
        assert curdoc() is not d
        events = []
        curdoc_from_listener = []

        def listener(event):
            curdoc_from_listener.append(curdoc())
            events.append(event)

        d.on_change(listener)
        m.patch(dict(a=[(0, 1)], b=[(0, 0), (1, 1)]))
        assert events
        event = events[0]
        assert isinstance(event, ColumnsPatchedEvent)
        assert event.document == d
        assert event.model == m
        assert event.attr == "data"
        assert event.patches == dict(a=[(0, 1)], b=[(0, 0), (1, 1)])
        assert len(curdoc_from_listener) == 1
        assert curdoc_from_listener[0] is d
Exemplo n.º 17
0
    def modify_document(self, doc):
        '''

        '''
        if self.failed:
            return

        module = self._runner.new_module()

        # One reason modules are stored is to prevent the module
        # from being gc'd before the document is. A symptom of a
        # gc'd module is that its globals become None. Additionally
        # stored modules are used to provide correct paths to
        # custom models resolver.
        sys.modules[module.__name__] = module
        doc._modules.append(module)

        old_doc = curdoc()
        set_curdoc(doc)
        old_io = self._monkeypatch_io()

        try:

            def post_check():
                newdoc = curdoc()
                # script is supposed to edit the doc not replace it
                if newdoc is not doc:
                    raise RuntimeError(
                        "%s at '%s' replaced the output document" %
                        (self._origin, self._runner.path))

            self._runner.run(module, post_check)
        finally:
            self._unmonkeypatch_io(old_io)
            set_curdoc(old_doc)
Exemplo n.º 18
0
def update_plot(attr, old, new):
    # The input yr is the year selected from the slider
    yr = select2.value
    new_data = merged_json(yr)
    # Update the data
    geosource.geojson = new_data
    # The input cr is the criteria selected from the select box
    cr = select.value
    input_field = cr

    # Update the plot based on the changed inputs
    p = make_plot(input_field)

    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(select), widgetbox(select2))
    curdoc().clear()
    curdoc().add_root(layout)
Exemplo n.º 19
0
def update_plot(attr, old, new):
    '''
    Callback function for make_plot(): Important for widget tools from Bokeh: Users when map is on the Web can select a criteria they want to have displayed
    (for us the options are: 'Price', 'Median Price' or 'Price per Square Metre'). Bokeh calls when the .on_change method is used 
    (when a change is made using the widget) the update_plot function. update_plot is a callback function with three parameters:
    the attr parameter is simply the ‘value’ passed (select.value = criteria), the old and new are internal parameters used by Bokeh.
    '''
    new_data = json_data
    cr = select.value  # The input cr is the criteria selected from the select box
    input_field = format_df.loc[format_df['verbage'] == cr, 'field'].iloc[0]
    p = make_plot(input_field)  # Update the plot based on the changed inputs
    layout = column(
        p, widgetbox(select)
    )  # Update the layout, clear the old document and display the new document
    curdoc().clear()
    curdoc().add_root(layout)
    geosource.geojson = new_data  # Update the data
Exemplo n.º 20
0
def test_show_with_default_args(mock__show_with_state):
    curstate().reset()
    default_kwargs = dict(browser=None, new="tab", notebook_handle=False)
    p = Plot()
    bis.show(p, **default_kwargs)
    assert mock__show_with_state.call_count == 1
    assert mock__show_with_state.call_args[0] == (p, curstate(), None, "tab")
    assert mock__show_with_state.call_args[1] == {'notebook_handle': False}
    assert p in curdoc().roots
Exemplo n.º 21
0
def test_show_with_default_args(mock__show_with_state):
    curstate().reset()
    default_kwargs = dict(browser=None, new="tab", notebook_handle=False)
    p = Plot()
    bis.show(p, **default_kwargs)
    assert mock__show_with_state.call_count == 1
    assert mock__show_with_state.call_args[0] == (p, curstate(), None, "tab")
    assert mock__show_with_state.call_args[1] == {'notebook_handle': False}
    assert p in curdoc().roots
Exemplo n.º 22
0
def test_show_with_explicit_args(mock__show_with_state):
    curstate().reset()
    kwargs = dict(browser="browser", new="new", notebook_handle=True)
    p = Plot()
    bis.show(p, **kwargs)
    assert mock__show_with_state.call_count == 1
    assert mock__show_with_state.call_args[0] == (p, curstate(), "browser", "new")
    assert mock__show_with_state.call_args[1] == {'notebook_handle': True}
    assert p in curdoc().roots
Exemplo n.º 23
0
def test_show_with_explicit_args(mock__show_with_state):
    curstate().reset()
    kwargs = dict(browser="browser", new="new", notebook_handle=True)
    p = Plot()
    bis.show(p, **kwargs)
    assert mock__show_with_state.call_count == 1
    assert mock__show_with_state.call_args[0] == (p, curstate(), "browser", "new")
    assert mock__show_with_state.call_args[1] == {'notebook_handle': True}
    assert p in curdoc().roots
Exemplo n.º 24
0
 def test_timeout_callback_gets_curdoc(self):
     d = document.Document()
     assert curdoc() is not d
     curdoc_from_cb = []
     def cb():
         curdoc_from_cb.append(curdoc())
     callback = d.add_timeout_callback(cb, 1)
     callback.callback()
     assert len(curdoc_from_cb) == 1
     assert curdoc_from_cb[0] is d
def update_plot1(attr, old, new):
    # The input day is the day selected from the slider
    day = slider.value
    new_data = json_data(day)

    # The input cr is the criteria selected from the select box
    cr = select.value
    input_field = format_df.loc[format_df['verbage'] == cr, 'field'].iloc[0]

    # Update the plot based on the changed inputs
    p = make_plot(input_field)

    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(select), widgetbox(slider))
    curdoc().clear()
    curdoc().add_root(layout)

    # Update the data
    geosource.geojson = new_data
Exemplo n.º 26
0
 def test_periodic_callback_gets_curdoc(self) -> None:
     d = document.Document()
     assert curdoc() is not d
     curdoc_from_cb = []
     def cb():
         curdoc_from_cb.append(curdoc())
     callback_obj = d.add_periodic_callback(cb, 1)
     callback_obj.callback()
     assert len(curdoc_from_cb) == 1
     assert curdoc_from_cb[0] is d
 def setUp(self):
     self.previous_backend = Store.current_backend
     if not bokeh_renderer:
         raise SkipTest("Bokeh required to test plot instantiation")
     Store.current_backend = 'bokeh'
     self.doc = curdoc()
     set_curdoc(Document())
     self.nbcontext = Renderer.notebook_context
     with param.logging_level('ERROR'):
         Renderer.notebook_context = False
Exemplo n.º 28
0
 def test_timeout_callback_gets_curdoc(self):
     d = document.Document()
     assert curdoc() is not d
     curdoc_from_cb = []
     def cb():
         curdoc_from_cb.append(curdoc())
     callback = d.add_timeout_callback(cb, 1)
     callback.callback()
     assert len(curdoc_from_cb) == 1
     assert curdoc_from_cb[0] is d
Exemplo n.º 29
0
 def test_next_tick_callback_gets_curdoc(self):
     d = document.Document()
     assert curdoc() is not d
     curdoc_from_cb = []
     def cb():
         curdoc_from_cb.append(curdoc())
     callback_obj = d.add_next_tick_callback(cb)
     callback_obj.callback()
     assert len(curdoc_from_cb) == 1
     assert curdoc_from_cb[0] is d
Exemplo n.º 30
0
def update_plot(attr, old, new):
    # The input yr is the year selected from the slider
    yr = slider.value
    date = dates[yr]
    new_data = json_data(date)
    label.text = str(date)

    # The input cr is the criteria selected from the select box
    cr = select.value
    # Update the plot based on the changed inputs
    p = make_plot(cr)
    p.add_layout(label)

    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(slider), widgetbox(select))
    curdoc().clear()
    curdoc().add_root(layout)

    # Update the data
    geosource.geojson = new_data
Exemplo n.º 31
0
 def test_model_callback_gets_curdoc(self):
     d = document.Document()
     m = AnotherModelInTestDocument(bar=42)
     d.add_root(m)
     assert curdoc() is not d
     curdoc_from_cb = []
     def cb(attr, old, new):
         curdoc_from_cb.append(curdoc())
     m.on_change('bar', cb)
     m.bar = 43
     assert len(curdoc_from_cb) == 1
     assert curdoc_from_cb[0] is d
Exemplo n.º 32
0
def test_patch_curdoc() -> None:
    d1 = Document()
    d2 = Document()
    orig_doc =  bid.curdoc()

    assert bid._PATCHED_CURDOCS == []

    with bid.patch_curdoc(d1):
        assert len(bid._PATCHED_CURDOCS) == 1
        assert isinstance(bid._PATCHED_CURDOCS[0], weakref.ReferenceType)
        assert bid.curdoc() is d1

        with bid.patch_curdoc(d2):
            assert len(bid._PATCHED_CURDOCS) == 2
            assert isinstance(bid._PATCHED_CURDOCS[1], weakref.ReferenceType)
            assert bid.curdoc() is d2

        assert len(bid._PATCHED_CURDOCS) == 1
        assert isinstance(bid._PATCHED_CURDOCS[0], weakref.ReferenceType)
        assert bid.curdoc() is d1

    assert bid.curdoc() is orig_doc
Exemplo n.º 33
0
    def _with_self_as_curdoc(self, f):
        '''

        '''
        from bokeh.io.doc import set_curdoc, curdoc
        old_doc = curdoc()
        try:
            if getattr(f, "nolock", False):
                set_curdoc(UnlockedDocumentProxy(self))
            else:
                set_curdoc(self)
            return f()
        finally:
            set_curdoc(old_doc)
Exemplo n.º 34
0
    def _with_self_as_curdoc(self, f):
        '''

        '''
        from bokeh.io.doc import set_curdoc, curdoc
        old_doc = curdoc()
        try:
            if getattr(f, "nolock", False):
                set_curdoc(UnlockedDocumentProxy(self))
            else:
                set_curdoc(self)
            return f()
        finally:
            set_curdoc(old_doc)
def update_plot(attr, old, new):

    # The input is the date selected from the slider
    rest = (total_days - int(slider.value))
    last_date = datetime.strptime(yesterday, '%d-%m-%Y')
    selected_date = (last_date - timedelta(days=rest)
                     )  #Ex. 2020-06-17 07:04:02.936282
    date_from_slider = selected_date.strftime('%d-%m-%Y')
    new_data = json_data(date_from_slider)

    # The input cr is the criteria selected from the select box
    cr = select.value
    input_field = format_df.loc[format_df['case_category'] == cr,
                                'field'].iloc[0]

    # Update the plot based on the changed inputs
    p = make_plot(input_field, date_from_slider)

    # Update the layout, clear the old document and display the new document
    layout = column(p, column(slider), column(select), column(button))
    curdoc().clear()
    curdoc().add_root(layout)

    geosource.geojson = new_data  # Update the data
Exemplo n.º 36
0
def update_plot(attr, old, new):
    # The input is the minimum assessed value selected from the slider
    print(slider.value)
    assess_value = slider.value
    new_data = json_data(assess_value)

    #print('what is new data?', new_data)
    #print('what are the updated data' new_data.columns)

    # The input cr is the criteria selected from the select box
    print('what is the new cr?', select.value)
    cr = select.value
    input_field = format_df.loc[format_df['verbage'] == cr, 'field'].iloc[0]
    print('what is the new input_field?', input_field)
    # Update the plot based on the changed inputs
    p = make_plot(input_field)

    # Update the layout, clear the old document and display the new document
    layout = column(p, widgetbox(select), widgetbox(slider))
    curdoc().clear()
    curdoc().add_root(layout)

    # Update the data
    geosource.geojson = new_data
Exemplo n.º 37
0
    def modify_document(self, doc: Document) -> None:
        if self.failed:
            return

        module = self._runner.new_module()

        doc.modules.add(module)

        orig_curdoc = curdoc()
        set_curdoc(doc)

        old_io, old_doc = self._monkeypatch()

        try:
            self._runner.run(module, lambda: None)
        finally:
            self._unmonkeypatch(old_io, old_doc)
            set_curdoc(orig_curdoc)
Exemplo n.º 38
0
    def modify_document(self, doc):
        if self.failed:
            return

        module = self._runner.new_module()

        sys.modules[module.__name__] = module
        doc._modules.append(module)

        orig_curdoc = curdoc()
        set_curdoc(doc)

        old_io, old_doc = self._monkeypatch()

        try:
            self._runner.run(module, lambda: None)
        finally:
            self._unmonkeypatch(old_io, old_doc)
            set_curdoc(orig_curdoc)
Exemplo n.º 39
0
 def post_check():
     newdoc = curdoc()
     # script is supposed to edit the doc not replace it
     if newdoc is not doc:
         raise RuntimeError("%s at '%s' replaced the output document" % (self._origin, self._runner.path))
Exemplo n.º 40
0
def test_curdoc_from_curstate():
    assert bid.curdoc() is curstate().document
Exemplo n.º 41
0
 def cb(attr, old, new):
     curdoc_from_cb.append(curdoc())
Exemplo n.º 42
0
 def cb():
     curdoc_from_cb.append(curdoc())
Exemplo n.º 43
0
 def listener(event):
     curdoc_from_listener.append(curdoc())
     events.append(event)
Exemplo n.º 44
0
    def __init__(self, data):
        """Container for variation analysis.
        
        Args:
            data: data container (pd.DataFrame)
        Returns:
            None
        """
        
        super().__init__()
        
        self._data = self._VariationAnalysisData(data=data)
        self._figure = bkp.figure(title=_JsonKey.TITLE.value,
                                  x_axis_label=_JsonKey.X_NAME.value, 
                                  y_axis_label=_JsonKey.Y_NAME.value, 
                                  x_axis_type="datetime",
                                  y_axis_type="linear",
                                  plot_width=1200)
        # add tools
        self._figure.add_tools(bkmt.HoverTool(tooltips=[("x", "@{}".format(_JsonKey.X_NAME.value)), 
                                                        ("y", "@{}".format(_JsonKey.Y_NAME.value)), 
                                                        ("index", "$index")],
                                              formatters={"datetime": "datetime"}))
        # add plot data glyphs
        self._figure.circle(x=_JsonKey.X_NAME.value, y=_JsonKey.Y_NAME.value, 
                            fill_color="white", legend="points", size=5, 
                            source=self._data[_DataKey.PLT_CDS])
        self._figure.line(x=_JsonKey.X_NAME.value, y=_JsonKey.Y_NAME.value, 
                          legend="lines", source=self._data[_DataKey.PLT_CDS])
        # add legend
        self._figure.legend.background_fill_alpha = 0
        self._figure.legend.border_line_color = "navy" 
        self._figure.legend.border_line_width = 3
        self._figure.legend.click_policy="hide"
        
        # init lines
        _avg = bkma.Span(dimension="width", line_color="#000000", line_dash="dashed", 
                         line_width=3, location=self._data[_TableCdsKey.AVG])
        _pass_min = bkma.Span(dimension="width", line_color="#FF0000", line_dash="dashed", 
                              line_width=3, location=_JsonKey.PASS_MIN.value)
        _pass_max = bkma.Span(dimension="width", line_color="#FF0000", line_dash="dashed",
                              line_width=3, location=_JsonKey.PASS_MAX.value)
        _var_min = bkma.Span(dimension="width", line_color="#FFA500", line_dash="dashed",
                             line_width=3, location=self._data[_TableCdsKey.VAR_MIN])
        _var_max = bkma.Span(dimension="width", line_color="#FFA500", line_dash="dashed", 
                             line_width=3, location=self._data[_TableCdsKey.VAR_MAX])
        self._figure.add_layout(obj=_avg)
        self._figure.add_layout(obj=_pass_max)
        self._figure.add_layout(obj=_pass_min)
        self._figure.add_layout(obj=_var_max)
        self._figure.add_layout(obj=_var_min)
        self._annotations = {_TableCdsKey.AVG: _avg,
                             _TableCdsKey.VAR_MAX: _var_max,
                             _TableCdsKey.VAR_MIN: _var_min,
                             _TableCdsKey.PASS_MAX: _pass_max,
                             _TableCdsKey.PASS_MIN: _pass_min}

        # init input widgets
        _x_in_partitions = bkmws.Slider(title=_WidgetKey.X_IN_PART.value, 
                                        start=2, end=10, value=2, step=1)
        _x_in_current = bkmws.RangeSlider(title=_WidgetKey.X_IN_CURR.value, 
                                          start=1, end=2, step=1, value=(1,2))
        _x_in_precision = bkmwi.Select(title=_WidgetKey.X_IN_PREC.value, 
                                       options=["1", "10", "100"], value="1")
        _x_in = bkmws.RangeSlider(title=_WidgetKey.X_IN.value, start=self._data[_DataKey.XCL_X_MIN], 
                                  end=self._data[_DataKey.XCL_X_MAX], step=1, 
                                  value=(self._data[_DataKey.XCL_X_MIN], self._data[_DataKey.XCL_X_MAX]))
        _y_in_partitions = None
        _y_in_current = None
        _Y_IN_PREC = None
        _y_in = bkmws.RangeSlider(title=_WidgetKey.Y_IN.value, 
                                  start=self._data[_DataKey.XCL_Y_MIN], 
                                  end=self._data[_DataKey.XCL_Y_MAX], step=1, 
                                  value=(self._data[_DataKey.XCL_Y_MIN], self._data[_DataKey.XCL_Y_MAX]))
        # self._save_data = bkmwb.Button(label="save data", button_type="success")
        _x_in_partitions.on_change("value", functools.partial(self._cb_input_settings, widget=_x_in_partitions))
        _x_in_current.on_change("value", functools.partial(self._cb_input_settings, widget=_x_in_current))
        _x_in_precision.on_change("value", functools.partial(self._cb_input_settings, widget=_x_in_precision))
        _x_in.on_change("value", functools.partial(self._cb_input_settings, widget=_x_in))
        # _Y_IN_PREC.on_change("value", functools.partial(self._callback_select, widget=_Y_IN_PREC))
        # _y_in.on_change("value", functools.partial(self._callback_slider, widget=_y_in))
        # self._save_data.on_click(callback_save_output)
        in_table_display = bkmwg.CheckboxGroup(labels=[_WidgetKey.GEN_BOX.value, _WidgetKey.VAR_BOX.value], active=[0, 1], name=_WidgetKey.BOXES.value)
        in_table_display.on_click(self._cb_table_settings)
        
        # init output widgets
        _tbl_col1 = bkmwt.TableColumn(field=_WidgetKey.COL_NAME_OUT.value,
                                      title=_WidgetKey.COL_NAME_OUT.value)
        _tbl_col2 = bkmwt.TableColumn(field=_WidgetKey.COL_VALUE_OUT.value,
                                      title=_WidgetKey.COL_VALUE_OUT.value)
        _tbl_out = bkmwt.DataTable(source=self._data[_DataKey.TBL_CDS], 
                                   columns=[_tbl_col1, _tbl_col2], 
                                   fit_columns=False, row_headers=False, sizing_mode="scale_width",
                                   sortable=True, selectable=True, scroll_to_selection=True)    
        # init widgets
        self._widgets = {_WidgetKey.X_IN_PART: _x_in_partitions,
                         _WidgetKey.X_IN_CURR: _x_in_current,
                         _WidgetKey.X_IN_PREC: _x_in_precision,
                         _WidgetKey.X_IN: _x_in,
                         _WidgetKey.COL_NAME_OUT: _tbl_col1,
                         _WidgetKey.COL_VALUE_OUT: _tbl_col2,
                         _WidgetKey.BOXES: in_table_display}
                                                                
        # init layout
        input_left = bkl.column(children=[_x_in_partitions, _x_in_current, _x_in_precision, _x_in])
        input_right = bkl.column(children=[])
        text_input = bkl.row(children=[input_left, input_right])
        input = bkl.column(children=[text_input])
        widgets = bkl.row(children=[input, in_table_display, _tbl_out])
        plot_and_io = bkl.column(children=[self._figure, widgets])
        bkiod.curdoc().add_root(model=plot_and_io)
        
        self._flag = False