Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-7427

Improve display of metric thresholds

    Details

    • Type: Story
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Some improvements on the display of the threshold lines in the bokeh app
      1) we want lines that extend to infinity independently of the zoom, pan
      2) we dont want the hover tool on threshold lines
      3) we want to turn them on/off to not hide subtle changes in the measurements (the y-axis range is automatically set to the threshold values if they are on)
      4) we want to indicate regions below/above the thresholds

        Attachments

          Issue Links

            Activity

            Hide
            afausti Angelo Fausti added a comment -

            Attempt to make bokeh spans annotation to work with a bokeh app.

            Show
            afausti Angelo Fausti added a comment - Attempt to make bokeh spans annotation to work with a bokeh app.
            Hide
            afausti Angelo Fausti added a comment - - edited

            Bokeh annotations cannot be configured with data sources, after exchanging some emails with bokeh developers the trick is to use a JS callback to update the annotation parameters as the metric change, here is a minimal example for the record

             
            from bokeh.io import curdoc
            from bokeh.layouts import row, widgetbox
            from bokeh.models import Slider, Span, CustomJS, Label
            from bokeh.plotting import figure
             
            slider = Slider(start=0, end=10, value=3, step=0.1, title='Slider')
             
            plot = figure(width=700, height=250, x_range=(0,10), y_range=(-1, 1))
            span = Span(location=slider.value, dimension='height')
            plot.add_layout(span)
            label = Label(x=slider.value, y=0, x_units='data', y_units='data',
                             text="Minimum")
            plot.add_layout(label)
             
            slider.callback = CustomJS(args=dict(span=span, label=label, slider=slider), code="""
                span.location = slider.value
                label.x = slider.value
            """)
            curdoc().add_root(row(plot, widgetbox(slider)))
            

            Show
            afausti Angelo Fausti added a comment - - edited Bokeh annotations cannot be configured with data sources, after exchanging some emails with bokeh developers the trick is to use a JS callback to update the annotation parameters as the metric change, here is a minimal example for the record   from bokeh.io import curdoc from bokeh.layouts import row, widgetbox from bokeh.models import Slider, Span, CustomJS, Label from bokeh.plotting import figure   slider = Slider(start = 0 , end = 10 , value = 3 , step = 0.1 , title = 'Slider' )   plot = figure(width = 700 , height = 250 , x_range = ( 0 , 10 ), y_range = ( - 1 , 1 )) span = Span(location = slider.value, dimension = 'height' ) plot.add_layout(span) label = Label(x = slider.value, y = 0 , x_units = 'data' , y_units = 'data' , text = "Minimum" ) plot.add_layout(label)   slider.callback = CustomJS(args = dict (span = span, label = label, slider = slider), code = """ span.location = slider.value label.x = slider.value """ ) curdoc().add_root(row(plot, widgetbox(slider)))
            Hide
            afausti Angelo Fausti added a comment -

            Another implementation using the same logic but updating the annotation parameters in the server side, avoiding the javascript callback. I think it is quite illustrative of bokeh's flexibility and worth to keep:

             
            from bokeh.io import curdoc
            from bokeh.layouts import row, widgetbox
            from bokeh.models import Slider, Span, Label
            from bokeh.plotting import figure
             
            slider = Slider(start=0, end=10, value=3, step=0.1, title='Slider')
             
            plot = figure(width=700, height=250, x_range=(0,10), y_range=(-1, 1))
            span = Span(location=slider.value, dimension='height')
            plot.add_layout(span)
            label = Label(x=slider.value, y=0, x_units='data', y_units='data',
                             text="Minimum")
             
            plot.add_layout(label)
             
            def update_annotations(attr, old, new):
                span.location = new
                label.x = new
             
            slider.on_change('value', update_annotations)
             
            curdoc().add_root(row(plot, widgetbox(slider)))
            

            Show
            afausti Angelo Fausti added a comment - Another implementation using the same logic but updating the annotation parameters in the server side, avoiding the javascript callback. I think it is quite illustrative of bokeh's flexibility and worth to keep:   from bokeh.io import curdoc from bokeh.layouts import row, widgetbox from bokeh.models import Slider, Span, Label from bokeh.plotting import figure   slider = Slider(start = 0 , end = 10 , value = 3 , step = 0.1 , title = 'Slider' )   plot = figure(width = 700 , height = 250 , x_range = ( 0 , 10 ), y_range = ( - 1 , 1 )) span = Span(location = slider.value, dimension = 'height' ) plot.add_layout(span) label = Label(x = slider.value, y = 0 , x_units = 'data' , y_units = 'data' , text = "Minimum" )   plot.add_layout(label)   def update_annotations(attr, old, new): span.location = new label.x = new   slider.on_change( 'value' , update_annotations)   curdoc().add_root(row(plot, widgetbox(slider)))
            Hide
            afausti Angelo Fausti added a comment - - edited

            Added annotations for the mininum specification, design specification and stretch goals - it took me a while to figure out how to update the annotation parameters dynamically after changing the metric in the bokeh app.

            Since the annotations are not interpreted as data, they do not affect the plot limits which is good. So the ability to turn annotations on/off is not required.

            Show
            afausti Angelo Fausti added a comment - - edited Added annotations for the mininum specification, design specification and stretch goals - it took me a while to figure out how to update the annotation parameters dynamically after changing the metric in the bokeh app. Since the annotations are not interpreted as data, they do not affect the plot limits which is good. So the ability to turn annotations on/off is not required.
            Hide
            afausti Angelo Fausti added a comment -
            Show
            afausti Angelo Fausti added a comment - More info in the PR https://github.com/lsst-sqre/qa-dashboard/pull/14
            Hide
            afausti Angelo Fausti added a comment -

            Not reviewed.

            Review can be done in DM-7612

            Show
            afausti Angelo Fausti added a comment - Not reviewed. Review can be done in DM-7612

              People

              • Assignee:
                afausti Angelo Fausti
                Reporter:
                afausti Angelo Fausti
                Reviewers:
                Jonathan Sick
                Watchers:
                Angelo Fausti, Jonathan Sick
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel