1503 lines
52 KiB
HTML
1503 lines
52 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<script src="cls-1.5.js" type="module"></script>
|
|
<title>智能视频分析系统</title>
|
|
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
|
<style>
|
|
:root {
|
|
--primary-color: #2962ff;
|
|
--secondary-color: #82b1ff;
|
|
--background-color: #f8f9fa;
|
|
--sidebar-color: #ffffff;
|
|
--text-primary: #2c3e50;
|
|
--text-secondary: #7f8c8d;
|
|
--success-color: #4caf50;
|
|
--warning-color: #ff9800;
|
|
--danger-color: #f44336;
|
|
--border-radius: 12px;
|
|
--card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
--transition: all 0.3s ease;
|
|
--border-color: #e0e0e0;
|
|
}
|
|
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
|
|
}
|
|
|
|
body {
|
|
background-color: var(--background-color);
|
|
color: var(--text-primary);
|
|
}
|
|
|
|
.container {
|
|
display: flex;
|
|
min-height: 100vh;
|
|
}
|
|
|
|
/* 侧边栏样式 */
|
|
.sidebar {
|
|
background-color: var(--sidebar-color);
|
|
padding: 24px;
|
|
box-shadow: var(--card-shadow);
|
|
position: fixed;
|
|
width: 280px;
|
|
height: 100vh;
|
|
overflow-y: auto;
|
|
top: 0;
|
|
left: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.logo {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding-bottom: 24px;
|
|
border-bottom: 1px solid #eee;
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.logo img {
|
|
width: 40px;
|
|
height: 40px;
|
|
}
|
|
|
|
.logo h1 {
|
|
font-size: 20px;
|
|
font-weight: 600;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.camera-list {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 12px;
|
|
}
|
|
|
|
.camera-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px;
|
|
background-color: #fff;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
border: 1px solid #eee;
|
|
}
|
|
|
|
.camera-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.camera-item.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.camera-status {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background-color: var(--success-color);
|
|
}
|
|
|
|
/* 主内容区样式 */
|
|
.main-content {
|
|
flex: 1;
|
|
padding: 24px;
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 24px;
|
|
margin-left: 280px;
|
|
min-height: 100vh;
|
|
width: calc(100% - 280px);
|
|
}
|
|
|
|
/* 顶部工具栏 */
|
|
.toolbar {
|
|
display: flex;
|
|
gap: 16px;
|
|
background-color: white;
|
|
padding: 16px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.search-box {
|
|
flex: 1;
|
|
position: relative;
|
|
}
|
|
|
|
.search-box i {
|
|
position: absolute;
|
|
left: 12px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.search-box input {
|
|
width: 100%;
|
|
padding: 12px 12px 12px 40px;
|
|
border: 1px solid #eee;
|
|
border-radius: var(--border-radius);
|
|
font-size: 14px;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.search-box input:focus {
|
|
outline: none;
|
|
border-color: var(--primary-color);
|
|
box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.1);
|
|
}
|
|
|
|
.date-picker input {
|
|
padding: 12px;
|
|
border: 1px solid #eee;
|
|
border-radius: var(--border-radius);
|
|
font-size: 14px;
|
|
}
|
|
|
|
.button {
|
|
padding: 12px 24px;
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
border: none;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
font-weight: 500;
|
|
}
|
|
|
|
.button:hover {
|
|
background-color: var(--secondary-color);
|
|
}
|
|
|
|
/* 时间轴样式 */
|
|
.timeline-card {
|
|
background-color: white;
|
|
border-radius: 12px;
|
|
padding: 24px;
|
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
}
|
|
|
|
.timeline-content {
|
|
position: relative;
|
|
overflow-x: hidden;
|
|
background: white;
|
|
border-radius: var(--border-radius);
|
|
padding: 20px;
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
|
|
.timeline {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100px;
|
|
background: var(--background-color);
|
|
border: 1px solid var(--border-color);
|
|
border-radius: 4px;
|
|
margin-top: 30px;
|
|
overflow: visible;
|
|
}
|
|
|
|
.hour-marker {
|
|
position: absolute;
|
|
width: 1px;
|
|
height: 100%;
|
|
background: rgba(0, 0, 0, 0.1);
|
|
top: 0;
|
|
}
|
|
|
|
.hour-label {
|
|
position: absolute;
|
|
top: -25px;
|
|
transform: translateX(-50%);
|
|
font-size: 12px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.event {
|
|
position: absolute;
|
|
height: 8px;
|
|
transform: translateX(-50%);
|
|
border-radius: 3px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
opacity: 0.85;
|
|
z-index: 1;
|
|
}
|
|
|
|
.event:hover {
|
|
opacity: 1;
|
|
transform: translateX(-50%) scaleY(1.5);
|
|
z-index: 2;
|
|
}
|
|
|
|
.timeline-controls {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.zoom-controls button {
|
|
background: white;
|
|
border: 1px solid var(--border-color);
|
|
color: var(--text-color);
|
|
padding: 8px 15px;
|
|
border-radius: 6px;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
margin-right: 10px;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.zoom-controls button:hover {
|
|
background: var(--primary-color);
|
|
border-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
/* 滚动条样式 */
|
|
.timeline-content::-webkit-scrollbar {
|
|
height: 8px;
|
|
}
|
|
|
|
.timeline-content::-webkit-scrollbar-track {
|
|
background: var(--secondary-bg);
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.timeline-content::-webkit-scrollbar-thumb {
|
|
background: #ccc;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.timeline-content::-webkit-scrollbar-thumb:hover {
|
|
background: #bbb;
|
|
}
|
|
|
|
/* 数据卡片网格 */
|
|
.dashboard-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 24px;
|
|
}
|
|
|
|
.stat-card {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.stat-card h3 {
|
|
color: var(--text-secondary);
|
|
font-size: 14px;
|
|
margin-bottom: 8px;
|
|
}
|
|
|
|
.stat-value {
|
|
font-size: 32px;
|
|
font-weight: 600;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
/* 图表容器 */
|
|
.chart-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(2, 1fr);
|
|
gap: 24px;
|
|
}
|
|
|
|
.chart-card {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.chart-container {
|
|
height: 300px;
|
|
margin-top: 20px;
|
|
}
|
|
|
|
/* 事件列表 */
|
|
.event-list {
|
|
background-color: white;
|
|
padding: 24px;
|
|
border-radius: var(--border-radius);
|
|
box-shadow: var(--card-shadow);
|
|
}
|
|
|
|
.event-list-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.event-list-item {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
padding: 16px;
|
|
border-bottom: 1px solid #eee;
|
|
transition: var(--transition);
|
|
}
|
|
|
|
.event-list-item:hover {
|
|
background-color: #f8f9fa;
|
|
}
|
|
|
|
.event-info {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
}
|
|
|
|
.event-icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
border-radius: 50%;
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.event-details {
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
|
|
.event-time {
|
|
font-size: 14px;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.confidence-badge {
|
|
padding: 6px 12px;
|
|
border-radius: 20px;
|
|
font-size: 14px;
|
|
background-color: #e3f2fd;
|
|
color: var(--primary-color);
|
|
}
|
|
|
|
.highlight {
|
|
background-color: rgba(41, 98, 255, 0.1);
|
|
border-radius: 4px;
|
|
padding: 2px 4px;
|
|
}
|
|
|
|
/* 新增样式 */
|
|
.sidebar-divider {
|
|
height: 1px;
|
|
background-color: #eee;
|
|
margin: 24px 0;
|
|
}
|
|
|
|
.nav-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 12px;
|
|
padding: 16px;
|
|
border-radius: var(--border-radius);
|
|
cursor: pointer;
|
|
transition: var(--transition);
|
|
border: 1px solid #eee;
|
|
}
|
|
|
|
.nav-item:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: var(--card-shadow);
|
|
background-color: rgba(41, 98, 255, 0.1);
|
|
}
|
|
|
|
.nav-item.active {
|
|
background-color: var(--primary-color);
|
|
color: white;
|
|
}
|
|
|
|
.summary-section {
|
|
background-color: white;
|
|
border-radius: var(--border-radius);
|
|
padding: 24px;
|
|
box-shadow: var(--card-shadow);
|
|
margin-bottom: 24px;
|
|
}
|
|
|
|
.summary-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
margin-bottom: 20px;
|
|
}
|
|
|
|
.insight-card {
|
|
background-color: #f8f9fa;
|
|
border-radius: var(--border-radius);
|
|
padding: 20px;
|
|
margin-bottom: 16px;
|
|
}
|
|
|
|
.insight-title {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
color: var(--primary-color);
|
|
margin-bottom: 12px;
|
|
}
|
|
|
|
.recommendation {
|
|
background-color: #e3f2fd;
|
|
border-left: 4px solid var(--primary-color);
|
|
padding: 16px;
|
|
margin-top: 16px;
|
|
border-radius: 0 var(--border-radius) var(--border-radius) 0;
|
|
}
|
|
|
|
.trend-indicator {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 4px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.trend-up {
|
|
color: var(--success-color);
|
|
}
|
|
|
|
.trend-down {
|
|
color: var(--danger-color);
|
|
}
|
|
|
|
/* 添加图例样式 */
|
|
.legend {
|
|
display: flex;
|
|
gap: 15px;
|
|
padding: 15px;
|
|
justify-content: center;
|
|
flex-wrap: wrap;
|
|
background: var(--secondary-bg);
|
|
border-radius: 8px;
|
|
margin-top: 15px;
|
|
}
|
|
|
|
.legend-item {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 13px;
|
|
gap: 5px;
|
|
padding: 4px 6px;
|
|
background: white;
|
|
border-radius: 4px;
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
|
|
.legend-color {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.legend-container {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
justify-content: center;
|
|
padding: 12px;
|
|
}
|
|
|
|
.legend-item {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
padding: 6px 12px;
|
|
background: white;
|
|
border-radius: 20px;
|
|
border: 1px solid var(--border-color);
|
|
font-size: 13px;
|
|
}
|
|
|
|
.legend-color {
|
|
width: 12px;
|
|
height: 12px;
|
|
border-radius: 3px;
|
|
}
|
|
|
|
.legend-item {
|
|
cursor: pointer;
|
|
opacity: 0.7;
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.legend-item.active {
|
|
opacity: 1;
|
|
}
|
|
|
|
.legend-item:not(.active) {
|
|
opacity: 0.4;
|
|
}
|
|
|
|
.legend-item:not(.active) .legend-color {
|
|
background-color: #ccc !important;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<!-- 侧边栏 -->
|
|
<div class="sidebar">
|
|
<div class="logo">
|
|
<img src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%232962ff'%3E%3Cpath d='M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z'/%3E%3C/svg%3E" alt="Logo">
|
|
<h1>智能视频分析</h1>
|
|
</div>
|
|
<div class="camera-list">
|
|
<div class="camera-item active">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 01</span>
|
|
</div>
|
|
<div class="camera-item">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 02</span>
|
|
</div>
|
|
<div class="camera-item">
|
|
<span class="camera-status"></span>
|
|
<span>摄像头 03</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="sidebar-divider"></div>
|
|
<div class="nav-item daily-summary">
|
|
<i class="material-icons">analytics</i>
|
|
<span>每日行为分析</span>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 主内容区 -->
|
|
<div class="main-content">
|
|
<!-- 工具栏 -->
|
|
<div class="toolbar">
|
|
<div class="search-box">
|
|
<i class="material-icons">search</i>
|
|
<input type="text" placeholder="搜索行为或事件...">
|
|
</div>
|
|
<div class="date-picker">
|
|
<input type="date">
|
|
</div>
|
|
<button class="button">
|
|
<i class="material-icons">filter_list</i>
|
|
筛选
|
|
</button>
|
|
</div>
|
|
|
|
<!-- 数据卡片 -->
|
|
<div class="dashboard-grid">
|
|
<div class="stat-card">
|
|
<h3>今日识别行为</h3>
|
|
<div class="stat-value">--</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>平均置信度</h3>
|
|
<div class="stat-value">--%</div>
|
|
</div>
|
|
<div class="stat-card">
|
|
<h3>异常行为</h3>
|
|
<div class="stat-value">--</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 时间轴 -->
|
|
<div class="timeline-card">
|
|
<div class="timeline-controls">
|
|
<div class="zoom-controls">
|
|
<button onclick="adjustZoom(1)">放大</button>
|
|
<button onclick="adjustZoom(-1)">缩小</button>
|
|
<button onclick="adjustZoom('reset')">还原</button>
|
|
</div>
|
|
<button class="button">导出数据</button>
|
|
</div>
|
|
<div class="timeline-content">
|
|
<div class="timeline" id="timeline">
|
|
<!-- 时间标记和事件将通过 JavaScript 动态添加 -->
|
|
</div>
|
|
</div>
|
|
<!-- 添加图例容器 -->
|
|
<div class="legend" id="legend"></div>
|
|
</div>
|
|
|
|
<!-- 图表区域 -->
|
|
<div class="chart-grid">
|
|
<div class="chart-card">
|
|
<div class="card-header">
|
|
<h2>行为分布</h2>
|
|
</div>
|
|
<div class="chart-container" id="behaviorChart"></div>
|
|
</div>
|
|
<div class="chart-card">
|
|
<div class="card-header">
|
|
<h2>时段分析</h2>
|
|
</div>
|
|
<div class="chart-container" id="timeChart"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- 事件列表 -->
|
|
<div class="event-list">
|
|
<div class="event-list-header">
|
|
<h2>最新事件</h2>
|
|
<button class="button">查看全部</button>
|
|
</div>
|
|
<!-- 事件将通过 JavaScript 动态添加 -->
|
|
</div>
|
|
|
|
<!-- 每日总结分析 -->
|
|
<div class="summary-section">
|
|
<div class="summary-header">
|
|
<h2>每日行为分析</h2>
|
|
<div class="date-picker">
|
|
<input type="date">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">trending_up</i>
|
|
<h3>整体活动趋势</h3>
|
|
</div>
|
|
<p>今日共记录 2,547 个行为事件,较昨日增长 15%</p>
|
|
<div class="trend-indicator trend-up">
|
|
<i class="material-icons">arrow_upward</i>
|
|
<span>活跃度上升</span>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">access_time</i>
|
|
<h3>高峰时段分析</h3>
|
|
</div>
|
|
<p>活动高峰出现在 9:00-11:00 和 14:00-16:00</p>
|
|
<div class="chart-container" id="peakTimeChart" style="height: 200px;"></div>
|
|
</div>
|
|
|
|
<div class="insight-card">
|
|
<div class="insight-title">
|
|
<i class="material-icons">warning</i>
|
|
<h3>异常行为分析</h3>
|
|
</div>
|
|
<p>检测到 23 起异常行为,主要集中在午夜时段</p>
|
|
<div class="recommendation">
|
|
<strong>建议:</strong>
|
|
<p>建议加强夜间监控,特别是在 23:00-凌晨 2:00 时段</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
|
|
<script>
|
|
|
|
const API_BASE_URL = 'https://dev.obscura.work/web';
|
|
|
|
// 获取摄像头数据
|
|
async function fetchCameraData(cameraId, date) {
|
|
try {
|
|
// 如果没有传入日期,使用当前日期
|
|
const currentDate = date || new Date().toISOString().split('T')[0].replace(/-/g, '');
|
|
const response = await fetch(`${API_BASE_URL}/${cameraId}/data?date=${currentDate}`);
|
|
if (!response.ok) {
|
|
throw new Error('Network response was not ok');
|
|
}
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error('Error fetching camera data:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
// 解析视频分析数据
|
|
function parseVideoAnalysis(data) {
|
|
const behaviors = new Map();
|
|
const timeDistribution = new Map();
|
|
let totalEvents = 0;
|
|
let totalConfidence = 0;
|
|
let abnormalCount = 0;
|
|
|
|
// 初始化24小时时间分布
|
|
for (let i = 0; i < 24; i++) {
|
|
timeDistribution.set(i, 0);
|
|
}
|
|
|
|
// 遍历所有摄像头数据
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.values(cameraData).forEach(record => {
|
|
if (record.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
const info = record.video_analysis['qwen-7B'].extracted_info;
|
|
const timestamp = new Date(record.timestamp);
|
|
|
|
// 统计行为
|
|
info.actions.forEach(action => {
|
|
behaviors.set(action, (behaviors.get(action) || 0) + 1);
|
|
totalEvents++;
|
|
});
|
|
|
|
// 记录时间分布
|
|
const hour = timestamp.getHours();
|
|
timeDistribution.set(hour, (timeDistribution.get(hour) || 0) + 1);
|
|
|
|
// 统计异常行为(可以根据实际需求调整判断标准)
|
|
if (info.actions.some(action =>
|
|
action.includes('异常') ||
|
|
action.includes('可疑'))) {
|
|
abnormalCount++;
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
return {
|
|
behaviors: Object.fromEntries(behaviors),
|
|
timeDistribution: Object.fromEntries(timeDistribution),
|
|
totalEvents,
|
|
abnormalCount
|
|
};
|
|
}
|
|
|
|
// 更新统计卡片
|
|
function updateStatCards(stats) {
|
|
document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = stats.totalEvents;
|
|
document.querySelector('.stat-card:nth-child(2) .stat-value').textContent =
|
|
`${stats.totalEvents ? Math.round((stats.totalEvents - stats.abnormalCount) / stats.totalEvents * 100) : 0}%`;
|
|
document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = stats.abnormalCount;
|
|
}
|
|
|
|
// 添加全局变量
|
|
let currentZoom = 1;
|
|
let lastFetchedData = null;
|
|
let defaultTimelineWidth = 0;
|
|
let behaviorColors = new Map(); // 将 behaviorColors 提升为全局变量
|
|
|
|
function adjustZoom(delta) {
|
|
const timeline = document.getElementById('timeline');
|
|
const timelineContent = document.querySelector('.timeline-content');
|
|
|
|
if (delta === 'reset') {
|
|
// 重置缩放
|
|
currentZoom = 1;
|
|
timeline.style.width = '100%';
|
|
timelineContent.style.overflowX = 'hidden';
|
|
} else {
|
|
const newZoom = currentZoom + delta * 0.2;
|
|
if (newZoom >= 1 && newZoom <= 3) { // 限制最小缩放为1(不允许缩小)
|
|
currentZoom = newZoom;
|
|
|
|
// 计算新的时间轴宽度
|
|
const baseWidth = defaultTimelineWidth || timeline.parentElement.offsetWidth;
|
|
const newWidth = baseWidth * currentZoom;
|
|
|
|
timeline.style.width = `${newWidth}px`;
|
|
timelineContent.style.overflowX = currentZoom > 1 ? 'auto' : 'hidden';
|
|
}
|
|
}
|
|
|
|
if (lastFetchedData) {
|
|
updateTimeline(lastFetchedData);
|
|
}
|
|
}
|
|
|
|
// 修改 updateTimeline 函数
|
|
function updateTimeline(data) {
|
|
const timeline = document.getElementById('timeline');
|
|
timeline.innerHTML = '';
|
|
|
|
// 存储默认宽度
|
|
if (!defaultTimelineWidth) {
|
|
defaultTimelineWidth = timeline.parentElement.offsetWidth;
|
|
}
|
|
|
|
// 计算时间轴的总宽度(像素)
|
|
const timelineWidth = timeline.offsetWidth;
|
|
|
|
// 定义行为类别的垂直位置(从上到下)
|
|
const categoryRows = {
|
|
'基础动作': 0, // 第一行
|
|
'日常生活': 1, // 第二行
|
|
'工作学习': 2, // 第三行
|
|
'社交活动': 3, // 第四行
|
|
'其他': 4, // 第五行
|
|
'异常行为': 5 // 第六行
|
|
};
|
|
|
|
// 修改行为分类的判断逻辑
|
|
function getBehaviorCategory(behavior) {
|
|
// 遍历 window.actions 中的所有类别
|
|
for (const [mainCategory, subCategories] of Object.entries(window.actions)) {
|
|
// 遍历每个主类别下的子类别
|
|
for (const [subCategory, behaviors] of Object.entries(subCategories)) {
|
|
// 使用完全匹配来检查行为
|
|
if (behaviors.includes(behavior)) {
|
|
return mainCategory;
|
|
}
|
|
}
|
|
}
|
|
return '其他';
|
|
}
|
|
|
|
// 添加小时刻度
|
|
for (let i = 0; i <= 24; i++) {
|
|
const marker = document.createElement('div');
|
|
marker.className = 'hour-marker';
|
|
marker.style.left = `${(i / 24) * 100}%`;
|
|
|
|
const label = document.createElement('div');
|
|
label.className = 'hour-label';
|
|
label.textContent = i.toString().padStart(2, '0') + ':00';
|
|
label.style.left = `${(i / 24) * 100}%`;
|
|
|
|
timeline.appendChild(marker);
|
|
timeline.appendChild(label);
|
|
}
|
|
|
|
// 处理事件数据
|
|
if (data) {
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.entries(cameraData).forEach(([key, value]) => {
|
|
if (value.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
const timestamp = new Date(value.timestamp);
|
|
const hour = timestamp.getHours();
|
|
const minute = timestamp.getMinutes();
|
|
const actions = value.video_analysis['qwen-7B'].extracted_info.actions;
|
|
|
|
if (Array.isArray(actions) && actions.length > 0) {
|
|
actions.forEach(behavior => {
|
|
const category = getBehaviorCategory(behavior);
|
|
|
|
const event = document.createElement('div');
|
|
event.className = 'event';
|
|
event.setAttribute('data-behavior', behavior);
|
|
event.setAttribute('data-category', category);
|
|
|
|
const timePercentage = ((hour * 60 + minute) / (24 * 60)) * 100;
|
|
event.style.left = `${timePercentage}%`;
|
|
|
|
const rowIndex = categoryRows[category];
|
|
const baseOffset = 20;
|
|
const rowSpacing = 8; // 增加行间距
|
|
event.style.top = `${baseOffset + (rowIndex * rowSpacing)}px`;
|
|
|
|
// 设置事件样式
|
|
const baseWidth = 4;
|
|
event.style.width = `${baseWidth * currentZoom}px`;
|
|
event.style.backgroundColor = getBehaviorColor(behavior);
|
|
|
|
const time = `${hour.toString().padStart(2, '0')}:${minute.toString().padStart(2, '0')}`;
|
|
event.setAttribute('data-time', time);
|
|
|
|
event.addEventListener('mouseover', showTooltip);
|
|
event.addEventListener('mouseout', hideTooltip);
|
|
|
|
timeline.appendChild(event);
|
|
});
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// 更新图例
|
|
updateLegend(behaviorColors);
|
|
}
|
|
|
|
// 更新图例函数
|
|
function updateLegend(behaviorColors) {
|
|
const legend = document.getElementById('legend');
|
|
legend.innerHTML = '';
|
|
|
|
// 按行为名称排序
|
|
const sortedBehaviors = Array.from(behaviorColors.entries())
|
|
.sort((a, b) => a[0].localeCompare(b[0], 'zh'));
|
|
|
|
// 创建图例容器
|
|
const legendContainer = document.createElement('div');
|
|
legendContainer.className = 'legend-container';
|
|
|
|
// 添加所有行为的图例
|
|
sortedBehaviors.forEach(([behavior, color]) => {
|
|
const legendItem = document.createElement('div');
|
|
legendItem.className = 'legend-item';
|
|
// 添加 active 类作为默认状态
|
|
legendItem.classList.add('active');
|
|
legendItem.innerHTML = `
|
|
<div class="legend-color" style="background: ${color}"></div>
|
|
<span>${behavior}</span>
|
|
`;
|
|
|
|
// 添加点击事件
|
|
legendItem.addEventListener('click', () => {
|
|
legendItem.classList.toggle('active');
|
|
filterTimelineEvents();
|
|
});
|
|
|
|
legendContainer.appendChild(legendItem);
|
|
});
|
|
|
|
legend.appendChild(legendContainer);
|
|
}
|
|
|
|
// 添加过滤时间轴事件的函数
|
|
function filterTimelineEvents() {
|
|
const timeline = document.getElementById('timeline');
|
|
const events = timeline.querySelectorAll('.event');
|
|
const activeLegendItems = document.querySelectorAll('.legend-item.active');
|
|
const activeBehaviors = new Set(
|
|
Array.from(activeLegendItems).map(item => item.querySelector('span').textContent)
|
|
);
|
|
|
|
events.forEach(event => {
|
|
const behavior = event.getAttribute('data-behavior');
|
|
if (activeBehaviors.has(behavior)) {
|
|
event.style.display = 'block';
|
|
} else {
|
|
event.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
|
|
// 添加随机颜色生成函数
|
|
function getRandomColor() {
|
|
// 预定义的备用颜色
|
|
const fallbackColors = [
|
|
'#E91E63', // 粉红色
|
|
'#9C27B0', // 紫色
|
|
'#673AB7', // 深紫色
|
|
'#00BCD4', // 青色
|
|
'#FF5722', // 深橙色
|
|
'#607D8B', // 蓝灰色
|
|
'#4CAF50' // 翠绿色
|
|
];
|
|
|
|
return fallbackColors[Math.floor(Math.random() * fallbackColors.length)];
|
|
}
|
|
|
|
// 修改获取行为颜色的逻辑
|
|
function getBehaviorColor(behavior) {
|
|
// 如果行为已经有对应的颜色,直接返回
|
|
if (behaviorColors.has(behavior)) {
|
|
return behaviorColors.get(behavior);
|
|
}
|
|
|
|
// 首先尝试从 cls 文件中匹配颜色
|
|
if (window.actions && window.actionColors) {
|
|
for (const [mainCategory, subCategories] of Object.entries(window.actions)) {
|
|
for (const [subCategory, behaviors] of Object.entries(subCategories)) {
|
|
if (behaviors.includes(behavior)) {
|
|
const color = window.actionColors[subCategory];
|
|
if (color) {
|
|
behaviorColors.set(behavior, color);
|
|
return color;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// 如果在 cls 文件中找不到匹配的颜色,使用预设的备用颜色
|
|
const color = getRandomColor();
|
|
behaviorColors.set(behavior, color);
|
|
return color;
|
|
}
|
|
|
|
// 更新图表
|
|
function updateCharts(stats) {
|
|
// 行为分布图表
|
|
const behaviorChart = echarts.init(document.getElementById('behaviorChart'));
|
|
const behaviorData = Object.entries(stats.behaviors).map(([name, value]) => ({
|
|
name,
|
|
value
|
|
}));
|
|
|
|
behaviorChart.setOption({
|
|
tooltip: {
|
|
trigger: 'item',
|
|
formatter: '{b}: {c} ({d}%)'
|
|
},
|
|
legend: {
|
|
type: 'scroll', // 启用滚动
|
|
orient: 'vertical', // 改为垂直布局
|
|
right: 10, // 位于右侧
|
|
top: 'center', // 垂直居中
|
|
height: '80%', // 限制图例高度
|
|
textStyle: {
|
|
fontSize: 12 // 减小字体大小
|
|
},
|
|
pageButtonPosition: 'end', // 翻页按钮位置
|
|
pageButtonGap: 5, // 翻页按钮间距
|
|
pageFormatter: '{current}/{total}', // 页码格式
|
|
pageIconSize: 12, // 翻页按钮大小
|
|
},
|
|
series: [{
|
|
name: '行为分布',
|
|
type: 'pie',
|
|
radius: ['40%', '70%'],
|
|
center: ['40%', '50%'], // 将饼图向左移动
|
|
avoidLabelOverlap: false,
|
|
itemStyle: {
|
|
borderRadius: 10,
|
|
borderColor: '#fff',
|
|
borderWidth: 2
|
|
},
|
|
label: {
|
|
show: false,
|
|
position: 'center'
|
|
},
|
|
emphasis: {
|
|
label: {
|
|
show: true,
|
|
fontSize: '20',
|
|
fontWeight: 'bold'
|
|
}
|
|
},
|
|
labelLine: {
|
|
show: false
|
|
},
|
|
data: behaviorData
|
|
}]
|
|
});
|
|
|
|
// 时段分析图表
|
|
const timeChart = echarts.init(document.getElementById('timeChart'));
|
|
const hours = Array.from({length: 24}, (_, i) => `${i}:00`);
|
|
const timeData = hours.map(hour => stats.timeDistribution[parseInt(hour)] || 0);
|
|
|
|
timeChart.setOption({
|
|
tooltip: {
|
|
trigger: 'axis',
|
|
axisPointer: {
|
|
type: 'shadow'
|
|
}
|
|
},
|
|
grid: {
|
|
left: '3%',
|
|
right: '4%',
|
|
bottom: '3%',
|
|
containLabel: true
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: hours,
|
|
axisTick: {
|
|
alignWithLabel: true
|
|
}
|
|
},
|
|
yAxis: {
|
|
type: 'value'
|
|
},
|
|
series: [{
|
|
name: '行为数量',
|
|
type: 'bar',
|
|
barWidth: '60%',
|
|
data: timeData,
|
|
itemStyle: {
|
|
color: '#2962ff'
|
|
}
|
|
}]
|
|
});
|
|
|
|
// 高峰时段分析图表
|
|
const peakTimeChart = echarts.init(document.getElementById('peakTimeChart'));
|
|
peakTimeChart.setOption({
|
|
tooltip: {
|
|
trigger: 'axis'
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
data: hours
|
|
},
|
|
yAxis: {
|
|
type: 'value',
|
|
name: '行为数量'
|
|
},
|
|
series: [{
|
|
data: timeData,
|
|
type: 'line',
|
|
smooth: true,
|
|
areaStyle: {
|
|
opacity: 0.3
|
|
},
|
|
lineStyle: {
|
|
width: 3
|
|
},
|
|
itemStyle: {
|
|
color: '#2962ff'
|
|
}
|
|
}]
|
|
});
|
|
}
|
|
|
|
// 更新事件列表
|
|
function updateEventList(data) {
|
|
const eventList = document.querySelector('.event-list');
|
|
const eventListContent = document.createElement('div');
|
|
|
|
// 获取所有事件并按时间排序
|
|
const events = [];
|
|
Object.values(data).forEach(cameraData => {
|
|
Object.entries(cameraData).forEach(([key, value]) => {
|
|
if (value.video_analysis?.['qwen-7B']?.extracted_info) {
|
|
events.push({
|
|
timestamp: new Date(value.timestamp),
|
|
info: value.video_analysis['qwen-7B'].extracted_info,
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
// 按时间降序排序
|
|
events.sort((a, b) => b.timestamp - a.timestamp);
|
|
|
|
// 只显示前3个事件
|
|
events.slice(0, 3).forEach(event => {
|
|
const eventItem = document.createElement('div');
|
|
eventItem.className = 'event-list-item';
|
|
eventItem.innerHTML = `
|
|
<div class="event-info">
|
|
<div class="event-icon">
|
|
<i class="material-icons">${getActionIcon(event.info.actions[0])}</i>
|
|
</div>
|
|
<div class="event-details">
|
|
<strong>${event.info.actions.join(', ')}</strong>
|
|
<span class="event-time">${event.timestamp.toLocaleTimeString()}</span>
|
|
</div>
|
|
</div>
|
|
<div class="event-features">
|
|
<span class="confidence-badge">人数: ${event.info.num_people}</span>
|
|
</div>
|
|
`;
|
|
eventListContent.appendChild(eventItem);
|
|
});
|
|
|
|
// 清除现有事件列表并添加新的
|
|
const oldContent = eventList.querySelector('.event-list-header').nextElementSibling;
|
|
if (oldContent) {
|
|
oldContent.remove();
|
|
}
|
|
eventList.appendChild(eventListContent);
|
|
}
|
|
|
|
// 获取行为对应的图标
|
|
function getActionIcon(action) {
|
|
const iconMap = {
|
|
'走': 'directions_walk',
|
|
'站': 'accessibility',
|
|
'跑': 'directions_run',
|
|
'坐': 'event_seat',
|
|
'工作': 'computer',
|
|
'吃': 'restaurant',
|
|
'喝水': 'local_drink'
|
|
};
|
|
|
|
for (const [key, icon] of Object.entries(iconMap)) {
|
|
if (action.includes(key)) {
|
|
return icon;
|
|
}
|
|
}
|
|
return 'help_outline';
|
|
}
|
|
|
|
// 初始化页面
|
|
async function initPage() {
|
|
// 绑定摄像头切换事件
|
|
const cameraItems = document.querySelectorAll('.camera-item');
|
|
cameraItems.forEach((item, index) => {
|
|
item.addEventListener('click', async () => {
|
|
// 更新UI状态
|
|
cameraItems.forEach(cam => cam.classList.remove('active'));
|
|
item.classList.add('active');
|
|
|
|
// 设置日期为今天
|
|
const today = new Date().toISOString().split('T')[0];
|
|
const datePickers = document.querySelectorAll('input[type="date"]');
|
|
datePickers.forEach(picker => picker.value = today);
|
|
|
|
// 重新加载数据
|
|
await loadCameraData(`camera00${index + 1}`);
|
|
});
|
|
});
|
|
|
|
// 绑定日期选择事件
|
|
const datePickers = document.querySelectorAll('input[type="date"]');
|
|
datePickers.forEach(picker => {
|
|
picker.valueAsDate = new Date();
|
|
picker.addEventListener('change', async () => {
|
|
const activeCamera = document.querySelector('.camera-item.active');
|
|
const cameraIndex = Array.from(cameraItems).indexOf(activeCamera);
|
|
await loadCameraData(`camera00${cameraIndex + 1}`, picker.value.replace(/-/g, ''));
|
|
});
|
|
});
|
|
|
|
// 绑定搜索框事件
|
|
const searchInput = document.querySelector('.search-box input');
|
|
searchInput.addEventListener('input', handleSearch);
|
|
|
|
// 初始加载第一个摄像头的数据
|
|
await loadCameraData('camera001');
|
|
|
|
// 绑定窗口大小改变事件
|
|
window.addEventListener('resize', function() {
|
|
const charts = document.querySelectorAll('.chart-container');
|
|
charts.forEach(container => {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.resize();
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
// 加载摄像头数据
|
|
async function loadCameraData(cameraId, date) {
|
|
// 先清理页面数据
|
|
clearPageData();
|
|
|
|
|
|
const data = await fetchCameraData(cameraId, date);
|
|
if (data && data.data) {
|
|
lastFetchedData = data.data; // 保存获取的数据
|
|
const stats = parseVideoAnalysis(data.data);
|
|
updateStatCards(stats);
|
|
updateTimeline(data.data);
|
|
updateCharts(stats);
|
|
updateEventList(data.data);
|
|
}
|
|
}
|
|
|
|
// 处理搜索
|
|
function handleSearch(e) {
|
|
const searchText = e.target.value.toLowerCase();
|
|
|
|
// 处理时间轴事件
|
|
const timelineEvents = document.querySelectorAll('.event-item');
|
|
timelineEvents.forEach(event => {
|
|
const eventText = event.textContent;
|
|
if (searchText === '') {
|
|
event.style.opacity = '1';
|
|
event.style.transform = 'translateY(0)';
|
|
event.style.height = '24px';
|
|
event.style.backgroundColor = '';
|
|
} else if (eventText.toLowerCase().includes(searchText)) {
|
|
event.style.opacity = '1';
|
|
event.style.transform = 'translateY(-2px)';
|
|
event.style.height = '28px';
|
|
event.style.backgroundColor = 'var(--primary-color)';
|
|
} else {
|
|
event.style.opacity = '0.3';
|
|
event.style.transform = 'translateY(2px)';
|
|
event.style.height = '20px';
|
|
}
|
|
});
|
|
|
|
// 处理事件列表
|
|
const eventItems = document.querySelectorAll('.event-list-item');
|
|
eventItems.forEach(item => {
|
|
const behaviorElement = item.querySelector('.event-details strong');
|
|
const timeElement = item.querySelector('.event-time');
|
|
const behaviorText = behaviorElement.textContent;
|
|
const timeText = timeElement.textContent;
|
|
|
|
if (behaviorText.toLowerCase().includes(searchText) ||
|
|
timeText.toLowerCase().includes(searchText)) {
|
|
item.style.display = 'flex';
|
|
if (searchText) {
|
|
behaviorElement.innerHTML = highlightText(behaviorText, searchText);
|
|
timeElement.innerHTML = highlightText(timeText, searchText);
|
|
} else {
|
|
behaviorElement.textContent = behaviorText;
|
|
timeElement.textContent = timeText;
|
|
}
|
|
} else {
|
|
item.style.display = 'none';
|
|
}
|
|
});
|
|
}
|
|
|
|
// 高亮搜索文本
|
|
function highlightText(text, searchText) {
|
|
if (!searchText) return text;
|
|
const regex = new RegExp(`(${searchText})`, 'gi');
|
|
return text.replace(regex, '<span class="highlight">$1</span>');
|
|
}
|
|
|
|
function initPageSwitching() {
|
|
const dailySummaryNav = document.querySelector('.daily-summary');
|
|
const cameraItems = document.querySelectorAll('.camera-item');
|
|
const regularContent = document.querySelectorAll('.dashboard-grid, .timeline-card, .chart-grid, .event-list');
|
|
const summarySection = document.querySelector('.summary-section');
|
|
|
|
// 初始状态设置
|
|
summarySection.style.display = 'none';
|
|
|
|
dailySummaryNav.addEventListener('click', function() {
|
|
// 隐藏常规内容
|
|
regularContent.forEach(item => item.style.display = 'none');
|
|
// 显示总结内容
|
|
summarySection.style.display = 'block';
|
|
// 更新导航状态
|
|
cameraItems.forEach(item => item.classList.remove('active'));
|
|
dailySummaryNav.classList.add('active');
|
|
});
|
|
|
|
// 点击摄像头时的处理
|
|
cameraItems.forEach(item => {
|
|
item.addEventListener('click', function() {
|
|
// 显示常规内容,根据不同类型设置不同的display值
|
|
regularContent.forEach(content => {
|
|
if (content.classList.contains('dashboard-grid')) {
|
|
content.style.display = 'grid';
|
|
} else if (content.classList.contains('chart-grid')) {
|
|
content.style.display = 'grid';
|
|
} else {
|
|
content.style.display = 'block';
|
|
}
|
|
});
|
|
// 隐藏总结内容
|
|
summarySection.style.display = 'none';
|
|
// 更新导航状态
|
|
dailySummaryNav.classList.remove('active');
|
|
cameraItems.forEach(cam => cam.classList.remove('active'));
|
|
this.classList.add('active');
|
|
});
|
|
});
|
|
}
|
|
|
|
// 添加清除页面数据的函数
|
|
function clearPageData() {
|
|
// 清除统计卡片数据
|
|
const statValues = document.querySelectorAll('.stat-value');
|
|
statValues.forEach(el => {
|
|
if (el) el.textContent = '--';
|
|
});
|
|
|
|
// 清除时间轴
|
|
const timeline = document.getElementById('timeline');
|
|
if (timeline) {
|
|
timeline.innerHTML = '';
|
|
}
|
|
|
|
// 清除图例
|
|
const legend = document.getElementById('legend');
|
|
if (legend) {
|
|
legend.innerHTML = '';
|
|
}
|
|
|
|
// 清除图表数据
|
|
const chartIds = ['behaviorChart', 'timeChart', 'peakTimeChart'];
|
|
chartIds.forEach(id => {
|
|
const container = document.getElementById(id);
|
|
if (container) {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.clear();
|
|
}
|
|
}
|
|
});
|
|
|
|
// 清除事件列表
|
|
const eventList = document.querySelector('.event-list');
|
|
if (eventList) {
|
|
const eventListContent = eventList.querySelector('.event-list-header')?.nextElementSibling;
|
|
if (eventListContent) {
|
|
eventListContent.remove();}
|
|
}
|
|
}
|
|
|
|
// 添加 tooltip 相关函数
|
|
function showTooltip(e) {
|
|
const tooltip = document.createElement('div');
|
|
tooltip.className = 'tooltip';
|
|
const time = e.target.getAttribute('data-time');
|
|
const behavior = e.target.getAttribute('data-behavior');
|
|
|
|
tooltip.innerHTML = `
|
|
<div style="font-weight: bold">${time}</div>
|
|
<div>${behavior}</div>
|
|
`;
|
|
|
|
// 设置tooltip位置
|
|
tooltip.style.position = 'fixed';
|
|
tooltip.style.left = (e.clientX + 10) + 'px';
|
|
tooltip.style.top = (e.clientY + 10) + 'px';
|
|
|
|
// 移除旧的tooltip
|
|
const oldTooltip = document.querySelector('.tooltip');
|
|
if (oldTooltip) {
|
|
oldTooltip.remove();
|
|
}
|
|
|
|
document.body.appendChild(tooltip);
|
|
}
|
|
|
|
function hideTooltip() {
|
|
const tooltip = document.querySelector('.tooltip');
|
|
if (tooltip) {
|
|
tooltip.remove();
|
|
}
|
|
}
|
|
|
|
// 添加 tooltip 样式
|
|
const styleSheet = document.createElement('style');
|
|
styleSheet.textContent = `
|
|
.tooltip {
|
|
position: fixed;
|
|
background: white;
|
|
color: var(--text-color);
|
|
padding: 8px 12px;
|
|
border-radius: 6px;
|
|
font-size: 12px;
|
|
pointer-events: none;
|
|
z-index: 1000;
|
|
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
|
border: 1px solid var(--border-color);
|
|
}
|
|
`;
|
|
document.head.appendChild(styleSheet);
|
|
|
|
// 处理tooltip位置更新
|
|
document.addEventListener('mousemove', function(e) {
|
|
const tooltip = document.querySelector('.tooltip');
|
|
if (tooltip) {
|
|
tooltip.style.left = (e.clientX + 10) + 'px';
|
|
tooltip.style.top = (e.clientY + 10) + 'px';
|
|
}
|
|
});
|
|
|
|
window.onload = function() {
|
|
initPage();
|
|
initPageSwitching();
|
|
|
|
// 保留窗口大小改变事件监听
|
|
window.addEventListener('resize', function() {
|
|
const charts = document.querySelectorAll('.chart-container');
|
|
charts.forEach(container => {
|
|
const chart = echarts.getInstanceByDom(container);
|
|
if (chart) {
|
|
chart.resize();
|
|
}
|
|
});
|
|
});
|
|
};
|
|
</script>
|
|
</body>
|
|
</html> |