{"id":386,"date":"2026-04-10T00:15:17","date_gmt":"2026-04-09T15:15:17","guid":{"rendered":"https:\/\/athealthdesign.co.jp\/?page_id=386"},"modified":"2026-04-10T01:24:35","modified_gmt":"2026-04-09T16:24:35","slug":"ai%e9%8c%ac%e8%8f%8c%e8%a1%93%e3%80%80%e7%b5%b1%e8%a8%88%ef%bd%a5%e9%9b%86%e8%a8%88","status":"publish","type":"page","link":"https:\/\/athealthdesign.co.jp\/?page_id=386","title":{"rendered":"AI\u932c\u83cc\u8853\u3000\u7d71\u8a08\uff65\u96c6\u8a08"},"content":{"rendered":"\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/PapaParse\/5.3.0\/papaparse.min.js\"><\/script>\n<script src=\"https:\/\/cdn.jsdelivr.net\/npm\/chart.js\"><\/script>\n\n<div class=\"st-wrapper bg-slate-50 p-4 md:p-8 rounded-xl border border-slate-200\">\n    <header class=\"st-header mb-8 pb-4 border-b border-emerald-100\">\n        <div class=\"flex justify-between items-center flex-wrap gap-4\">\n            <div class=\"flex items-center gap-4\">\n                <a href=\"https:\/\/athealthdesign.co.jp\/?page_id=345\" class=\"st-btn-back\">\u2190 \u623b\u308b<\/a>\n                <h1 class=\"text-2xl font-extrabold text-emerald-900 m-0\">AI\u932c\u83cc\u8853 <span class=\"text-emerald-500 text-lg\">Statistics<\/span><\/h1>\n            <\/div>\n            <p class=\"text-[10px] text-gray-400 bg-white px-2 py-1 rounded border\">v4.0.20 - PFC Percentage Fix<\/p>\n        <\/div>\n    <\/header>\n\n    <div id=\"st-page-top\" class=\"st-upload-area\">\n        <div class=\"mb-10\">\n            <input type=\"file\" id=\"st-csv-file\" accept=\".csv\" style=\"display:none !important;\">\n            <button type=\"button\" onclick=\"document.getElementById('st-csv-file').click()\" class=\"st-main-upload-btn\">\n                \ud83d\udcc1 CSV\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\n            <\/button>\n            <p id=\"st-status\" class=\"mt-6 text-base text-gray-600 font-bold\">\n                \u300cdaily.csv\u300d\u3092\u9078\u629e\u3057\u3066\u932c\u6210\u3092\u958b\u59cb\u3057\u3066\u304f\u3060\u3055\u3044\n            <\/p>\n        <\/div>\n        \n        <div class=\"flex justify-center gap-4 flex-wrap\">\n            <button class=\"st-mode-btn\" id=\"st-btn-week\" onclick=\"initStPage('C')\" disabled>\u9031\u9593 (\u65e5\u6b21\u63a8\u79fb)<\/button>\n            <button class=\"st-mode-btn\" id=\"st-btn-month\" onclick=\"initStPage('B')\" disabled>\u6708\u9593 (\u9031\u6b21\u63a8\u79fb)<\/button>\n            <button class=\"st-mode-btn\" id=\"st-btn-year\" onclick=\"initStPage('A')\" disabled>\u5e74\u9593 (\u6708\u6b21\u63a8\u79fb)<\/button>\n        <\/div>\n    <\/div>\n\n    <div id=\"st-page-report\" class=\"st-hide\">\n        <div class=\"flex justify-between items-center mb-6 flex-wrap gap-3\">\n            <button onclick=\"goStBack()\" class=\"bg-slate-500 text-white px-4 py-2 rounded-lg text-sm font-bold hover:bg-slate-600 transition shadow-sm\">\u2190 \u30d5\u30a1\u30a4\u30eb\u9078\u629e\u306b\u623b\u308b<\/button>\n            <div class=\"flex gap-2\">\n                <button class=\"st-nav-btn\" onclick=\"changeStPeriod(-1)\">\u25c0 \u524d<\/button>\n                <button id=\"st-btn-current\" class=\"st-nav-btn\" onclick=\"resetStPeriod()\">\u73fe\u5728<\/button>\n                <button class=\"st-nav-btn\" onclick=\"changeStPeriod(1)\">\u6b21 \u25b6<\/button>\n            <\/div>\n        <\/div>\n\n        <h2 id=\"st-view-title\" class=\"text-center text-xl font-bold text-emerald-800 mb-6 border-b-2 border-emerald-500 pb-2\">\u671f\u9593\u30bf\u30a4\u30c8\u30eb<\/h2>\n        \n        <div class=\"st-summary-container mb-8\" id=\"st-summary-cards\"><\/div>\n\n        <div class=\"bg-white p-4 md:p-6 rounded-xl shadow-sm border border-slate-200 mb-8\">\n            <div class=\"flex justify-center gap-2 mb-6 flex-wrap\">\n                <button id=\"st-g-kcal\" class=\"st-graph-tab\" onclick=\"updateStGraph('kcal')\">\u6442\u53d6Kcal<\/button>\n                <button id=\"st-g-pfc\" class=\"st-graph-tab\" onclick=\"updateStGraph('pfc')\">PFC(%)<\/button>\n                <button id=\"st-g-weight\" class=\"st-graph-tab\" onclick=\"updateStGraph('weight')\">\u4f53\u91cd\u30fb\u53ce\u652f<\/button>\n            <\/div>\n            <div class=\"st-graph-container\" id=\"st-chart-box\">\n                <canvas id=\"stMainChart\"><\/canvas>\n            <\/div>\n        <\/div>\n\n        <div class=\"overflow-x-auto bg-white rounded-xl shadow-sm border border-slate-200\">\n            <table class=\"st-table\">\n                <thead id=\"st-thead\"><\/thead>\n                <tbody id=\"st-tbody\"><\/tbody>\n            <\/table>\n        <\/div>\n    <\/div>\n<\/div>\n\n<style>\n.st-hide { display: none !important; }\n.st-wrapper { font-family: 'Noto Sans JP', sans-serif; color: #1e293b; }\n.st-btn-back { color: #10b981 !important; font-weight: bold; text-decoration: none !important; font-size: 0.9rem; }\n\n\/* \u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u30a8\u30ea\u30a2 *\/\n.st-upload-area { padding: 40px 10px; text-align: center; }\n.st-main-upload-btn { background: #10b981 !important; color: #fff !important; padding: 15px 35px !important; font-size: 1.1rem !important; font-weight: bold; border-radius: 12px; border: none; cursor: pointer; }\n\n\/* \u671f\u9593\u9078\u629e\u30dc\u30bf\u30f3 *\/\n.st-mode-btn { background: #fff; border: 1px solid #e2e8f0; color: #94a3b8; padding: 10px 20px; border-radius: 10px; font-weight: bold; }\n.st-mode-btn:not(:disabled) { color: #1e293b; border-color: #cbd5e1; cursor: pointer; }\n\n\/* \u30b5\u30de\u30ea\u30fc\u30ab\u30fc\u30c9\u306e\u30b5\u30a4\u30ba\u8abf\u6574 *\/\n.st-summary-container {\n    display: grid !important;\n    grid-template-columns: repeat(2, 1fr) !important;\n    gap: 12px !important;\n}\n@media (min-width: 768px) {\n    .st-summary-container { grid-template-columns: repeat(4, 1fr) !important; }\n}\n\n.st-card { background: #fff; padding: 20px 10px; border-radius: 12px; border: 1px solid #e2e8f0; text-align: center; display: block !important; }\n.st-card h3 { font-size: 0.75rem !important; color: #64748b !important; margin: 0 0 8px 0 !important; font-weight: bold; }\n.st-card .val { font-size: 1.25rem !important; font-weight: 800 !important; color: #10b981 !important; margin: 0 !important; }\n\n\/* \u30b0\u30e9\u30d5 *\/\n.st-graph-container { position: relative; width: 100%; height: 350px !important; }\n.st-nav-btn { background: #fff; border: 1px solid #e2e8f0; padding: 6px 15px; border-radius: 8px; font-size: 0.85rem; font-weight: bold; cursor: pointer; }\n.st-graph-tab { padding: 8px 18px; border-radius: 20px; border: 1px solid #e2e8f0; font-size: 0.8rem; font-weight: bold; background: #fff; cursor: pointer; }\n.st-graph-tab.active { background: #10b981; color: #fff !important; border-color: #10b981; }\n\n\/* \u30c6\u30fc\u30d6\u30eb *\/\n.st-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; min-width: 600px; }\n.st-table th { background: #f8fafc; padding: 10px; color: #475569; border-bottom: 2px solid #e2e8f0; text-align: center; }\n.st-table td { padding: 10px; border-bottom: 1px solid #f1f5f9; text-align: center; }\n<\/style>\n\n<script>\n    let stAllData = [];\n    let stCurrentMode = 'C';\n    let stRefDate = new Date();\n    let stChartInstance = null;\n    let stGraphType = 'kcal';\n    let stCache = [];\n\n    document.getElementById('st-csv-file').addEventListener('change', e => {\n        const file = e.target.files[0];\n        if (!file) return;\n        Papa.parse(file, {\n            header: true, dynamicTyping: true, skipEmptyLines: true,\n            complete: res => {\n                stAllData = res.data.filter(d => d.date).sort((a,b) => new Date(a.date) - new Date(b.date));\n                document.getElementById('st-status').innerText = `\u89e3\u6790\u5b8c\u4e86: ${stAllData.length}\u65e5\u5206\u3002\u5206\u6790\u30e2\u30fc\u30c9\u3092\u9078\u629e\u3057\u3066\u304f\u3060\u3055\u3044\u3002`;\n                document.getElementById('st-status').style.color = \"#10b981\";\n                document.getElementById('st-btn-week').disabled = false;\n                document.getElementById('st-btn-month').disabled = false;\n                document.getElementById('st-btn-year').disabled = false;\n            }\n        });\n    });\n\n    function initStPage(m) {\n        stCurrentMode = m;\n        document.getElementById('st-page-top').classList.add('st-hide');\n        document.getElementById('st-page-report').classList.remove('st-hide');\n        renderSt();\n    }\n\n    function goStBack() {\n        resetStChart();\n        document.getElementById('st-page-report').classList.add('st-hide');\n        document.getElementById('st-page-top').classList.remove('st-hide');\n    }\n\n    function changeStPeriod(d) {\n        if(stCurrentMode==='A') stRefDate.setFullYear(stRefDate.getFullYear()+d);\n        else if(stCurrentMode==='B') stRefDate.setMonth(stRefDate.getMonth()+d);\n        else stRefDate.setDate(stRefDate.getDate()+(d*7));\n        renderSt();\n    }\n    function resetStPeriod() { stRefDate = new Date(); renderSt(); }\n\n    function resetStChart() {\n        if(stChartInstance) {\n            stChartInstance.destroy();\n            stChartInstance = null;\n        }\n    }\n\n    function renderSt() {\n        let start, end;\n        const d = new Date(stRefDate);\n        if(stCurrentMode==='A') { \n            start = new Date(d.getFullYear(), 0, 1); \n            end = new Date(d.getFullYear(), 11, 31);\n        } else if(stCurrentMode==='B') { \n            start = new Date(d.getFullYear(), d.getMonth(), 1); \n            end = new Date(d.getFullYear(), d.getMonth() + 1, 0);\n        } else {\n            const day = d.getDay();\n            const diff = d.getDate() - day + (day === 0 ? -6 : 1);\n            start = new Date(d.getFullYear(), d.getMonth(), diff);\n            start.setHours(0,0,0,0);\n            end = new Date(start); end.setDate(start.getDate() + 6); end.setHours(23,59,59);\n        }\n        const filtered = stAllData.filter(r => { const rd = new Date(r.date); return rd >= start && rd <= end; });\n        document.getElementById('st-view-title').innerText = `${start.toLocaleDateString()} \u301c ${end.toLocaleDateString()}`;\n        \n        stCache = processStData(filtered);\n        updateStSummary(filtered);\n        updateStTable(stCache);\n        \n        if (stCache && stCache.length > 0) {\n            drawStChart(stGraphType);\n        } else {\n            resetStChart();\n        }\n    }\n\n    function processStData(data) {\n        if(!data || data.length === 0) return [];\n        if(stCurrentMode === 'C') return data.map(d => ({...d, label: `${new Date(d.date).getMonth()+1}\/${new Date(d.date).getDate()}`}));\n        const groups = {};\n        data.forEach(d => {\n            const dt = new Date(d.date);\n            let key = stCurrentMode === 'A' ? (dt.getMonth()+1)+'\u6708' : '\u7b2c'+Math.ceil(dt.getDate()\/7)+'\u9031';\n            if(!groups[key]) groups[key] = []; groups[key].push(d);\n        });\n        return Object.keys(groups).map(k => {\n            const g = groups[k];\n            const avg = key => g.reduce((a,b)=>a+(b[key]||0),0)\/g.length;\n            return { label: k, energy_kcal: avg('energy_kcal'), protein_g: avg('protein_g'), fat_g: avg('fat_g'), carb_g: avg('carb_g'), fiber_total_g: avg('fiber_total_g'), body_weight_kg: avg('body_weight_kg'), energy_balance_kcal: avg('energy_balance_kcal'), exercise_time_min_total: avg('exercise_time_min_total')};\n        });\n    }\n\n    function updateStGraph(type) { stGraphType = type; drawStChart(type); }\n\n    function drawStChart(type) {\n        const data = stCache;\n        if(!data || data.length === 0) {\n            resetStChart();\n            return;\n        }\n        \n        document.querySelectorAll('.st-graph-tab').forEach(b => b.classList.remove('active'));\n        const targetBtn = document.getElementById('st-g-'+type);\n        if(targetBtn) targetBtn.classList.add('active');\n        \n        const ctx = document.getElementById('stMainChart').getContext('2d');\n        resetStChart();\n        \n        const labels = data.map(d => d.label);\n        let datasets = [], options = { maintainAspectRatio: false, scales: { x: { grid: { display: false } } } };\n        \n        if(type === 'kcal') {\n            datasets = [{ label: '\u6442\u53d6Kcal', data: data.map(d => d.energy_kcal), borderColor: '#10b981', backgroundColor: 'rgba(16, 185, 129, 0.1)', fill: true, tension: 0.3 }];\n        } else if(type === 'pfc') {\n            \/\/ \u30ab\u30ed\u30ea\u30fc\u30d9\u30fc\u30b9\u306e\u6bd4\u7387(%)\u3092\u8a08\u7b97\n            const pfcRates = data.map(d => {\n                const pKcal = (d.protein_g || 0) * 4;\n                const fKcal = (d.fat_g || 0) * 9;\n                const cKcal = (d.carb_g || 0) * 4;\n                const total = pKcal + fKcal + cKcal;\n                return {\n                    p: total > 0 ? (pKcal \/ total * 100) : 0,\n                    f: total > 0 ? (fKcal \/ total * 100) : 0,\n                    c: total > 0 ? (cKcal \/ total * 100) : 0\n                };\n            });\n            datasets = [\n                { label: 'P (%)', data: pfcRates.map(r => r.p.toFixed(1)), backgroundColor: '#f472b6' },\n                { label: 'F (%)', data: pfcRates.map(r => r.f.toFixed(1)), backgroundColor: '#60a5fa' },\n                { label: 'C (%)', data: pfcRates.map(r => r.c.toFixed(1)), backgroundColor: '#fbbf24' }\n            ];\n            options.scales.x.stacked = true; \n            options.scales.y = { \n                stacked: true,\n                min: 0,\n                max: 100,\n                ticks: { callback: (v) => v + '%' }\n            };\n        } else if(type === 'weight') {\n            datasets = [\n                { label: '\u4f53\u91cd(kg)', data: data.map(d => d.body_weight_kg), borderColor: '#3b82f6', yAxisID: 'y' },\n                { label: '\u53ce\u652f(kcal)', data: data.map(d => d.energy_balance_kcal), borderColor: '#f87171', yAxisID: 'y1', borderDash: [5, 5] }\n            ];\n            options.scales.y1 = { position: 'right', grid: { drawOnChartArea: false } };\n        }\n        stChartInstance = new Chart(ctx, { type: (type === 'pfc' ? 'bar' : 'line'), data: { labels, datasets }, options });\n    }\n\n    function updateStSummary(data) {\n        const target = document.getElementById('st-summary-cards');\n        if(!data || data.length === 0) { \n            target.innerHTML = \"<div class='col-span-full text-center py-6 text-gray-400 font-bold'>\u8868\u793a\u671f\u9593\u5185\u306e\u30c7\u30fc\u30bf\u304c\u3042\u308a\u307e\u305b\u3093<\/div>\"; \n            return; \n        }\n        const avg = k => (data.reduce((s,x)=>s+(x[k]||0),0)\/data.length).toFixed(1);\n        target.innerHTML = `\n            <div class=\"st-card\"><h3>\u6442\u53d6\u5e73\u5747<\/h3><div class=\"val\">${avg('energy_kcal')} <small>kcal<\/small><\/div><\/div>\n            <div class=\"st-card\"><h3>\u98df\u7269\u7e4a\u7dad\u5e73\u5747<\/h3><div class=\"val\">${avg('fiber_total_g')} <small>g<\/small><\/div><\/div>\n            <div class=\"st-card\"><h3>\u53ce\u652f\u5e73\u5747<\/h3><div class=\"val\">${avg('energy_balance_kcal')} <small>kcal<\/small><\/div><\/div>\n            <div class=\"st-card\"><h3>\u4f53\u91cd\u5e73\u5747<\/h3><div class=\"val\">${avg('body_weight_kg')} <small>kg<\/small><\/div><\/div>\n        `;\n    }\n\n    function updateStTable(data) {\n        if(!data || data.length === 0) {\n            document.getElementById('st-tbody').innerHTML = \"<tr><td colspan='9' class='py-4'>\u30c7\u30fc\u30bf\u306a\u3057<\/td><\/tr>\";\n            return;\n        }\n        const head = stCurrentMode==='C' ? ['\u65e5\u4ed8','kcal','P','F','C','\u7e4a\u7dad','\u904b\u52d5','\u4f53\u91cd','\u53ce\u652f'] : ['\u671f\u9593','avg kcal','P','F','C','\u7e4a\u7dad','\u904b\u52d5','\u4f53\u91cd','\u53ce\u652f'];\n        document.getElementById('st-thead').innerHTML = `<tr>${head.map(h=>`<th>${h}<\/th>`).join('')}<\/tr>`;\n        document.getElementById('st-tbody').innerHTML = data.map(d => `<tr><td>${d.label}<\/td><td>${Math.round(d.energy_kcal)}<\/td><td>${d.protein_g.toFixed(1)}<\/td><td>${d.fat_g.toFixed(1)}<\/td><td>${d.carb_g.toFixed(1)}<\/td><td>${d.fiber_total_g.toFixed(1)}<\/td><td>${Math.round(d.exercise_time_min_total)}<\/td><td>${d.body_weight_kg.toFixed(1)}<\/td><td>${Math.round(d.energy_balance_kcal)}<\/td><\/tr>`).join('');\n    }\n<\/script>\n\n\n\n<p><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\ud83d\udee1\ufe0f\u30d7\u30e9\u30a4\u30d0\u30b7\u30fc\u4fdd\u8b77\u3068\u30c7\u30fc\u30bf\u306e\u5b89\u5168\u6027\u306b\u3064\u3044\u3066<br>\u672c\u30c4\u30fc\u30eb\u306f\u3001\u304a\u4f7f\u3044\u306e\u30d6\u30e9\u30a6\u30b6\u4e0a\u3067\u5168\u3066\u306e\u8a08\u7b97\u51e6\u7406\u3092\u884c\u3046\u300c\u30ed\u30fc\u30ab\u30eb\u5b8c\u7d50\u578b\u300d\u30b7\u30b9\u30c6\u30e0\u3067\u3059\u3002<br>\u30fb\u30c7\u30fc\u30bf\u306e\u975e\u4fdd\u6301: \u8aad\u307f\u8fbc\u3093\u3060\u300cdaily.csv\u300d\u306e\u5185\u5bb9\u304c\u5f53\u30b5\u30a4\u30c8\u306e\u30b5\u30fc\u30d0\u30fc\u306b\u9001\u4fe1\u30fb\u84c4\u7a4d\u3055\u308c\u308b\u3053\u3068\u306f\u4e00\u5207\u3042\u308a\u307e\u305b\u3093\u3002<br>\u30fb\u5b8c\u5168\u533f\u540d\u6027: \u7d71\u8a08\u30b0\u30e9\u30d5\u306e\u751f\u6210\u306f\u3001\u304a\u5ba2\u69d8\u306e\u30c7\u30d0\u30a4\u30b9\u5185\u3067\u306e\u307f\u5b9f\u884c\u3055\u308c\u307e\u3059\u3002<br>\u30fb\u4fdd\u5b58\u306e\u4ed5\u7d44\u307f: \u30da\u30fc\u30b8\u3092\u9589\u3058\u308b\u3068\u8aad\u307f\u8fbc\u3093\u3060\u30c7\u30fc\u30bf\u306f\u30ea\u30bb\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002\u518d\u5ea6\u5206\u6790\u3092\u884c\u3046\u969b\u306f\u3001\u304a\u624b\u5143\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u518d\u5ea6\u8aad\u307f\u8fbc\u3093\u3067\u304f\u3060\u3055\u3044\u3002<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u2190 \u623b\u308b AI\u932c\u83cc\u8853 Statistics v4.0.20 - PFC Percentage Fix \ud83d\udcc1 CSV\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080 \u300cdaily.csv\u300d\u3092\u9078\u629e\u3057\u3066\u932c\u6210\u3092\u958b\u59cb\u3057\u3066\u304f\u3060\u3055\u3044 \u9031\u9593 (\u65e5\u6b21\u63a8\u79fb) \u6708\u9593 (\u9031\u6b21\u63a8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":351,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"vkexunit_cta_each_option":"","footnotes":""},"class_list":["post-386","page","type-page","status-publish","has-post-thumbnail","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/pages\/386","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=386"}],"version-history":[{"count":12,"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/pages\/386\/revisions"}],"predecessor-version":[{"id":439,"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/pages\/386\/revisions\/439"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=\/wp\/v2\/media\/351"}],"wp:attachment":[{"href":"https:\/\/athealthdesign.co.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}