数据可视化大屏
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.

161 lines
5.1KB

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