remove
This commit is contained in:
parent
16deaf1890
commit
fe4176621c
@ -210,148 +210,148 @@ const DailyPOSReport = () => {
|
||||
currentY = 20
|
||||
|
||||
// === TREN PENJUALAN (berdasarkan data sales analytics) ===
|
||||
if (profitLoss7Days?.data && profitLoss7Days.data.length > 0) {
|
||||
pdf.setFontSize(PDF_FONT_SIZES.heading)
|
||||
pdf.text('Tren Penjualan 7 Hari Terakhir', 14, currentY)
|
||||
currentY += 10
|
||||
// if (profitLoss7Days?.data && profitLoss7Days.data.length > 0) {
|
||||
// pdf.setFontSize(PDF_FONT_SIZES.heading)
|
||||
// pdf.text('Tren Penjualan 7 Hari Terakhir', 14, currentY)
|
||||
// currentY += 10
|
||||
|
||||
// Create canvas for chart
|
||||
const canvas = document.createElement('canvas')
|
||||
canvas.width = 800
|
||||
canvas.height = 400
|
||||
const ctx = canvas.getContext('2d')
|
||||
// // Create canvas for chart
|
||||
// const canvas = document.createElement('canvas')
|
||||
// canvas.width = 800
|
||||
// canvas.height = 400
|
||||
// const ctx = canvas.getContext('2d')
|
||||
|
||||
if (ctx) {
|
||||
const { Chart, registerables } = await import('chart.js')
|
||||
Chart.register(...registerables)
|
||||
// if (ctx) {
|
||||
// const { Chart, registerables } = await import('chart.js')
|
||||
// Chart.register(...registerables)
|
||||
|
||||
// Prepare chart data
|
||||
const chartLabels = profitLoss7Days.data.map(day =>
|
||||
new Date(day.date).toLocaleDateString('id-ID', { day: '2-digit', month: 'short' })
|
||||
)
|
||||
const revenueData = profitLoss7Days.data.map(day => day.revenue)
|
||||
const ordersData = profitLoss7Days.data.map(day => day.orders)
|
||||
// // Prepare chart data
|
||||
// const chartLabels = profitLoss7Days.data.map(day =>
|
||||
// new Date(day.date).toLocaleDateString('id-ID', { day: '2-digit', month: 'short' })
|
||||
// )
|
||||
// const revenueData = profitLoss7Days.data.map(day => day.revenue)
|
||||
// const ordersData = profitLoss7Days.data.map(day => day.orders)
|
||||
|
||||
// Create chart
|
||||
new Chart(ctx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: chartLabels,
|
||||
datasets: [
|
||||
{
|
||||
label: 'Total Penjualan (Rp)',
|
||||
data: revenueData,
|
||||
backgroundColor: 'rgba(54, 23, 94, 0.8)',
|
||||
borderColor: 'rgba(54, 23, 94, 1)',
|
||||
borderWidth: 1,
|
||||
yAxisID: 'y'
|
||||
},
|
||||
{
|
||||
label: 'Jumlah Invoice',
|
||||
data: ordersData,
|
||||
type: 'line',
|
||||
borderColor: 'rgba(59, 130, 246, 1)',
|
||||
backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
||||
borderWidth: 2,
|
||||
tension: 0.4,
|
||||
yAxisID: 'y1',
|
||||
pointRadius: 4,
|
||||
pointBackgroundColor: 'rgba(59, 130, 246, 1)'
|
||||
}
|
||||
]
|
||||
},
|
||||
options: {
|
||||
responsive: false,
|
||||
animation: false,
|
||||
plugins: {
|
||||
legend: {
|
||||
display: true,
|
||||
position: 'top',
|
||||
labels: {
|
||||
font: { size: 12 },
|
||||
padding: 15
|
||||
}
|
||||
},
|
||||
title: {
|
||||
display: false
|
||||
}
|
||||
},
|
||||
scales: {
|
||||
y: {
|
||||
type: 'linear',
|
||||
position: 'left',
|
||||
beginAtZero: true,
|
||||
ticks: {
|
||||
callback: function (value) {
|
||||
if (typeof value !== 'number') return ''
|
||||
return 'Rp ' + (value / 1000).toFixed(0) + 'k'
|
||||
}
|
||||
},
|
||||
// // Create chart
|
||||
// new Chart(ctx, {
|
||||
// type: 'bar',
|
||||
// data: {
|
||||
// labels: chartLabels,
|
||||
// datasets: [
|
||||
// {
|
||||
// label: 'Total Penjualan (Rp)',
|
||||
// data: revenueData,
|
||||
// backgroundColor: 'rgba(54, 23, 94, 0.8)',
|
||||
// borderColor: 'rgba(54, 23, 94, 1)',
|
||||
// borderWidth: 1,
|
||||
// yAxisID: 'y'
|
||||
// },
|
||||
// {
|
||||
// label: 'Jumlah Invoice',
|
||||
// data: ordersData,
|
||||
// type: 'line',
|
||||
// borderColor: 'rgba(59, 130, 246, 1)',
|
||||
// backgroundColor: 'rgba(59, 130, 246, 0.1)',
|
||||
// borderWidth: 2,
|
||||
// tension: 0.4,
|
||||
// yAxisID: 'y1',
|
||||
// pointRadius: 4,
|
||||
// pointBackgroundColor: 'rgba(59, 130, 246, 1)'
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
// options: {
|
||||
// responsive: false,
|
||||
// animation: false,
|
||||
// plugins: {
|
||||
// legend: {
|
||||
// display: true,
|
||||
// position: 'top',
|
||||
// labels: {
|
||||
// font: { size: 12 },
|
||||
// padding: 15
|
||||
// }
|
||||
// },
|
||||
// title: {
|
||||
// display: false
|
||||
// }
|
||||
// },
|
||||
// scales: {
|
||||
// y: {
|
||||
// type: 'linear',
|
||||
// position: 'left',
|
||||
// beginAtZero: true,
|
||||
// ticks: {
|
||||
// callback: function (value) {
|
||||
// if (typeof value !== 'number') return ''
|
||||
// return 'Rp ' + (value / 1000).toFixed(0) + 'k'
|
||||
// }
|
||||
// },
|
||||
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Total Penjualan'
|
||||
}
|
||||
},
|
||||
y1: {
|
||||
type: 'linear',
|
||||
position: 'right',
|
||||
beginAtZero: true,
|
||||
grid: {
|
||||
drawOnChartArea: false
|
||||
},
|
||||
title: {
|
||||
display: true,
|
||||
text: 'Jumlah Invoice'
|
||||
}
|
||||
},
|
||||
x: {
|
||||
grid: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
// title: {
|
||||
// display: true,
|
||||
// text: 'Total Penjualan'
|
||||
// }
|
||||
// },
|
||||
// y1: {
|
||||
// type: 'linear',
|
||||
// position: 'right',
|
||||
// beginAtZero: true,
|
||||
// grid: {
|
||||
// drawOnChartArea: false
|
||||
// },
|
||||
// title: {
|
||||
// display: true,
|
||||
// text: 'Jumlah Invoice'
|
||||
// }
|
||||
// },
|
||||
// x: {
|
||||
// grid: {
|
||||
// display: false
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
|
||||
// Wait for chart to render
|
||||
await new Promise(resolve => setTimeout(resolve, 500))
|
||||
// // Wait for chart to render
|
||||
// await new Promise(resolve => setTimeout(resolve, 500))
|
||||
|
||||
// Convert chart to image
|
||||
const chartImage = canvas.toDataURL('image/png', 1.0)
|
||||
const chartWidth = 180
|
||||
const chartHeight = 90
|
||||
// // Convert chart to image
|
||||
// const chartImage = canvas.toDataURL('image/png', 1.0)
|
||||
// const chartWidth = 180
|
||||
// const chartHeight = 90
|
||||
|
||||
pdf.addImage(chartImage, 'PNG', 15, currentY, chartWidth, chartHeight)
|
||||
currentY += chartHeight + 10
|
||||
// pdf.addImage(chartImage, 'PNG', 15, currentY, chartWidth, chartHeight)
|
||||
// currentY += chartHeight + 10
|
||||
|
||||
// Add summary table below chart
|
||||
autoTable(pdf, {
|
||||
startY: currentY,
|
||||
head: [['Total Invoice', 'Total Penjualan']],
|
||||
body: [
|
||||
[String(profitLoss7Days.summary.total_orders), formatCurrency(profitLoss7Days.summary.total_revenue)]
|
||||
],
|
||||
theme: 'grid',
|
||||
styles: {
|
||||
fontSize: PDF_FONT_SIZES.tableContent,
|
||||
cellPadding: PDF_SPACING.cellPadding,
|
||||
lineColor: [0, 0, 0],
|
||||
lineWidth: 0.1,
|
||||
halign: 'center'
|
||||
},
|
||||
headStyles: {
|
||||
fillColor: [54, 23, 94],
|
||||
textColor: 255,
|
||||
fontStyle: 'bold',
|
||||
fontSize: PDF_FONT_SIZES.tableHeader
|
||||
},
|
||||
margin: { left: 14, right: 14 }
|
||||
})
|
||||
// // Add summary table below chart
|
||||
// autoTable(pdf, {
|
||||
// startY: currentY,
|
||||
// head: [['Total Invoice', 'Total Penjualan']],
|
||||
// body: [
|
||||
// [String(profitLoss7Days.summary.total_orders), formatCurrency(profitLoss7Days.summary.total_revenue)]
|
||||
// ],
|
||||
// theme: 'grid',
|
||||
// styles: {
|
||||
// fontSize: PDF_FONT_SIZES.tableContent,
|
||||
// cellPadding: PDF_SPACING.cellPadding,
|
||||
// lineColor: [0, 0, 0],
|
||||
// lineWidth: 0.1,
|
||||
// halign: 'center'
|
||||
// },
|
||||
// headStyles: {
|
||||
// fillColor: [54, 23, 94],
|
||||
// textColor: 255,
|
||||
// fontStyle: 'bold',
|
||||
// fontSize: PDF_FONT_SIZES.tableHeader
|
||||
// },
|
||||
// margin: { left: 14, right: 14 }
|
||||
// })
|
||||
|
||||
currentY = (pdf as any).lastAutoTable.finalY + 20
|
||||
}
|
||||
}
|
||||
// currentY = (pdf as any).lastAutoTable.finalY + 20
|
||||
// }
|
||||
// }
|
||||
|
||||
// Payment Method Summary - DENGAN BORDER HITAM
|
||||
pdf.setFontSize(PDF_FONT_SIZES.heading)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user