Files
data-chart-tool/style.css
T
hz4th_coder e56c6cb79f feat: 双图合并升级为多图合并 + 数据输入框加宽
- 合并模式默认2张图,新增'+添加图表'按钮可不断添加,每张图可独立删除
- 每张图卡片:标题/类型/主题/显示选项/数据,动态渲染(combineCharts 数组驱动)
- 合并逻辑支持 N 张图:横排等高依次排列、竖排等宽依次堆叠
- 后端 /api/combine 支持 charts 数组(N 张),兼容 chart1+chart2
- 修复合并图数据输入框过窄:.config-group textarea 统一 width:100%(与设置区一致)
2026-08-19 13:30:35 +08:00

778 lines
14 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 {
text-align: center;
padding: 20px 0 30px;
}
.app-header h1 {
font-size: 2rem;
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: 5px;
font-size: 0.95rem;
}
.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 - 140px);
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-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;
}