fix: LineChart tooltip UTC+8 date label mismatch
LineChart 点击 tooltip 的日期格式化未传入 useUtc8 参数, 导致 UTC+8 模式下首尾数据点标签差 8 小时(日粒度差一天)。 同步补上 UsageChartScreen 中 6 处图表调用的 useUtc8 传递。
This commit is contained in:
parent
9cfb962bc8
commit
47d361b527
@ -229,7 +229,8 @@ fun UsageChartScreen(
|
|||||||
granularity = state.granularity,
|
granularity = state.granularity,
|
||||||
legendItems = models.mapIndexed { idx, m ->
|
legendItems = models.mapIndexed { idx, m ->
|
||||||
m to modelColors[idx % modelColors.size]
|
m to modelColors[idx % modelColors.size]
|
||||||
}
|
},
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -240,7 +241,8 @@ fun UsageChartScreen(
|
|||||||
valueSelector = { it.totalRequests.toFloat() },
|
valueSelector = { it.totalRequests.toFloat() },
|
||||||
lineColor = StrawberryPink,
|
lineColor = StrawberryPink,
|
||||||
formatValue = { "${it.toInt()}次" },
|
formatValue = { "${it.toInt()}次" },
|
||||||
granularity = state.granularity
|
granularity = state.granularity,
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -263,7 +265,8 @@ fun UsageChartScreen(
|
|||||||
stackLabels = { listOf("输出", "输入(未命中)", "命中缓存") },
|
stackLabels = { listOf("输出", "输入(未命中)", "命中缓存") },
|
||||||
formatValue = { formatTokenComma(it.toLong()) },
|
formatValue = { formatTokenComma(it.toLong()) },
|
||||||
granularity = state.granularity,
|
granularity = state.granularity,
|
||||||
tooltipReversed = true
|
tooltipReversed = true,
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ChartLegend(
|
ChartLegend(
|
||||||
@ -302,7 +305,8 @@ fun UsageChartScreen(
|
|||||||
granularity = state.granularity,
|
granularity = state.granularity,
|
||||||
legendItems = models.mapIndexed { idx, m ->
|
legendItems = models.mapIndexed { idx, m ->
|
||||||
m to modelColors[idx % modelColors.size]
|
m to modelColors[idx % modelColors.size]
|
||||||
}
|
},
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +323,8 @@ fun UsageChartScreen(
|
|||||||
valueSelector = { it.totalRequests.toFloat() },
|
valueSelector = { it.totalRequests.toFloat() },
|
||||||
lineColor = StrawberryPink,
|
lineColor = StrawberryPink,
|
||||||
formatValue = { "${it.toInt()}次" },
|
formatValue = { "${it.toInt()}次" },
|
||||||
granularity = state.granularity
|
granularity = state.granularity,
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -344,7 +349,8 @@ fun UsageChartScreen(
|
|||||||
stackLabels = { listOf("输出", "输入(未命中)", "命中缓存") },
|
stackLabels = { listOf("输出", "输入(未命中)", "命中缓存") },
|
||||||
formatValue = { formatTokenComma(it.toLong()) },
|
formatValue = { formatTokenComma(it.toLong()) },
|
||||||
granularity = state.granularity,
|
granularity = state.granularity,
|
||||||
tooltipReversed = true
|
tooltipReversed = true,
|
||||||
|
useUtc8 = state.useUtc8
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
ChartLegend(
|
ChartLegend(
|
||||||
@ -756,7 +762,7 @@ internal fun LineChart(
|
|||||||
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant)
|
colors = CardDefaults.cardColors(containerColor = MaterialTheme.colorScheme.surfaceVariant)
|
||||||
) {
|
) {
|
||||||
Row(Modifier.padding(8.dp), horizontalArrangement = Arrangement.SpaceBetween) {
|
Row(Modifier.padding(8.dp), horizontalArrangement = Arrangement.SpaceBetween) {
|
||||||
Text(formatChartTime(bucket.ts, granularity, 0, 1).first, style = MaterialTheme.typography.labelSmall)
|
Text(formatChartTime(bucket.ts, granularity, 0, 1, useUtc8).first, style = MaterialTheme.typography.labelSmall)
|
||||||
Text(formatValue(valueSelector(bucket)), style = MaterialTheme.typography.bodySmall, color = StrawberryPink)
|
Text(formatValue(valueSelector(bucket)), style = MaterialTheme.typography.bodySmall, color = StrawberryPink)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user