cmkimber / Elections_Ontario_App

Webapp to explore Elections Ontario data
0 stars 0 forks source link

unregistered plotly_hover event warning #17

Open cmkimber opened 2 months ago

cmkimber commented 2 months ago

The application currently gives a console warning stemming from the use of plotly_hover to trigger the data table in pane 3. This does not affect the functioning of the webapp. The warning is as follows:

Warning: The 'plotly_hover' event tied a source ID of 'A' is not registered. In order to obtain this event data, please add event_register(p, 'plotly_hover') to the plot (p) that you wish to obtain event data from.

One possible solution is just to suppress the warning. Another is to figure out if registering the event in event_register() will actually suppress the warning without functional changes.

Carson Sievert recommends using a req(!is.null) call to ensure there are no issues with the plotly_hover being empty before it is first used. At present, the req(!is.null) call is used in the DT::renderDataTable() expression to ensure a year has been hovered over before the table is triggered. Requiring a non-null value for plotly_hover in the observe() that saves out the x value from the hover suppresses the warning but does not work beacause it will by definition be null before the first hover.