|
1 | | -<div class="card-common" style="padding: 30px 20px 15px 20px;"> |
2 | | - <div style="display: flex; align-items: flex-end; justify-content: space-between; height: 180px; gap: 4px;"> |
3 | | - {# 定义一个从 葱绿 -> 薄荷 -> 鹅黄 -> 蜜桃粉 的完美过渡色板 #} |
| 1 | +<div style="display: flex; flex-direction: column; gap: 12px; width: 100%; min-width: 600px;"> |
| 2 | + {# 柱状图主体层:确保底部对齐 #} |
| 3 | + <div style="display: flex; align-items: flex-end; justify-content: space-between; height: 160px; gap: 4px; padding-bottom: 5px; border-bottom: 2px solid rgba(57, 197, 187, 0.1);"> |
4 | 4 | {% set chart_colors = [ |
5 | 5 | '#66D1C7', '#6FD3C6', '#79D5C4', '#85D8C3', '#93DAC1', '#A3DDBF', |
6 | 6 | '#B4E0BD', '#C7E2BA', '#DBE5B8', '#EFE8B5', '#FFEAB3', '#FFDF9E', |
|
10 | 10 |
|
11 | 11 | {% for item in chart_data %} |
12 | 12 | {% set h = item.percentage | float %} |
13 | | - |
14 | | - {# 使用 loop.index0 从色板中依次取色,形成从左到右的全局渐变 #} |
15 | 13 | {% set bar_color = chart_colors[loop.index0 % 24] %} |
16 | | - |
17 | 14 | {% set bar_opacity = '1' %} |
18 | 15 | {% if item.count == 0 %} |
19 | 16 | {% set h = '4' %} |
20 | 17 | {% set bar_opacity = '0.3' %} |
21 | 18 | {% set bar_color = 'var(--miku-blue)' %} |
22 | 19 | {% endif %} |
23 | 20 |
|
24 | | - <div style="flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; position: relative;"> |
| 21 | + <div style="flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%;"> |
25 | 22 | {% if item.count > 0 %} |
26 | | - {# 数字去掉背景框,颜色与柱子保持一致,视觉更通透 #} |
27 | | - <span style="font-family: var(--font-num); font-size: 0.8rem; color: {{ bar_color }}; margin-bottom: 6px; font-weight: bold; text-shadow: 0 1px 2px rgba(0,0,0,0.02);">{{ item.count }}</span> |
| 23 | + <span style="font-family: var(--font-num); font-size: 0.75rem; color: {{ bar_color }}; margin-bottom: 4px; font-weight: 800;">{{ item.count }}</span> |
28 | 24 | {% endif %} |
29 | 25 |
|
30 | | - {# 柱状体 #} |
31 | 26 | <div style="width: 100%; height: {{ h }}%; |
32 | 27 | background: {{ bar_color }}; |
33 | 28 | border-radius: 4px 4px 1px 1px; |
34 | | - box-shadow: 0 2px 8px rgba(0,0,0,0.05); |
35 | | - transition: height 0.3s ease; |
36 | | - opacity: {{ bar_opacity }};"></div> |
37 | | - |
38 | | - {# X轴标签 #} |
39 | | - <span style="margin-top: 10px; font-family: var(--font-num); font-size: 0.75rem; color: var(--text-sub); font-weight: bold;">{{ "%02d"|format(item.hour) }}时</span> |
| 29 | + opacity: {{ bar_opacity }}; |
| 30 | + transition: height 0.3s ease;"></div> |
| 31 | + </div> |
| 32 | + {% endfor %} |
| 33 | + </div> |
| 34 | + |
| 35 | + {# X轴标签层:独立容器确保水平对齐且不换行 #} |
| 36 | + <div style="display: flex; justify-content: space-between; gap: 4px;"> |
| 37 | + {% for item in chart_data %} |
| 38 | + <div style="flex: 1; text-align: center;"> |
| 39 | + <span style="font-family: var(--font-num); font-size: 0.7rem; color: var(--text-sub); font-weight: bold; white-space: nowrap; display: inline-block;"> |
| 40 | + {{ "%02d"|format(item.hour) }}{% if loop.index0 % 4 == 0 or loop.last %}时{% endif %} |
| 41 | + </span> |
40 | 42 | </div> |
41 | 43 | {% endfor %} |
42 | 44 | </div> |
|
0 commit comments