数据可视化大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

second1.component.ts 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. import { AfterViewInit, Component, ElementRef, OnInit, ViewChild, inject } from '@angular/core';
  2. import { ModalHelper, TitleService, _HttpClient } from '@delon/theme';
  3. import { SHARED_IMPORTS } from '@shared';
  4. import { AgGridAngular } from 'ag-grid-angular';
  5. import { ColDef, GridApi } from 'ag-grid-community';
  6. import * as echarts from 'echarts';
  7. import { NzPaginationModule } from 'ng-zorro-antd/pagination';
  8. import { MqttService } from 'ngx-mqtt';
  9. import { DataVCardComponent } from '../card/card.component';
  10. import { DataVLjCarInfoTableComponent } from '../lj-car-info-table/lj-car-info-table.component';
  11. import { DataVLjDashboardComponent } from '../lj-dashboard/lj-dashboard.component';
  12. import { DataVTitleComponent } from '../title/title.component';
  13. import { AgGridComponentComponent } from '../workstation/ag-grid-component/ag-grid-component.component';
  14. import { GridButtonValueRenderer } from '../workstation/grid-button/grid-button';
  15. import { LjAgGridComponentComponent } from '../workstation/lj-ag-grid-component/lj-ag-grid-component.component';
  16. @Component({
  17. selector: 'app-data-v-s1',
  18. standalone: true,
  19. templateUrl: './second1.component.html',
  20. styleUrls: ['./second1.component.less'],
  21. imports: [
  22. DataVLjCarInfoTableComponent,
  23. AgGridAngular,
  24. AgGridComponentComponent,
  25. LjAgGridComponentComponent,
  26. NzPaginationModule,
  27. DataVCardComponent,
  28. GridButtonValueRenderer,
  29. DataVTitleComponent,
  30. DataVLjDashboardComponent,
  31. ...SHARED_IMPORTS,
  32. DataVLjCarInfoTableComponent
  33. ]
  34. })
  35. export class DataVSecond1Component implements OnInit {
  36. private readonly http = inject(_HttpClient);
  37. private readonly modal = inject(ModalHelper);
  38. private readonly elementRef = inject(ElementRef);
  39. private readonly titleService = inject(TitleService);
  40. public chartDom = document.getElementById('main')!;
  41. // public myChart = echarts.init(this.chartDom);
  42. // public option!: EChartsOption;
  43. @ViewChild('myGrid') grid!: AgGridAngular;
  44. public defaultColDef: ColDef = {
  45. width: 170,
  46. editable: false
  47. };
  48. public gridThemedClass: string = 'ag-theme-quartz ag-theme-datav';
  49. //多模拟几行数据出来
  50. rowData: object[] = [];
  51. colDefs1: ColDef[] = [
  52. {
  53. headerName: '序号',
  54. valueGetter: function (params: any) {
  55. return parseInt(params.node.id) + 1;
  56. },
  57. width: 90,
  58. // flex: 2,
  59. sortable: true,
  60. unSortIcon: true,
  61. field: 'xh'
  62. },
  63. { headerName: '任务名称', unSortIcon: true, width: 120, field: 'rwmc' },
  64. { headerName: '任务描述', unSortIcon: true, field: 'rwms', width: 120 },
  65. { headerName: '开始时间', headerClass: 'ag-header-center', unSortIcon: true, field: 'kssj', width: 180 },
  66. { headerName: '计划完成时间', unSortIcon: true, field: 'jhwcsj', width: 180 },
  67. { headerName: '超期', width: 70, field: 'sfcq' },
  68. { headerName: '操作', width: 90, autoHeaderHeight: true, field: 'cz', cellRenderer: GridButtonValueRenderer }
  69. ];
  70. colDefs2: ColDef[] = [
  71. {
  72. headerName: '序号',
  73. valueGetter: function (params: any) {
  74. return parseInt(params.node.id) + 1;
  75. },
  76. width: 90,
  77. unSortIcon: true,
  78. field: 'xh'
  79. },
  80. { headerName: '任务名称', unSortIcon: true, field: 'rwmc' },
  81. { headerName: '任务描述', unSortIcon: true, field: 'rwms', minWidth: 170, flex: 1 },
  82. { headerName: '开始时间', unSortIcon: true, field: 'kssj', minWidth: 170, flex: 1 },
  83. { headerName: '当前状态', field: 'dqzt' },
  84. { headerName: '当前节点', field: 'dqjd' },
  85. { headerName: '实际完成时间', field: 'sjwcsj', minWidth: 170, flex: 1 },
  86. { headerName: '操作', autoHeaderHeight: true, width: 110, field: 'cz', cellRenderer: GridButtonValueRenderer }
  87. ];
  88. client: any;
  89. constructor(private _mqttService: MqttService) {
  90. this.client = _mqttService;
  91. }
  92. initCharts(): void {
  93. // 获取DOM
  94. const lineChart = echarts.init(document.getElementById('lineChart')); // console.log(lineChart);
  95. const option = {
  96. tooltip: {
  97. formatter: '{a} <br/>{b} : {c}%'
  98. },
  99. series: [
  100. {
  101. name: 'Pressure',
  102. type: 'gauge',
  103. progress: {
  104. show: true
  105. },
  106. detail: {
  107. valueAnimation: true,
  108. formatter: '{value}'
  109. },
  110. data: [
  111. {
  112. value: 50,
  113. name: 'SCORE'
  114. }
  115. ]
  116. }
  117. ]
  118. };
  119. lineChart.setOption(option);
  120. }
  121. ngOnInit(): void {
  122. this.titleService.setTitle('我的工作站');
  123. for (var i = 1; i < 30; i++) {
  124. this.rowData.push({
  125. rwmc: `任务${i}`,
  126. rwms: `任务描述${i}`,
  127. kssj: `2024-1-${i} 13:38:${i * 11}`,
  128. jhwcsj: `2024-1-${i} 13:38:${i * 10}`,
  129. sfcq: '否',
  130. dqzt: '正常',
  131. dqjd: `节点${i}`,
  132. sjwcsj: `2024-1-${i} 13:38:${i * 27}`,
  133. bjmc: '报警5',
  134. bjms: '报警描述5',
  135. bjsj: `2024-1-${i} 13:38:${i * 12}`,
  136. gzyy: '-',
  137. clff: '-',
  138. tzsj: `2024-1-${i} 13:38:${i * 19}`,
  139. zycd: '一般',
  140. tzmc: '系统提示',
  141. tznr: '账户登录',
  142. fj: '-',
  143. cz: '操作'
  144. });
  145. }
  146. this.initCharts();
  147. }
  148. ngAfterViewInit(): void {
  149. // 获取 ag-grid 元素
  150. const gridDiv = this.elementRef.nativeElement.querySelector('.ag-theme-datav');
  151. // 获取 ag-grid 内部滚动容器元素
  152. const scrollContainer = gridDiv.querySelector('.ag-body-viewport');
  153. // 获取滚动条元素
  154. const scrollBar = gridDiv.querySelector('.ag-scroller');
  155. }
  156. add(): void {
  157. // this.modal
  158. // .createStatic(FormEditComponent, { i: { id: 0 } })
  159. // .subscribe(() => this.st.reload());
  160. }
  161. }