| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- <div>
- {{-- 标题和控制 --}}
- <div class="flex items-center justify-between">
- <div>
- <h3 class="text-lg font-medium text-gray-900">掌握度热力图</h3>
- <p class="mt-1 text-sm text-gray-500">
- 以网格形式展示学生对各知识点的掌握情况
- </p>
- </div>
- @if (!empty($heatmapData['data']))
- <div class="text-sm text-gray-600">
- 共 {{ count($heatmapData['data']) }} 个知识点
- </div>
- @endif
- </div>
- {{-- 热力图容器 --}}
- <div class="relative bg-white rounded-lg border border-gray-200 p-6" style="min-height: 400px;">
- @if ($isLoading)
- <div class="flex items-center justify-center h-96">
- <div class="flex flex-col items-center">
- <svg class="animate-spin h-8 w-8 text-indigo-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
- <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
- <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
- </svg>
- <p class="mt-3 text-sm text-gray-600">正在加载热力图数据...</p>
- </div>
- </div>
- @elseif ($errorMessage)
- <div class="flex items-center justify-center h-96">
- <div class="text-center">
- <svg class="mx-auto h-12 w-12 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900">加载失败</h3>
- <p class="mt-1 text-sm text-red-600">{{ $errorMessage }}</p>
- </div>
- </div>
- @elseif (empty($heatmapData['data']))
- <div class="flex items-center justify-center h-96">
- <div class="text-center">
- <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
- <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path>
- </svg>
- <h3 class="mt-2 text-sm font-medium text-gray-900">暂无热力图数据</h3>
- <p class="mt-1 text-sm text-gray-500">该学生还没有掌握度数据</p>
- </div>
- </div>
- @else
- {{-- 简单的文本展示代替热力图 --}}
- <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
- @foreach ($heatmapData['data'] as $index => $item)
- <div class="p-4 border rounded-lg" style="background-color: {{ $this->getMasteryColor($item['mastery_level'] ?? 0) }};">
- <div class="text-sm font-medium text-white">{{ $item['kp_code'] ?? 'N/A' }}</div>
- <div class="text-xs text-white mt-1">{{ number_format(($item['mastery_level'] ?? 0) * 100, 1) }}%</div>
- </div>
- @endforeach
- </div>
- {{-- 分类图例 --}}
- @if (!empty($heatmapData['categories']))
- <div class="mt-4 flex flex-wrap gap-4 justify-center">
- @foreach ($heatmapData['categories'] as $category)
- <div class="flex items-center space-x-2">
- <div class="w-3 h-3 rounded-full bg-indigo-500"></div>
- <span class="text-xs text-gray-600">{{ $category }}</span>
- </div>
- @endforeach
- </div>
- @endif
- @endif
- </div>
- {{-- ECharts 脚本(简化版) --}}
- <script>
- document.addEventListener('livewire:initialized', () => {
- console.log('热力图已初始化');
- });
- // 监听 Livewire 更新
- document.addEventListener('livewire:update', () => {
- console.log('热力图数据已更新');
- });
- </script>
- </div>
|