Fix Google Charts loading for AJAX-loaded bar graph

The issue was that google.load() doesn't work reliably when called
from AJAX-loaded content. The callback wasn't firing.

Solution:
- Load Google Charts library once in main application.html.erb layout
- Bar graph partial now just polls for google.visualization to be ready
- Uses retry logic (50 attempts @ 100ms = 5 second timeout)
- Returns success/failure boolean for proper flow control
- Removed duplicate script loading from partial

This ensures Google Charts is available globally for all chart views
(bar graphs, pie charts, performance charts) without timing issues.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Ken Johnson
2025-12-07 02:31:36 -05:00
parent b47a70d8b8
commit 8abf409041
4 changed files with 37 additions and 30 deletions
+9
View File
@@ -29,6 +29,15 @@
<!-- Bootstrap JS - loaded last -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<!-- Google Charts - load once globally for dashboard charts -->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
// Load Google Charts library once for the entire application
if (typeof google !== 'undefined' && google.load) {
google.load("visualization", "1", {packages:["corechart"]});
}
</script>
<!-- Modern Design System -->
<style>
:root {