修复趋势图表加载与比例展示
This commit is contained in:
@@ -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 })
|
||||
|
||||
@@ -39,11 +39,11 @@
|
||||
/* value caption floats above the bar so it never eats into bar height */
|
||||
.trend-bar-value {
|
||||
position: absolute;
|
||||
top: -28rpx;
|
||||
top: -26rpx;
|
||||
left: 0;
|
||||
right: 0;
|
||||
text-align: center;
|
||||
font-size: 18rpx;
|
||||
font-size: 16rpx;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1;
|
||||
white-space: nowrap;
|
||||
|
||||
Reference in New Issue
Block a user