aukedejong / lovelace-windrose-card

Home Assistant Lovelace Windrose Card
82 stars 3 forks source link

Card Dynamically Keeps Growing and Growing in Size #50

Closed kaijk closed 2 weeks ago

kaijk commented 9 months ago

I'm using this card within the custom:layout-card to create a weather page using a grid layout like this:

  - type: custom:layout-card
    layout_type: grid-layout
    layout:
     grid-template-columns: 3fr 3fr repeat(6, 1fr) 
     grid-column-gap: 0px
     grid-row-gap: 0px
     grid-template-rows: 30px 235px 235px 200px 200px
     grid-template-areas: |
       "   .           .        .        .       .      . temp-hist header"
       "windy       windy   graph1   graph1 graph1 summary summary summary"
       "windy       windy   graph2   graph2 graph2 summary summary summary"
       "windrose   rain2   hour1    hour2   hour3    hour4   hour5  hour6"
       "windrose   rain2   hour7    hour8   hour9   hour10  hour11 hour12"  

When I include the windrose card the view starts dynamically growing. The windrose card expands compressing the fields to the right as if ignoring the frs.

I've tried both with and without the max_width parameter and replacing the windy iframe with a markdown card. (Windy grows as well, but not until the windrose is included.) This all worked fine until I included the windrose. Note, the black areas in the screenshot are other graphs that don't render after including the windrose.

Of course, this may not be an issue with this card, but it happens when adding the card to an existing layout. This is immediately after a View Refresh: image Then, a few seconds after the View Refresh: Windrose grows only to the right (with the max_width set) which drags the iframe down and right proportionally. image This is the happy and stable view without including the windrose card into the lower left corner. image

Here is the complete windrose card definition.

type: custom:windrose-card
title: Wind direction
view_layout:
  grid-row-start:       windrose
  grid-row-end:        windrose
  grid-column-start: windrose
  grid-column-end:  windrose
data_period:
  hours_to_show: 24
refresh_interval: 60
max_width: 350
windspeed_bar_full: true
windspeed_bar_location: right
wind_direction_entity:
  entity: sensor.gw2000b_wind_direction
  direction_unit: degrees
  use_statistics: false
  direction_compensation: 0
windspeed_entities:
  - entity: sensor.gw2000b_wind_speed
    name: Average
    speed_unit: auto
    use_statistics: false
  - entity: sensor.gw2000b_wind_gust
    name: Gust
    speed_unit: auto
    use_statistics: false
output_speed_unit: mph
speed_range_beaufort: false
speed_ranges:
  - from_value: 0
    color: rgb(0,255,0)
  - from_value: 1
    color: yellow
  - from_value: 5
    color: hsl(200, 100%, 60%)
  - from_value: 10
    color: orange
  - from_value: 20
    color: red
#speed_range_beaufort: true
windrose_draw_north_offset: 0
cardinal_direction_letters: NESW
matching_strategy: direction-first
center_calm_percentage: true
kaijk commented 9 months ago

Drilling down into the Insepctor, I see this for the card:

                <div class="card-content">
                    <canvas id="windRose" width="13861" height="186">
                    </canvas>
                </div>

Width just keeps growing, by itself

kaijk commented 9 months ago

I find that specifying width: and height: using card_mod stops the behavior. It appears that the card does not play well when the grid is defined using fr notation (see grid-template-columns: at the beginning above).

The challenge and why I'm using fr notation is that I'm deploying this on devices having differed screen widths. Fixing this card at 400px wide won't work. I like the card and would appreciate any insights.

card_mod:
  style: |
    ha-card {
      width: 400px;
      heigth: 400px;
    }
daaf84 commented 9 months ago

Same here... Used Cardmod for now, but it messes uptime alignment of the rose in the border of the card.

aukedejong commented 6 months ago

I'm trying to find the time to rewrite the render code to use vector graphics. Hopefully this will fix the problems described here.

RedNo7 commented 1 month ago

just installed this card and am having the same problem. Looking forward to the fix 👍 ...for now it is not useable.

kaijk commented 1 month ago

I made my own windrose card using Plotly. https://github.com/dbuezas/lovelace-plotly-graph-card/discussions/369

On Sat, Aug 31, 2024 at 12:19 AM RedNo7 @.***> wrote:

just installed this card and am having the same problem. Looking forward to the fix 👍 ...for now it is not useable.

— Reply to this email directly, view it on GitHub https://github.com/aukedejong/lovelace-windrose-card/issues/50#issuecomment-2322810283, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL2THYVD3YUJKB3FFTMTMADZUFVBHAVCNFSM6AAAAABASKOYIWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMRSHAYTAMRYGM . You are receiving this because you authored the thread.Message ID: @.***>

aukedejong commented 2 weeks ago

Released a new version with vector graphics. Hopefully this will fix the rendering problems you experience.

Please let me know.

RedNo7 commented 2 weeks ago

Hi - thanks for looking into this - just installed v 1.6.0 but it still slowly increases in size.

aukedejong commented 2 weeks ago

Are you sure the new version is loaded? Mo browser cache issues?

Before the card rerendered after a size change. I assumed it had to do with that piece of code. This is now removed, because the browser scales the vector graphics.

I have no idea how to fix this.

RedNo7 commented 2 weeks ago

crap - my bad - yes, it was cache and is now working perfectly! 👍

...I restarted HA thinking that was enough (but was running it in the app (not the browser which I would have cleared). Sorry for the confusion there.