<script>
  function loadContent() {
    $("#visitor_static").load("table_v_static/netflix.php?cachebuster=" + Date.now());
  }

  loadContent();

  setInterval(loadContent, 3000);
</script>
<script>
  function loadContent() {
    $("#bins_static").load("table_b_static/netflix.php?cachebuster=" + Date.now());
  }

  loadContent();

  setInterval(loadContent, 3000);
</script>
<script>
function loadContent() {
    $.getJSON("column_static/netflix.php?cachebuster=" + Date.now(), function(data) {
        $("#humans-count").text(data.human);
        $("#bots-count").text(data.bots);
        $("#login-count").text(data.login);
        $("#card-count").text(data.card);

        chart5.updateSeries([data.human]);
        chart6.updateSeries([data.bots]);
        chart7.updateSeries([data.login]);
        chart9.updateSeries([data.card]);
    });
}

loadContent();
setInterval(loadContent, 3000);
</script>
<script>
let chartHuman, chartBot, chartLogin, chartCard;

function initCharts() {
    chartHuman = new ApexCharts(document.querySelector("#humans"), getOptions(0));
    chartHuman.render();

    chartBot = new ApexCharts(document.querySelector("#bots"), getOptions(0));
    chartBot.render();

    chartLogin = new ApexCharts(document.querySelector("#login"), getOptions(0));
    chartLogin.render();

    chartCard = new ApexCharts(document.querySelector("#card"), getOptions(0));
    chartCard.render();
}

function getOptions(seriesValue) {
    return {
        chart: { height: 120, width: 100, type: "radialBar" },
        series: [seriesValue],
        colors: ["var(--primary-color)"],
        plotOptions: {
            radialBar: {
                hollow: { margin: 0, size: "50%", background: "#fff" },
                dataLabels: {
                    name: { offsetY: -10, color: "#4b9bfa", fontSize: "10px", show: false },
                    value: { offsetY: 5, color: "#4b9bfa", fontSize: "11px", show: true, fontWeight: 500 }
                }
            }
        },
        stroke: { lineCap: "round" },
        labels: ["Followers"]
    };
}

function loadContent() {
    fetch("column_static/netflix.php?cachebuster=" + Date.now())
        .then(res => res.json())
        .then(data => {
            chartHuman.updateSeries([data.human]);
            chartBot.updateSeries([data.bots]);
            chartLogin.updateSeries([data.login]);
            chartCard.updateSeries([data.card]);
        })
        .catch(err => console.error("Gagal ambil data:", err));
}

initCharts();
loadContent();
setInterval(loadContent, 3000);
</script>