06eb3c57ab
- Chart.js - pdf, csv 파일 업로드 후 데이터 정제하여 llm으로 처리 후 결과 도출 - sqlite로 데이터 저장 - ORM - SQLAlchemy
65 lines
1.5 KiB
JavaScript
65 lines
1.5 KiB
JavaScript
|
|
const drawCategoryChart = (data) => {
|
|
new Chart(document.querySelector("#categoryChart"), {
|
|
type: 'pie',
|
|
data: {
|
|
labels : data.map((x) => x.category),
|
|
datasets:[
|
|
{
|
|
data:data.map((x)=>x.amount)
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top',
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: '카테고리별 소비내역'
|
|
}
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
const drawMonthlyChart = (data) => {
|
|
new Chart(document.querySelector("#monthlyChart"), {
|
|
type: 'line',
|
|
data: {
|
|
labels : data.map((x) => x.month),
|
|
datasets:[
|
|
{
|
|
label:"월별 소비",
|
|
data:data.map((x)=>x.amount)
|
|
}
|
|
]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
plugins: {
|
|
legend: {
|
|
position: 'top',
|
|
},
|
|
title: {
|
|
display: true,
|
|
text: '월별 소비내역'
|
|
}
|
|
}
|
|
},
|
|
})
|
|
}
|
|
|
|
async function loadDashboard() {
|
|
const response = await fetch("/api/card/dashboard");
|
|
|
|
const data = await response.json();
|
|
console.log(data);
|
|
|
|
drawCategoryChart(data.category);
|
|
drawMonthlyChart(data.monthly)
|
|
}
|
|
|
|
window.onload = loadDashboard; |