Skip to content

Commit 178832c

Browse files
committed
chart
1 parent f87c7f8 commit 178832c

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

app/views/assistants/show.html.erb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,22 @@
7070
const ctx = document.getElementById('chatsPerDayChart');
7171
if (!ctx) return;
7272

73+
// Check if Chart.js is loaded, if not wait for it
74+
if (typeof Chart === 'undefined') {
75+
// Wait for Chart.js to load
76+
const checkChart = setInterval(() => {
77+
if (typeof Chart !== 'undefined') {
78+
clearInterval(checkChart);
79+
createChart(ctx);
80+
}
81+
}, 100);
82+
return;
83+
}
84+
85+
createChart(ctx);
86+
}
87+
88+
function createChart(ctx) {
7389
// Destroy existing chart if it exists to prevent duplicates
7490
if (window.chatsChart) {
7591
window.chatsChart.destroy();

0 commit comments

Comments
 (0)