United4Surveillance / signal-detection-tool

A tool for detection of signals in infectious disease surveillance data.
Other
8 stars 0 forks source link

[BUG] Time series plot background vertical space can be too short or too tall #279

Closed tomasmartbert closed 6 months ago

tomasmartbert commented 6 months ago

Describe the Bug

The light-blue background on the time series plot demarcating the signal detection period is sometimes not covering the full vertical space in the coordinate system.

Currently, it is the non-stratified max weekly case numbers which determines the top edge of a rectangle making up the background, which in many cases is clipped to nicely fit the actual data window. The bug is most obviously seen from the ggplot2-facet plot in the non-interactive Report, see screen shot: Since implicit one-year filtering is applied here, there is a smaller chance that any case number is high enough relative to the threshold line to make the background appear good-looking on all facets: The thresholds are way above the case numbers.

It also possible, using input data with a decreasing case number trend over time, to have the interactive plot appear to have a too tall y-axis resulting in data looking squashed towards the x-axis.

Solution

The top edge of the background rectangle should be determined from the highest of case numbers and signal thresholds, and additionally adapt dynamically to the zoomed dates on the interactive plot.

To Reproduce

Steps to reproduce the behavior:

  1. Load input example data
  2. Input parameters: Choose stratify by county, EARS algorithm
  3. Check out the non-interactive Report, see the timeseries plots by county To see the same effect on the interactive plot, first filter the data on the input tab to retain only one year back.

Expected Behavior

The blue background colour ought to cover up the whole vertical space.

Screenshots / Code Snippets (if applicable) Here are shown the simulated example input data: image

If applicable, add screenshots, code snippets, or logs to help explain your problem.

Environment (please complete the following information):

Additional Context

Add any other context about the problem here.

tomasmartbert commented 6 months ago

Fixed for static facet plot in report (including fix for #277 WIP): image

Remaining issue The interactive plot should dynamically adjust the y-axis according to data shown. I'll explore a more plotly-based solution for the rectangle background.

tinneuro commented 6 months ago

Nice work!