skill-radar.component.ts 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. import { Component, OnInit, AfterViewInit, OnDestroy, ViewChild, ElementRef } from '@angular/core';
  2. import { CommonModule } from '@angular/common';
  3. import * as echarts from 'echarts';
  4. interface SkillData {
  5. label: string;
  6. current: number;
  7. target: number;
  8. teamAvg: number;
  9. }
  10. interface SkillAnalysisItem {
  11. name: string;
  12. score: number;
  13. status: string;
  14. }
  15. @Component({
  16. selector: 'app-skill-radar',
  17. standalone: true,
  18. imports: [CommonModule],
  19. templateUrl: './skill-radar.component.html',
  20. styleUrl: './skill-radar.component.scss'
  21. })
  22. export class SkillRadarComponent implements OnInit, AfterViewInit, OnDestroy {
  23. @ViewChild('radarChart') radarChartRef!: ElementRef<HTMLDivElement>;
  24. private radarChart: any = null;
  25. viewMode: 'self' | 'comparison' = 'self';
  26. // 能力维度数据
  27. skillDimensions: SkillData[] = [
  28. { label: '建模能力', current: 85, target: 95, teamAvg: 78 },
  29. { label: '渲染技巧', current: 76, target: 90, teamAvg: 72 },
  30. { label: '软装搭配', current: 90, target: 95, teamAvg: 85 },
  31. { label: '沟通能力', current: 70, target: 85, teamAvg: 75 },
  32. { label: '项目管理', current: 65, target: 80, teamAvg: 68 },
  33. { label: '创新能力', current: 82, target: 90, teamAvg: 76 }
  34. ];
  35. // 能力分析数据
  36. skillAnalysis: SkillAnalysisItem[] = [
  37. { name: '建模能力', score: 85, status: '优秀' },
  38. { name: '渲染技巧', score: 76, status: '良好' },
  39. { name: '软装搭配', score: 90, status: '优秀' },
  40. { name: '沟通能力', score: 70, status: '需要提升' },
  41. { name: '项目管理', score: 65, status: '需要提升' },
  42. { name: '创新能力', score: 82, status: '良好' }
  43. ];
  44. // 提升建议
  45. improvementSuggestions = [
  46. '在项目管理方面,建议使用敏捷管理方法,提高任务优先级判断能力',
  47. '沟通能力可以通过主动与客户进行阶段性汇报来提升',
  48. '渲染技巧可以学习新的灯光设置和材质调整方法,提升作品真实感',
  49. '继续保持软装搭配和建模能力的优势,探索更多创新风格'
  50. ];
  51. constructor() { }
  52. ngOnInit(): void {
  53. // 初始化组件数据
  54. }
  55. ngAfterViewInit(): void {
  56. // 初始化雷达图
  57. this.initRadarChart();
  58. }
  59. // 切换视图模式
  60. switchViewMode(mode: 'self' | 'comparison'): void {
  61. this.viewMode = mode;
  62. this.updateRadarChart();
  63. }
  64. // 初始化雷达图
  65. private initRadarChart(): void {
  66. const chartDom = this.radarChartRef.nativeElement;
  67. this.radarChart = echarts.init(chartDom);
  68. const option = this.getEChartsOption();
  69. this.radarChart.setOption(option);
  70. // 窗口调整大小时重绘图表
  71. window.addEventListener('resize', () => {
  72. if (this.radarChart) {
  73. this.radarChart.resize();
  74. }
  75. });
  76. }
  77. // 获取ECharts配置选项
  78. private getEChartsOption() {
  79. const indicators = this.skillDimensions.map(dim => ({
  80. name: dim.label,
  81. max: 100
  82. }));
  83. const series = [
  84. {
  85. name: '个人能力',
  86. type: 'radar',
  87. data: [
  88. {
  89. value: this.skillDimensions.map(dim => dim.current),
  90. name: '个人能力',
  91. itemStyle: {
  92. color: '#ff6384'
  93. },
  94. areaStyle: {
  95. color: 'rgba(255, 99, 132, 0.2)'
  96. }
  97. }
  98. ]
  99. }
  100. ];
  101. if (this.viewMode === 'comparison') {
  102. series[0].data.push({
  103. value: this.skillDimensions.map(dim => dim.teamAvg),
  104. name: '团队平均',
  105. itemStyle: {
  106. color: '#36a2eb'
  107. },
  108. areaStyle: {
  109. color: 'rgba(54, 162, 235, 0.2)'
  110. }
  111. });
  112. }
  113. return {
  114. title: {
  115. text: '能力雷达图',
  116. left: 'center',
  117. textStyle: {
  118. fontSize: 16,
  119. color: '#333'
  120. }
  121. },
  122. legend: {
  123. data: this.viewMode === 'comparison' ? ['个人能力', '团队平均'] : ['个人能力'],
  124. bottom: 10
  125. },
  126. radar: {
  127. indicator: indicators,
  128. radius: '60%',
  129. axisLine: {
  130. lineStyle: {
  131. color: 'rgba(200, 200, 200, 0.3)'
  132. }
  133. },
  134. splitLine: {
  135. lineStyle: {
  136. color: 'rgba(200, 200, 200, 0.3)'
  137. }
  138. },
  139. splitArea: {
  140. show: false
  141. }
  142. },
  143. series: series,
  144. tooltip: {
  145. trigger: 'item',
  146. formatter: function(params: any) {
  147. return `${params.seriesName}<br/>${params.name}: ${params.value}`;
  148. }
  149. }
  150. };
  151. }
  152. // 更新雷达图
  153. private updateRadarChart(): void {
  154. if (this.radarChart) {
  155. const option = this.getEChartsOption();
  156. this.radarChart.setOption(option);
  157. }
  158. }
  159. // 清理图表资源
  160. ngOnDestroy(): void {
  161. if (this.radarChart) {
  162. this.radarChart.destroy();
  163. }
  164. }
  165. }