修复趋势图表加载与比例展示

This commit is contained in:
2026-07-29 14:18:45 +08:00
parent 1372ec19b8
commit 19b0c4d4c8
5 changed files with 124 additions and 45 deletions
+5 -3
View File
@@ -1,3 +1,5 @@
const { getBarPercent } = require('../../utils/util')
/**
* Trend bar chart - pure CSS (no canvas), matches the calendar-heatmap's
* rendering approach for consistency.
@@ -8,8 +10,8 @@
* - valueText: formatted string shown above the bar (e.g. "1分30秒")
* - highlight: truthy -> theme glow + bold label (today / this month)
*
* Bar height is value/max*100%, with an 8% floor for any non-zero value so
* short sessions stay visible. Zero values render a faint stub.
* Bar height is strictly proportional to value/max. Zero values render a
* faint stub so empty dates remain visible without distorting the data.
*/
Component({
properties: {
@@ -39,7 +41,7 @@ Component({
value: v,
valueText: (d && d.valueText) || '',
highlight: !!(d && d.highlight),
percent: max > 0 ? Math.max((v / max) * 100, v > 0 ? 8 : 0) : 0
percent: getBarPercent(v, max)
}
})
this.setData({ bars })