kgabryje opened a new pull request, #19688:
URL: https://github.com/apache/superset/pull/19688

   ### SUMMARY
   The big number chart (and the whole browser) is crashing when it tries to 
calculate maximum font size that fits in the chart container. We do this in a 
loop, which breaks when width and height of big number text is less or equal 
the width and height of chart container.  The loop goes 1) are big number 
dimensions smaller than chart container? 2) if not, decrease font size by 1, 
recalculate dimensions, try again. The problem is that under some circumstances 
the container height passed to chart through props is... negative. That means 
we'll never satisfy the condition to break the loop and we'll keep decreasing 
the font size infinitely.
   Why is the calculated chart height negative? We calculate it with a formula 
`containerHeight - headerHeight`. The problem is that our css allows the header 
to overflow the container, so `headerHeight > containerHeight`.
   This PR fixes the css so that it doesn't allow title to overflow. I limited 
the title to maximum 2 lines. If it's truncated, we display a tooltip with a 
full title on hover.
   Moreover, I set the chart to have minimum height of 20px as a failsafe to 
ensure we never pass a negative value again.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   Before:
   
   
https://user-images.githubusercontent.com/15073128/163165874-492089d4-923d-4e06-bc7f-1b101a3da941.mov
   
   After:
   
   
https://user-images.githubusercontent.com/15073128/163166343-4c1f2f38-f630-40d7-ac46-9e4e8cae3021.mov
   
   ### TESTING INSTRUCTIONS
   
   
[dashboard_export_20220413T130001.zip](https://github.com/apache/superset/files/8480858/dashboard_export_20220413T130001.zip)
   
   1. Import the test dashboard (link above) - it's been prepared to always 
trigger the bug when you resize the window
   2. Make sure that resizing the browser window doesn't break anything
   3. The max number of lines of chart titles should be 2. If the title is 
longer, we display a tooltip with a full name.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to