ultrasoundmoney / frontend

ultrasound.money frontend
https://ultrasound.money
MIT License
216 stars 73 forks source link

When selecting "SIMULATE PoW", the graph y-axis updates (needlessly lowering the y-axis starting point) when a new data point comes in. #246

Open alextes opened 1 year ago

alextes commented 1 year ago

https://user-images.githubusercontent.com/2011351/201222265-a011900a-64be-4809-950e-51b903c1389c.mov

Was able to reproduce it after a while. It depends a bit on the screensize and perhaps even the size of the delta of the new data point. It doesn't happen for me on the since_merge time frame for example.

I'm not sure how highcharts picks its chart dimensions. Things I can come up with:

  1. Lock the min and max. This would require us writing our own function to pick bounds given a set of sets of points. As it needs to work across time frames and with a single or multiple series.
  2. Try to force the chart to redraw after the simulate button is pressed. I believe highcharts has a method for this after you capture a ref. An example may be found in the TwoYearProjection.

imo not worth it for the small gain of the axis not shifting on the first point. Depending on how large the supply changes are relative to the chart range I'd argue we want the y-range to be shifting. You could add another layer of complexity and only take over the min / max in select scenarios, but which? Furthermore, that still doesn't guarantee anything of course. It may well have to do with how the x-axis shifts. It all depends on how highcharts works which is magic (but works quite well!).

Finally also consider this doesn't even happen on every time frame, only some, depending on screen size, and maybe point delta it seems.

Another objection that comes to mind to pouring more time into this, especially suggestion 1. is that we already were controlling the min and max. I don't remember why we did it. Something to do with the animation I believe. In addition, the way we did it was by making the series transparent to keep the chart stable. Either way, I took it out when multiple time frames were introduced as those required more complex min / max control than we had. Putting it back in feels like moving against the current (i.e. stacking complexity higher than already proved sustainable).

The component counts ~700 LOC, let's try to make it simpler. Not more complex. If someone has an idea to make the chart simpler and fix this, even through design changes, I'm all ears.

  1. Could be worth giving a shot. Not enough for me to spend time I think but if someone has some time left go for it 👍 .