Files
data-chart-tool/style.css
T
hz4th_coder 2cc6491440 feat: 数据方向(行=系列)+每系列类型/双轴 + 多图大标题/共享图例 v1.16.0
- 图表模式新增'数据方向':列=系列(默认)/行=系列(第一行是横坐标,每行一个系列),每行可独立设柱状/折线 + 左右轴量度
- 后端 buildChartOption/GET /api/chart 支持 rowsAsSeries + seriesAxis(按系列下标指定左右轴)
- 多图合并每张小图新增:行=系列、双Y轴(左右量度不同)、每系列独立图表类型与坐标轴配置
- 多图合并新增图片大标题(bigTitle),居中显示在顶部
- 多图合并新增图例方式(legendMode):own 各自图例(默认)/shared-top 共用图例顶部/shared-bottom 共用图例底部,共用时各子图隐藏自己的图例、系列合并去重、超宽自动换行
- /api/combine 后端同步支持 bigTitle/legendMode(含深色主题文字适配)
- 收藏功能完整支持新字段(combine 大标题/图例方式/每系列配置,chart 数据方向),编辑恢复正常
- 文档/API.md/README 更新,版本 1.16.0
2026-08-22 12:03:05 +08:00

1030 lines
19 KiB
CSS

/* ===== 全局样式 ===== */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
:root {
--primary: #4f46e5;
--primary-hover: #4338ca;
--success: #10b981;
--success-hover: #059669;
--bg: #f8fafc;
--panel-bg: #ffffff;
--border: #e2e8f0;
--text: #1e293b;
--text-light: #64748b;
--shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
--shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
--radius: 12px;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
background: var(--bg);
color: var(--text);
min-height: 100vh;
}
/* ===== 布局 ===== */
.app-container {
max-width: 1600px;
margin: 0 auto;
padding: 20px;
}
.app-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
flex-wrap: wrap;
text-align: left;
padding: 6px 0 10px;
}
.header-title {
min-width: 0;
}
.app-header h1 {
font-size: 1.35rem;
margin: 0;
background: linear-gradient(135deg, var(--primary), #7c3aed);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.subtitle {
color: var(--text-light);
margin-top: 2px;
font-size: 0.8rem;
}
.main-content {
display: grid;
grid-template-columns: 420px 1fr;
gap: 20px;
align-items: start;
}
/* ===== 左侧面板 ===== */
.left-panel {
display: flex;
flex-direction: column;
gap: 16px;
max-height: calc(100vh - 100px);
overflow-y: auto;
padding-right: 8px;
}
.left-panel::-webkit-scrollbar {
width: 6px;
}
.left-panel::-webkit-scrollbar-track {
background: transparent;
}
.left-panel::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 3px;
}
.panel-section {
background: var(--panel-bg);
border-radius: var(--radius);
padding: 20px;
box-shadow: var(--shadow);
border: 1px solid var(--border);
}
.panel-section h2 {
font-size: 1.05rem;
margin-bottom: 12px;
color: var(--text);
display: flex;
align-items: center;
gap: 6px;
}
/* ===== 数据输入 ===== */
.input-format-hint {
background: #f1f5f9;
border-radius: 8px;
padding: 10px 14px;
margin-bottom: 12px;
font-size: 0.82rem;
color: var(--text-light);
}
.input-format-hint pre {
margin-top: 6px;
font-family: 'Fira Code', monospace;
font-size: 0.78rem;
color: var(--primary);
white-space: pre-wrap;
}
#dataInput {
width: 100%;
height: 180px;
border: 2px solid var(--border);
border-radius: 8px;
padding: 12px;
font-family: 'Fira Code', 'Courier New', monospace;
font-size: 0.85rem;
resize: vertical;
transition: border-color 0.2s;
line-height: 1.5;
}
#dataInput:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
/* ===== 按钮 ===== */
.btn-group {
display: flex;
gap: 8px;
margin-top: 12px;
flex-wrap: wrap;
}
.btn {
padding: 8px 16px;
border: none;
border-radius: 8px;
font-size: 0.88rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
display: inline-flex;
align-items: center;
gap: 4px;
}
.btn-primary {
background: var(--primary);
color: white;
}
.btn-primary:hover {
background: var(--primary-hover);
transform: translateY(-1px);
box-shadow: var(--shadow);
}
.btn-secondary {
background: #f1f5f9;
color: var(--text);
border: 1px solid var(--border);
}
.btn-secondary:hover {
background: #e2e8f0;
}
.btn-success {
background: var(--success);
color: white;
flex: 1;
}
.btn-success:hover {
background: var(--success-hover);
transform: translateY(-1px);
}
/* ===== 配置区 ===== */
.config-group {
margin-bottom: 12px;
}
.config-group > label {
display: block;
font-size: 0.85rem;
font-weight: 500;
color: var(--text-light);
margin-bottom: 5px;
}
.config-group select,
.config-group input[type="text"],
.config-group input[type="number"],
.config-group textarea {
width: 100%;
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: 8px;
font-size: 0.88rem;
background: white;
transition: border-color 0.2s;
}
.config-group textarea {
font-family: inherit;
resize: vertical;
min-height: 80px;
}
.config-group select:focus,
.config-group input:focus,
.config-group textarea:focus {
outline: none;
border-color: var(--primary);
box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.checkbox-group {
display: flex;
flex-wrap: wrap;
gap: 8px;
}
.checkbox-group label {
display: flex;
align-items: center;
gap: 4px;
font-size: 0.83rem;
color: var(--text);
cursor: pointer;
background: #f8fafc;
padding: 4px 10px;
border-radius: 6px;
border: 1px solid var(--border);
transition: all 0.2s;
}
.checkbox-group label:hover {
background: #f1f5f9;
border-color: var(--primary);
}
.checkbox-group input[type="checkbox"] {
accent-color: var(--primary);
}
/* ===== 系列配置 ===== */
.series-config {
display: flex;
flex-direction: column;
gap: 8px;
}
.series-item {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 12px;
background: #f8fafc;
border-radius: 8px;
border: 1px solid var(--border);
cursor: grab;
transition: all 0.2s;
}
.series-item:hover {
border-color: var(--primary);
box-shadow: var(--shadow);
}
.series-item.dragging {
opacity: 0.5;
cursor: grabbing;
}
.series-item .drag-handle {
color: #94a3b8;
cursor: grab;
font-size: 1.1rem;
}
.series-item .series-name {
flex: 1;
font-size: 0.85rem;
font-weight: 500;
}
.series-item input[type="color"] {
width: 32px;
height: 32px;
border: none;
border-radius: 6px;
cursor: pointer;
padding: 0;
}
.series-item select {
padding: 4px 8px;
border: 1px solid var(--border);
border-radius: 6px;
font-size: 0.8rem;
background: white;
}
.hint-text {
font-size: 0.83rem;
color: var(--text-light);
text-align: center;
padding: 10px;
}
/* ===== 右侧图表区 ===== */
.right-panel {
position: sticky;
top: 20px;
display: flex;
gap: 16px;
align-items: flex-start;
}
/* 右侧主区域:原图预览 + 导出预览 上下排列 */
.right-main {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
gap: 14px;
}
.chart-container {
flex: none;
min-width: 0;
background: var(--panel-bg);
border-radius: var(--radius);
padding: 20px;
box-shadow: var(--shadow-lg);
border: 1px solid var(--border);
}
.chart-area {
width: 100%;
height: 420px;
}
.placeholder {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
color: var(--text-light);
}
.placeholder p:first-child {
font-size: 4rem;
margin-bottom: 16px;
}
.placeholder p:last-child {
font-size: 1.1rem;
}
/* ===== 响应式 ===== */
@media (max-width: 1024px) {
.main-content {
grid-template-columns: 1fr;
}
.left-panel {
max-height: none;
}
.chart-area {
height: 320px;
}
/* 小屏幕下风格按钮回到图表下方 */
.right-panel {
flex-direction: column;
}
.theme-buttons-section {
width: 100%;
max-height: none;
}
.theme-buttons-grid {
grid-template-columns: repeat(4, 1fr);
}
}
/* ===== 动画 ===== */
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.panel-section {
animation: fadeIn 0.3s ease-out;
}
/* ===== 模式切换 ===== */
.mode-switch {
display: flex;
gap: 8px;
}
.mode-btn {
flex: 1;
padding: 10px 16px;
border: 2px solid var(--border);
border-radius: 8px;
background: white;
font-size: 0.9rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
color: var(--text-light);
}
.mode-btn:hover {
border-color: var(--primary);
color: var(--primary);
}
.mode-btn.active {
background: var(--primary);
border-color: var(--primary);
color: white;
}
/* ===== 双图合并 ===== */
.combine-direction {
display: flex;
gap: 16px;
flex-wrap: wrap;
}
.dir-option {
display: flex;
align-items: center;
gap: 6px;
padding: 8px 12px;
border: 1px solid var(--border);
border-radius: 8px;
background: #f8fafc;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.2s;
}
.dir-option:hover {
border-color: var(--primary);
}
.dir-option:has(input:checked) {
border-color: var(--primary);
background: #eef2ff;
color: var(--primary);
font-weight: 500;
}
.combine-chart-card {
border: 1px solid var(--border);
border-radius: 10px;
padding: 14px;
margin-bottom: 14px;
background: #f8fafc;
}
/* 多图合并 - 每系列配置(类型/坐标轴) */
.combine-series-cfg {
display: flex;
flex-direction: column;
gap: 6px;
margin-top: 4px;
}
.combine-series-row {
display: flex;
align-items: center;
gap: 6px;
background: #fff;
border: 1px solid var(--border);
border-radius: 6px;
padding: 4px 8px;
}
.combine-series-name {
flex: 1;
font-size: 0.8rem;
color: var(--text);
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.combine-series-row select {
max-width: 96px;
padding: 3px 6px;
border: 1px solid var(--border);
border-radius: 6px;
font-size: 0.78rem;
background: white;
}
.combine-chart-card h3 {
font-size: 0.95rem;
margin: 0;
color: var(--text);
}
.combine-card-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
padding-bottom: 8px;
border-bottom: 1px dashed var(--border);
}
.btn-remove {
background: #fee2e2;
color: #dc2626;
border: none;
border-radius: 6px;
width: 24px;
height: 24px;
line-height: 1;
font-size: 0.8rem;
cursor: pointer;
flex-shrink: 0;
display: inline-flex;
align-items: center;
justify-content: center;
}
.btn-remove:hover {
background: #fecaca;
}
/* ===== 表格预览 ===== */
.table-preview {
width: 100%;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
overflow: auto;
}
.table-preview img {
max-width: 100%;
max-height: 100%;
border-radius: 8px;
box-shadow: var(--shadow);
}
/* ===== 滑块样式 ===== */
input[type="range"] {
width: 100%;
height: 6px;
border-radius: 3px;
background: #e2e8f0;
outline: none;
-webkit-appearance: none;
appearance: none;
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--primary);
cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
background: var(--primary);
cursor: pointer;
border: none;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
/* ===== 风格快速切换按钮区(右侧) ===== */
.theme-buttons-section {
width: 160px;
flex-shrink: 0;
background: var(--panel-bg);
border-radius: var(--radius);
padding: 16px;
box-shadow: var(--shadow);
border: 1px solid var(--border);
max-height: calc(100vh - 140px);
overflow-y: auto;
}
.theme-buttons-section h3 {
font-size: 0.9rem;
margin-bottom: 12px;
color: var(--text);
text-align: center;
}
.theme-buttons-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 8px;
}
.theme-btn {
display: flex;
flex-direction: column;
align-items: center;
gap: 4px;
padding: 6px 4px;
border: 2px solid var(--border);
border-radius: 8px;
background: white;
cursor: pointer;
transition: all 0.2s;
}
.theme-btn:hover {
border-color: var(--primary);
transform: translateY(-1px);
box-shadow: var(--shadow);
}
.theme-btn.active {
border-color: var(--primary);
background: rgba(79, 70, 229, 0.05);
box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}
.theme-preview {
display: block;
width: 32px;
height: 20px;
border-radius: 4px;
box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}
.theme-name {
font-size: 0.7rem;
color: var(--text-light);
font-weight: 500;
}
.theme-btn.active .theme-name {
color: var(--primary);
font-weight: 600;
}
/* 滚动条样式 */
.theme-buttons-section::-webkit-scrollbar {
width: 4px;
}
.theme-buttons-section::-webkit-scrollbar-track {
background: transparent;
}
.theme-buttons-section::-webkit-scrollbar-thumb {
background: #cbd5e1;
border-radius: 2px;
}
/* ===== 导出设置 ===== */
.res-input-row {
display: flex;
align-items: center;
gap: 8px;
}
.res-input-row input[type="number"] {
flex: 1;
min-width: 0;
}
.res-times {
color: var(--text-light);
font-weight: 600;
}
/* ===== 导出预览(按分辨率居中展示保存后的图) ===== */
.export-preview-box {
margin-top: 14px;
border: 1px dashed var(--border);
border-radius: 10px;
background: #ffffff;
padding: 10px;
}
.export-preview-title {
font-size: 0.85rem;
font-weight: 600;
color: var(--text-light);
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 6px;
}
.export-preview-inner {
display: flex;
align-items: center;
justify-content: center;
min-height: 120px;
background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 0 0 / 20px 20px;
border-radius: 8px;
padding: 12px;
overflow: auto;
}
.export-preview-inner img {
max-width: 100%;
max-height: 300px;
box-shadow: 0 4px 14px rgba(0,0,0,0.12);
border-radius: 4px;
background: #fff;
}
.export-preview-size {
font-size: 0.78rem;
color: var(--primary);
background: #eef2ff;
border-radius: 4px;
padding: 1px 8px;
font-weight: 600;
}
/* ===== 导出设置折叠栏 ===== */
.export-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
}
.export-header-main {
display: flex;
align-items: center;
gap: 10px;
flex: 1;
cursor: pointer;
user-select: none;
padding: 2px 0;
}
.export-header h2 {
font-size: 1rem;
margin: 0;
color: var(--text);
}
.export-summary {
font-size: 0.75rem;
color: var(--primary);
background: #eef2ff;
padding: 2px 8px;
border-radius: 10px;
font-weight: 600;
white-space: nowrap;
}
.export-toggle {
color: var(--text-light);
font-size: 0.8rem;
transition: transform 0.2s;
}
.export-settings-body {
margin-top: 12px;
padding-top: 12px;
border-top: 1px dashed var(--border);
}
.btn-sm {
padding: 4px 10px;
font-size: 0.78rem;
}
/* 导出设置折叠栏下载按钮(更小,避免挤占) */
.export-header .btn-sm {
flex: 0 0 auto;
width: auto;
padding: 3px 8px;
font-size: 0.74rem;
white-space: nowrap;
}
/* ===== 收藏功能 ===== */
.header-actions {
margin-top: 0;
flex-shrink: 0;
}
.btn-fav-outline {
background: #fff7ed;
color: #b45309;
border: 1px solid #fcd34d;
font-size: 0.88rem;
}
.btn-fav-outline:hover {
background: #ffedd5;
border-color: #f59e0b;
}
.btn-fav {
background: #f59e0b;
color: #fff;
}
.btn-fav:hover {
background: #d97706;
}
.btn-fav:disabled {
background: #fcd34d;
cursor: wait;
transform: none;
}
/* 收藏区弹窗 */
.fav-modal {
display: none;
position: fixed;
inset: 0;
z-index: 9999;
background: rgba(15, 23, 42, 0.55);
backdrop-filter: blur(3px);
align-items: center;
justify-content: center;
padding: 24px;
}
.fav-modal-box {
width: min(1080px, 96vw);
max-height: 88vh;
background: #fff;
border-radius: 16px;
box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
display: flex;
flex-direction: column;
overflow: hidden;
}
.fav-modal-head {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 22px;
border-bottom: 1px solid var(--border);
background: #fffbeb;
}
.fav-modal-head h2 {
margin: 0;
font-size: 1.1rem;
color: #92400e;
}
.fav-modal-tip {
padding: 8px 22px;
font-size: 0.8rem;
color: var(--text-light);
background: #f8fafc;
border-bottom: 1px solid var(--border);
}
.fav-modal-tip #favCount {
font-weight: 700;
color: #b45309;
}
.fav-list {
padding: 18px 22px;
overflow-y: auto;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
gap: 16px;
align-content: start;
}
.fav-empty {
grid-column: 1 / -1;
text-align: center;
padding: 60px 20px;
color: var(--text-light);
font-size: 0.95rem;
}
.fav-card {
border: 1px solid var(--border);
border-radius: 12px;
overflow: hidden;
background: #fff;
box-shadow: var(--shadow);
transition: box-shadow 0.2s, transform 0.2s;
}
.fav-card:hover {
box-shadow: var(--shadow-lg);
transform: translateY(-2px);
}
.fav-card-img {
position: relative;
height: 200px;
background: repeating-conic-gradient(#f1f5f9 0% 25%, #ffffff 0% 50%) 0 0 / 20px 20px;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
cursor: zoom-in;
}
.fav-card-img img {
max-width: 100%;
max-height: 100%;
object-fit: contain;
}
.fav-badge {
position: absolute;
top: 8px;
left: 8px;
background: rgba(79, 70, 229, 0.9);
color: #fff;
font-size: 0.72rem;
padding: 2px 8px;
border-radius: 10px;
font-weight: 600;
}
.fav-card-body {
padding: 10px 12px 12px;
}
.fav-card-title {
font-size: 0.9rem;
font-weight: 600;
color: var(--text);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
margin-bottom: 4px;
}
.fav-card-meta {
font-size: 0.74rem;
color: var(--text-light);
margin-bottom: 8px;
}
.fav-card-actions {
display: flex;
gap: 6px;
align-items: center;
}
.fav-card-actions .btn-sm {
padding: 3px 10px;
font-size: 0.75rem;
flex: 0 0 auto;
}
.fav-card-actions .btn-remove {
margin-left: auto;
}
/* Toast 提示 */
#appToast {
position: fixed;
bottom: 28px;
left: 50%;
transform: translateX(-50%) translateY(20px);
background: rgba(17, 24, 39, 0.92);
color: #fff;
padding: 10px 20px;
border-radius: 10px;
font-size: 0.88rem;
z-index: 10000;
opacity: 0;
pointer-events: none;
transition: opacity 0.25s, transform 0.25s;
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
max-width: 80vw;
text-align: center;
}
#appToast.show {
opacity: 1;
transform: translateX(-50%) translateY(0);
}