overthesun / simoc-web

This is the web interface to SIMOC
https://ngs.simoc.space/
Other
3 stars 0 forks source link

Implement graph zooming and panning #729

Open ezio-melotti opened 1 month ago

ezio-melotti commented 1 month ago

Currently all panels (and consequently the graphs they contain) have two separate "modes": fullscreen and "regular" (i.e. not fullscreen). When they are fullscreen the graphs show all the steps; when they are not they only show the last 24 steps (at least in simulation mode, with 1 step for each hour).

In regular mode the following things happen:

  1. The data for the current step and the 23 steps before it are loaded in the dataset array of the graph. If there are no steps before it, "empty slots" are added to ensure that there are 24 values in the array and in the graph.
  2. Each second, the current step is increased by one, the oldest step in the array is removed and the next step is added, so that the graph keeps shifting on the left by one step every second. The scrubber determines the current step, and all the graphs are aligned/synchronized with it.

If we implement zooming/panning for regular panel/graphs, we need to decide how to handle a few things:

Because of these issues, I think we are better off implementing zooming only on the fullscreen graphs. Panning could be implemented for regular graphs too, even though it doesn't add much -- only the ability to drag any graph in addition to the scrubber. We could possibly add a way to dynamically change the number of steps to implement some sort of global zoom.

For fullscreen panels/graphs things should be easier -- we could:

For this, I'm currently using https://www.chartjs.org/chartjs-plugin-zoom/latest/