Feat/chat quality analysis (#117 @Snow-kal)

* style: 更改模板的显示

* style: 修复显示

* fix: 已按评论建议完成最小修改
This commit is contained in:
2026-03-23 00:42:18 +08:00
committed by Helian Nuits
parent 9a35ed9600
commit ca104f2503
2 changed files with 44 additions and 19 deletions
@@ -1,5 +1,12 @@
<div class="chart-section-horizontal"> <div class="chart-section-horizontal">
{% for item in chart_data %} {% for item in chart_data %}
{% set bar_percentage = item.percentage | float %}
{% if bar_percentage < 0 %}
{% set bar_percentage = 0 %}
{% elif bar_percentage > 100 %}
{% set bar_percentage = 100 %}
{% endif %}
{% set bar_bg = 'var(--color-purple)' %} {% set bar_bg = 'var(--color-purple)' %}
{% set bar_height = '4px' %} {% set bar_height = '4px' %}
{% set bar_opacity = '1' %} {% set bar_opacity = '1' %}
@@ -8,15 +15,15 @@
{% set bar_bg = 'var(--ink-secondary)' %} {% set bar_bg = 'var(--ink-secondary)' %}
{% set bar_height = '4px' %} {% set bar_height = '4px' %}
{% set bar_opacity = '0.2' %} {% set bar_opacity = '0.2' %}
{% elif item.percentage >= 70 %} {% elif bar_percentage >= 70 %}
{% set bar_bg = 'var(--accent-orange)' %} {% set bar_bg = 'var(--accent-orange)' %}
{% set bar_height = item.percentage ~ '%' %} {% set bar_height = bar_percentage ~ '%' %}
{% elif item.percentage >= 30 %} {% elif bar_percentage >= 30 %}
{% set bar_bg = 'var(--color-green)' %} {% set bar_bg = 'var(--color-green)' %}
{% set bar_height = item.percentage ~ '%' %} {% set bar_height = bar_percentage ~ '%' %}
{% else %} {% else %}
{% set bar_bg = 'var(--color-blue)' %} {% set bar_bg = 'var(--color-blue)' %}
{% set bar_height = item.percentage ~ '%' %} {% set bar_height = bar_percentage ~ '%' %}
{% endif %} {% endif %}
<div class="chart-column"> <div class="chart-column">
@@ -24,8 +31,7 @@
<div class="chart-value-top">{{ item.count }}</div> <div class="chart-value-top">{{ item.count }}</div>
{% endif %} {% endif %}
{% set style_str = 'height: ' ~ bar_height ~ '; background: ' ~ bar_bg ~ '; opacity: ' ~ bar_opacity ~ '; {% set style_str = 'height: ' ~ bar_height ~ '; background: ' ~ bar_bg ~ '; opacity: ' ~ bar_opacity ~ '; border-bottom: none;' %}
border-bottom: none;' %}
<div class="chart-bar-vertical" style="{{ style_str }}"></div> <div class="chart-bar-vertical" style="{{ style_str }}"></div>
<div class="chart-label-xaxis">{{ "%02d" | format(item.hour) }}</div> <div class="chart-label-xaxis">{{ "%02d" | format(item.hour) }}</div>
@@ -232,27 +232,37 @@
<!-- 堆叠柱状图展示各个维度评分,充分利用空间 --> <!-- 堆叠柱状图展示各个维度评分,充分利用空间 -->
<div class="dimension-bar-container"> <div class="dimension-bar-container">
<div class="dimension-bar"> <div class="dimension-bar">
{% set total = 0 %} {% set ns = namespace(total=0) %}
{% for dim in dimensions %} {% for dim in dimensions %}
{% set total = total + dim.percentage %} {% set safe_percentage = dim.percentage|float %}
{% if safe_percentage < 0 %}
{% set safe_percentage = 0 %}
{% elif safe_percentage > 100 %}
{% set safe_percentage = 100 %}
{% endif %}
{% set ns.total = ns.total + safe_percentage %}
{% endfor %} {% endfor %}
{% set scale = 1 %} {% set scale = 1 %}
{% if total > 100 %} {% if ns.total > 0 %}
{% set scale = 100 / total %} {% set scale = 100 / ns.total %}
{% elif total > 0 %}
{% set scale = 100 / total %}
{% endif %} {% endif %}
{% set colors = ['#ffb74d', '#ff8a65', '#ba68c8', '#4db6ac', '#4dd0e1', '#64b5f6', '#81c784', '#e57373'] %} {% set colors = ['#ffb74d', '#ff8a65', '#ba68c8', '#4db6ac', '#4dd0e1', '#64b5f6', '#81c784', '#e57373'] %}
{% for dim in dimensions %} {% for dim in dimensions %}
{% if dim.percentage > 0 %} {% set safe_percentage = dim.percentage|float %}
{% if safe_percentage < 0 %}
{% set safe_percentage = 0 %}
{% elif safe_percentage > 100 %}
{% set safe_percentage = 100 %}
{% endif %}
{% if safe_percentage > 0 %}
<div class="dimension-segment" <div class="dimension-segment"
style="width: {{ dim.percentage * scale }}%; background-color: {{ colors[loop.index0 % colors|length] }};" style="width: {{ safe_percentage * scale }}%; background-color: {{ colors[loop.index0 % colors|length] }};"
title="{{ dim.comment }}"> title="{{ dim.comment }}">
<span class="segment-label" <span class="segment-label"
style="display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;"> style="display: inline-block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;">
{{ dim.name }}({{ dim.percentage }}) {{ dim.name }}
</span> </span>
</div> </div>
{% endif %} {% endif %}
@@ -264,12 +274,21 @@
<div class="dimension-comments-grid"> <div class="dimension-comments-grid">
{% set colors = ['#ffb74d', '#ff8a65', '#ba68c8', '#4db6ac', '#4dd0e1', '#64b5f6', '#81c784', '#e57373'] %} {% set colors = ['#ffb74d', '#ff8a65', '#ba68c8', '#4db6ac', '#4dd0e1', '#64b5f6', '#81c784', '#e57373'] %}
{% for dim in dimensions %} {% for dim in dimensions %}
{% if dim.percentage > 0 %} {% set safe_percentage = dim.percentage|float %}
{% if safe_percentage < 0 %}
{% set safe_percentage = 0 %}
{% elif safe_percentage > 100 %}
{% set safe_percentage = 100 %}
{% endif %}
{% if safe_percentage > 0 %}
{% set rot = loop.cycle('-1deg', '1.5deg', '-0.5deg', '1deg', '-1.5deg', '0.5deg') %} {% set rot = loop.cycle('-1deg', '1.5deg', '-0.5deg', '1deg', '-1.5deg', '0.5deg') %}
{% set tape_rot = loop.cycle('2deg', '-1deg', '3deg', '-2deg', '1deg', '-3deg') %} {% set tape_rot = loop.cycle('2deg', '-1deg', '3deg', '-2deg', '1deg', '-3deg') %}
<div class="dim-sticker" style="transform: rotate({{ rot }}); border-color: {{ colors[loop.index0 % colors|length] }};"> <div class="dim-sticker" style="transform: rotate({{ rot }}); border-color: {{ colors[loop.index0 % colors|length] }};">
<div class="small-tape" style="transform: translateX(-50%) rotate({{ tape_rot }});"></div> <div class="small-tape" style="transform: translateX(-50%) rotate({{ tape_rot }});"></div>
<strong class="dim-sticker-title" style="color: {{ colors[loop.index0 % colors|length] }}; border-color: {{ colors[loop.index0 % colors|length] }};">{{ dim.name }}</strong> <div style="display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px;">
<strong class="dim-sticker-title" style="color: {{ colors[loop.index0 % colors|length] }}; border-color: {{ colors[loop.index0 % colors|length] }}; margin-bottom: 0;">{{ dim.name }}</strong>
<span style="font-size: 0.86em; font-weight: 700; color: {{ colors[loop.index0 % colors|length] }};">{{ '%.1f'|format(safe_percentage * scale) }}%</span>
</div>
<span>{{ dim.comment }}</span> <span>{{ dim.comment }}</span>
</div> </div>
{% endif %} {% endif %}