// ui-chart.js — tiny wrapper for Chart.js usage (bar chart)
let chartInstance = null;

export function renderJamaahChart(canvasId = "chartJamaahHarian", values = []) {
  const ctx = document.getElementById(canvasId);
  if (!ctx || typeof Chart === "undefined") return;
  if (chartInstance) chartInstance.destroy();
  chartInstance = new Chart(ctx, {
    type: "bar",
    data: {
      labels: ["Subuh","Dzuhur","Ashar","Maghrib","Isya"],
      datasets: [{ label: "Jumlah", data: values, backgroundColor: ["#2d6a4f","#40916c","#52b788","#74c69d","#95d5b2"] }]
    },
    options: { plugins: { legend: { display: false } }, responsive: true, maintainAspectRatio: false }
  });
}
