XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

EARSystem

【ASP】耳间,网页端的情绪智能推荐系统

公开
关注 0 Fork 0 Star 0
UTF-8
(() => {
    let chart;
    window.refreshHomeChart = async () => {
        try {
            const points = await EAR.api('/api/reports/trend?days=7');
            const colors = ['#7e9c73','#d9bf75','#b2accb'];
            const data = { labels: points.map(x => x.date.slice(5).replace('-','.')), datasets: ['mood','energy','stress'].map((key,i) => ({
                label: ['心情','精力','压力'][i], data: points.map(x => x[key]), borderColor: colors[i], backgroundColor: colors[i],
                tension: .35, pointRadius: 3, borderWidth: 2, spanGaps: false })) };
            if(chart) { chart.data = data; chart.update(); return; }
            chart = new Chart(document.getElementById('home-trend'), { type: 'line', data, options: { responsive: true, maintainAspectRatio: false,
                plugins: { legend: { display: false } }, scales: { y: { min: 1, max: 5, ticks: { stepSize: 1, color:'#a5ad9c', font: { size:9 } }, grid: { color:'#f0f2e9' }, border: { display:false } }, x: { ticks: { color:'#a5ad9c', font:{size:9} }, grid: { display:false }, border: { display:false } } } } });
        } catch(error) { EAR.toast(error.message, true); }
    };
    refreshHomeChart();
})();