Skip to content

fix: graph rendering too wide when heading title is too long#812

Merged
RomRider merged 1 commit intoRomRider:devfrom
brokeh:master
Jan 26, 2025
Merged

fix: graph rendering too wide when heading title is too long#812
RomRider merged 1 commit intoRomRider:devfrom
brokeh:master

Conversation

@brokeh
Copy link
Copy Markdown
Contributor

@brokeh brokeh commented Nov 10, 2024

The graph would previously render at the max width of either the card or the header, which if the header was too wide for the display would mean part of the graph would render outside of the card.

For me, I use small apex charts inside of Grid Cards and while the title of some of my charts easily fit in the charts on larger screens like computers and tables, on mobile phones the title is wider than the card and so part of the graph is rending outside of the card and is hidden even with only 1 or 2 words in the title.

Here is an example dashboard showing the problem. The only difference between the 2 charts is the length of the title.

views:
  - title: Apex Testing
    cards: null
    type: sections
    max_columns: 2
    sections:
      - type: grid
        cards:
          - type: custom:apexcharts-card
            header:
              show: true
              title: >-
                A super duper extra really long title to make the title too long
                for the card
            yaxis:
              - max: 144
            series:
              - entity: sensor.sun_next_dawn
                data_generator: |
                  const now = new Date();
                  const data = [];
                  for(let i = 0; i <= 24; i++) {
                    data.push([now.getTime() - i * 1000 * 60 * 60, Math.floor(((i-12) * (i-12)))])
                  }
                  return data.reverse();
      - type: grid
        cards:
          - type: custom:apexcharts-card
            header:
              show: true
              title: A shorter title that fits in the card
            yaxis:
              - max: 144
            series:
              - entity: sensor.sun_next_dawn
                data_generator: |
                  const now = new Date();
                  const data = [];
                  for(let i = 0; i <= 24; i++) {
                    data.push([now.getTime() - i * 1000 * 60 * 60, Math.floor(((i-12) * (i-12)))])
                  }
                  return data.reverse();

Before this change, it looks like this. Notice the parabola on the left is missing part of the right-hand side
image

And after this change, it displays the whole chart
image

The graph would previously render at the max width of either the card or the header, which if the header was too wide for the display would mean part of the graph would render outside of the card
@RomRider RomRider changed the base branch from master to dev January 26, 2025 08:50
@RomRider
Copy link
Copy Markdown
Owner

Thanks !

@RomRider RomRider merged commit 094280d into RomRider:dev Jan 26, 2025
donbcd added a commit to donbcd/apexcharts-card that referenced this pull request Feb 20, 2025
fix: graph rendering too wide when heading title is too long (RomRider#812)
github-actions Bot pushed a commit that referenced this pull request Aug 20, 2025
## 2.2.0-dev.1 (2025-08-20)

* chore: Update CI ([ad124f7](ad124f7))
* chore(ci): update action/cache ([899dce3](899dce3))
* chore(deps): bump actions/cache from 4.0.2 to 4.1.0 (#785) ([18b9c11](18b9c11)), closes [#785](#785)
* chore(deps): bump actions/checkout from 4 to 5 (#939) ([8dc5150](8dc5150)), closes [#939](#939)
* chore(deps): bump actions/setup-node from 4.0.2 to 4.0.4 (#779) ([505a35d](505a35d)), closes [#779](#779)
* chore(deps): bump actions/setup-node from 4.0.4 to 4.4.0 (#940) ([a8ba417](a8ba417)), closes [#940](#940)
* chore(dev): Remove leftover file ([2a63138](2a63138))
* chore(dev): update devcontainer ([3f4f63a](3f4f63a))
* feat: Display the card version on the card (useful for debugging) ([ac800c5](ac800c5))
* feat: Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736)
* fix: graph rendering too wide when heading title is too long (#812) ([094280d](094280d)), closes [#812](#812)
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.2.0-dev.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

github-actions Bot pushed a commit that referenced this pull request Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20)

### Features

* Display the card version on the card (useful for debugging) ([ac800c5](ac800c5))
* **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543)
* **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec))
* Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736)

### Bug Fixes

* graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d))
* Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f))

### Documentation

* Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949))
* Updated install instructions ([37f3fa2](37f3fa2))
github-actions Bot pushed a commit that referenced this pull request Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20)

### Features

* Display the card version on the card (useful for debugging) ([ac800c5](ac800c5))
* **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543)
* **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec))
* Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736)

### Bug Fixes

* graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d))
* Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f))

### Documentation

* Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949))
* Updated install instructions ([37f3fa2](37f3fa2))
github-actions Bot pushed a commit that referenced this pull request Aug 20, 2025
## [2.2.0](v2.1.2...v2.2.0) (2025-08-20)

### Features

* Display the card version on the card (useful for debugging) ([ac800c5](ac800c5))
* **series:** Add option to hide null or zero values in the header ([#544](#544)) ([baf2066](baf2066)), closes [#543](#543)
* **series:** Extend `stroke_dash` to support an array for more complex dashing patterns ([#902](#902)) ([cafbcec](cafbcec))
* Support for sections views using `section_mode` ([fe85144](fe85144)), closes [#927](#927) [#837](#837) [#904](#904) [#736](#736)

### Bug Fixes

* graph rendering too wide when heading title is too long ([#812](#812)) ([094280d](094280d))
* Text color selection for given background now takes into account human perception. ([#820](#820)) ([f09756f](f09756f))

### Documentation

* Fix typos and improve grammar in README.md ([#698](#698)) ([6655949](6655949))
* Updated install instructions ([37f3fa2](37f3fa2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants