Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tooltips remain after a filter removes the element from the track #206

Open
abought opened this issue Sep 3, 2020 · 3 comments
Open

Tooltips remain after a filter removes the element from the track #206

abought opened this issue Sep 3, 2020 · 3 comments
Labels

Comments

@abought
Copy link
Member

abought commented Sep 3, 2020

Filtering operations allow controlling which elements are rendered.

However, an open tooltip will remain even after its parent element has been removed by a filter + re-render operation.

Steps to reproduce

See coaccessibility demo:
https://statgen.github.io/locuszoom/examples/coaccessibility.html

  1. Click on a loop with score = 0.5
  2. Using the textbox widget, apply a filter (score >= 0.9)
  3. See tooltip remain

Initial diagnosis

It appears that the rendering pipeline operates on this.data (the unfiltered set)- effectively, global state. When we re-render, the preserved internal state ("a tooltip was here") sees an annotation for an element with a matching entry in this.data, and concludes it is safe to redraw this element.

We'll need to refactor our rendering pipeline towards a more functional style so that tooltips are drawn based on the filtered set as determined by the render function.

Links:

tooltips are rendered based on this.data, but arcs are rendered based on applyFilters. Thus, a tooltip can be drawn for an element that isn't really there!

  • When a datalayer is rendered, it decides whether to draw any "state" values that it remembers. This includes "show tooltip". State decisions are based on the full, unfiltered data
  • When a data layer is rendered, it also decides whether to draw any arcs. This is a separate decision: the filtered dataset is known only to the render function.
  • The function that sets element status may be called more than once, before, or after, the render function.

Other notes

The internal store of tooltip state also has some bugs: it is not always clearing the has_tooltip annotation successfully, even when a tooltip is deselected. The best fix would probably to simplify and "linearize" the existing rendering pipeline- it's super tangled, and state is passed from many different places.

@abought abought added the bug label Sep 3, 2020
@abought
Copy link
Member Author

abought commented Sep 3, 2020

@Parul-Kudtarkar , here's the debug code we wrote during the call. Essentially, any time any function in any data layer is called, this code writes a message to the console that looks like this:

Called data layer method getElementId for layer Arcs

https://github.com/abought/locuszoom/blob/demo/instrument-callers/esm/registry/data_layers.js#L12-L21

@abought
Copy link
Member Author

abought commented Jan 14, 2021

Kenneth at the Broad also reports seeing this in some match events. He may add more details to the ticket later.

@kennethbruskiewicz
Copy link

kennethbruskiewicz commented Jan 14, 2021

When I click on a new match in one datalayer, and then I click on another in the other datalayer, the tooltip which popped up in the previous layer then pops up again.

The result is two tooltips being displayed, and the second tooltip irrelevant to the match not changing its type.

I'm using v13 beta-3. This is the config

        this.plot.addPanel(LocusZoom.Layouts.get("panel", "association_catalog", {
            data_layers: [
                LocusZoom.Layouts.get("panel", "association_catalog").data_layers[0],
                LocusZoom.Layouts.get("panel", "association_catalog").data_layers[1],
                LocusZoom.Layouts.get('data_layer', 'association_pvalues_catalog', {
                    match: { send: 'assoc:position', receive: 'assoc:position' },
                    color: [
                            {
                                field: 'lz_highlight_match',  // Special field name whose presence triggers custom rendering
                                scale_function: 'if',
                                parameters: {
                                    field_value: true,
                                    then: 'red'
                                }
                            },
                            ...LocusZoom.Layouts.get('data_layer', 'association_pvalues_catalog', { unnamespaced: true }).color,
                    ]
                })
            ]
        }))
      this.plot.addPanel(LocusZoom.Layouts.get("panel", "annotation_catalog", {
          data_layers: [
              Object.assign(LocusZoom.Layouts.get("panel", "annotation_catalog").data_layers[0], {
                  match: { send: 'catalog:pos', receive: 'catalog:pos' },
                  color: [
                          {
                              field: 'lz_highlight_match',  // Special field name whose presence triggers custom rendering
                              scale_function: 'if',
                              parameters: {
                                  field_value: true,
                                  then: 'red'
                              }
                          },
                          ...LocusZoom.Layouts.get('panel', 'annotation_catalog').data_layers[0].color,
                  ]
              })
          ]
      }))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants