mastery-heatmap.blade.php 4.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <div>
  2. {{-- 标题和控制 --}}
  3. <div class="flex items-center justify-between">
  4. <div>
  5. <h3 class="text-lg font-medium text-gray-900">掌握度热力图</h3>
  6. <p class="mt-1 text-sm text-gray-500">
  7. 以网格形式展示学生对各知识点的掌握情况
  8. </p>
  9. </div>
  10. @if (!empty($heatmapData['data']))
  11. <div class="text-sm text-gray-600">
  12. 共 {{ count($heatmapData['data']) }} 个知识点
  13. </div>
  14. @endif
  15. </div>
  16. {{-- 热力图容器 --}}
  17. <div class="relative bg-white rounded-lg border border-gray-200 p-6" style="min-height: 400px;">
  18. @if ($isLoading)
  19. <div class="flex items-center justify-center h-96">
  20. <div class="flex flex-col items-center">
  21. <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">
  22. <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
  23. <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>
  24. </svg>
  25. <p class="mt-3 text-sm text-gray-600">正在加载热力图数据...</p>
  26. </div>
  27. </div>
  28. @elseif ($errorMessage)
  29. <div class="flex items-center justify-center h-96">
  30. <div class="text-center">
  31. <svg class="mx-auto h-12 w-12 text-red-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  32. <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>
  33. </svg>
  34. <h3 class="mt-2 text-sm font-medium text-gray-900">加载失败</h3>
  35. <p class="mt-1 text-sm text-red-600">{{ $errorMessage }}</p>
  36. </div>
  37. </div>
  38. @elseif (empty($heatmapData['data']))
  39. <div class="flex items-center justify-center h-96">
  40. <div class="text-center">
  41. <svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
  42. <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>
  43. </svg>
  44. <h3 class="mt-2 text-sm font-medium text-gray-900">暂无热力图数据</h3>
  45. <p class="mt-1 text-sm text-gray-500">该学生还没有掌握度数据</p>
  46. </div>
  47. </div>
  48. @else
  49. {{-- 简单的文本展示代替热力图 --}}
  50. <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
  51. @foreach ($heatmapData['data'] as $index => $item)
  52. <div class="p-4 border rounded-lg" style="background-color: {{ $this->getMasteryColor($item['mastery_level'] ?? 0) }};">
  53. <div class="text-sm font-medium text-white">{{ $item['kp_code'] ?? 'N/A' }}</div>
  54. <div class="text-xs text-white mt-1">{{ number_format(($item['mastery_level'] ?? 0) * 100, 1) }}%</div>
  55. </div>
  56. @endforeach
  57. </div>
  58. {{-- 分类图例 --}}
  59. @if (!empty($heatmapData['categories']))
  60. <div class="mt-4 flex flex-wrap gap-4 justify-center">
  61. @foreach ($heatmapData['categories'] as $category)
  62. <div class="flex items-center space-x-2">
  63. <div class="w-3 h-3 rounded-full bg-indigo-500"></div>
  64. <span class="text-xs text-gray-600">{{ $category }}</span>
  65. </div>
  66. @endforeach
  67. </div>
  68. @endif
  69. @endif
  70. </div>
  71. {{-- ECharts 脚本(简化版) --}}
  72. <script>
  73. document.addEventListener('livewire:initialized', () => {
  74. console.log('热力图已初始化');
  75. });
  76. // 监听 Livewire 更新
  77. document.addEventListener('livewire:update', () => {
  78. console.log('热力图数据已更新');
  79. });
  80. </script>
  81. </div>