Skip to content

A live bird collage card for your Home Assistant dashboard.

Making charts more mobile friendly on "Today's Detections"

ehpersonal38534004acf6ea
diff --git a/scripts/todays_detections.php b/scripts/todays_detections.php
index 4251a50a..2c8355e2 100644
--- a/scripts/todays_detections.php
+++ b/scripts/todays_detections.php
@@ -656,7 +656,11 @@ function generateMiniGraph(elem, comname) {
// Position the chart window to the right of the button
var buttonRect = elem.getBoundingClientRect();
var chartRect = chartWindow.getBoundingClientRect();
- chartWindow.style.left = (buttonRect.right + 10) + 'px';
+ if (window.innerWidth < 700) {
+ chartWindow.style.left = 'calc(75% - ' + (chartRect.width / 2) + 'px)';
+ } else {
+ chartWindow.style.left = (buttonRect.right + 10) + 'px';
+ }
// Calculate the top position of the chart to center it with the button
var buttonCenter = buttonRect.top + (buttonRect.height / 2);