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

158 lines
5.0KB

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