This commit is contained in:
SeoJHeasdw 2025-06-13 14:14:30 +09:00
parent 66f5af64f4
commit 7439ce9c6c

View File

@ -174,12 +174,22 @@
</div> </div>
</div> </div>
<!-- X축 라벨 --> <!-- X축 라벨 - 데이터 포인트와 동일한 위치에 배치 -->
<div class="x-axis-labels mt-3"> <div class="x-axis-labels mt-3" style="position: relative; height: 20px;">
<div class="d-flex justify-between px-8"> <div class="x-axis-container" style="position: relative; padding-left: 60px; padding-right: 20px;">
<span v-for="item in currentChartData" :key="item.label" <span
class="x-label text-caption"> v-for="(point, index) in chartDataPoints"
{{ item.label }} :key="index"
class="x-label text-caption"
:style="{
position: 'absolute',
left: `${point.x}%`,
transform: 'translateX(-50%)',
textAlign: 'center',
whiteSpace: 'nowrap'
}"
>
{{ currentChartData[index].label }}
</span> </span>
</div> </div>
</div> </div>
@ -390,18 +400,27 @@ const aiRecommendations = ref([
// //
const currentChartData = computed(() => chartData.value[chartPeriod.value]) const currentChartData = computed(() => chartData.value[chartPeriod.value])
// chartDataPoints -
const chartDataPoints = computed(() => { const chartDataPoints = computed(() => {
const data = currentChartData.value const data = currentChartData.value
const maxSales = Math.max(...data.map(d => Math.max(d.sales, d.target))) const maxSales = Math.max(...data.map(d => Math.max(d.sales, d.target)))
return data.map((item, index) => ({ return data.map((item, index) => {
x: 10 + (index * 80 / (data.length - 1)), // 10% 90% //
y: 10 + ((item.sales / maxSales) * 80), // 10% 90% // Y (60px) (20px)
targetY: 10 + ((item.target / maxSales) * 80), const chartStartPercent = 8 // ( )
sales: item.sales, const chartEndPercent = 92 // ( )
target: item.target, const chartWidth = chartEndPercent - chartStartPercent
label: item.label
})) return {
x: chartStartPercent + (index * chartWidth / (data.length - 1)),
y: 10 + ((item.sales / maxSales) * 80), // 10% 90%
targetY: 10 + ((item.target / maxSales) * 80),
sales: item.sales,
target: item.target,
label: item.label
}
})
}) })
const avgSales = computed(() => { const avgSales = computed(() => {
@ -854,13 +873,22 @@ onBeforeUnmount(() => {
transform: scale(1.5); transform: scale(1.5);
} }
/* 수정된 X축 라벨 스타일 */
.x-axis-labels { .x-axis-labels {
padding: 0 40px; position: relative;
margin-top: 12px;
}
.x-axis-container {
position: relative;
width: 100%;
} }
.x-label { .x-label {
font-size: 0.75rem; font-size: 0.75rem;
color: #6B7280; color: #6B7280;
min-width: 40px;
display: inline-block;
} }
/* 툴팁 스타일 */ /* 툴팁 스타일 */
@ -952,6 +980,11 @@ onBeforeUnmount(() => {
.y-axis-labels { .y-axis-labels {
width: 30px; width: 30px;
} }
.x-label {
font-size: 0.65rem;
min-width: 30px;
}
} }
/* 다크 테마 지원 */ /* 다크 테마 지원 */
@ -971,4 +1004,5 @@ onBeforeUnmount(() => {
.v-theme--dark .chart-stats { .v-theme--dark .chart-stats {
background: #1E293B !important; background: #1E293B !important;
border-color: #334155; border-color: #334155;
}</style> }
</style>