time-series-chart-widget.component.html
6.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<!--
Copyright © 2016-2024 The Thingsboard Authors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div class="tb-time-series-chart-panel" [style.padding]="padding"
[class.overlay]="overlayEnabled" [style]="backgroundStyle$ | async">
<div class="tb-time-series-chart-overlay" [style]="overlayStyle"></div>
<ng-container *ngTemplateOutlet="widgetTitlePanel"></ng-container>
<div class="tb-time-series-chart-content" [class]="legendClass">
<div #chartShape class="tb-time-series-chart-shape">
</div>
<div *ngIf="showLegend" class="tb-time-series-chart-legend" [class.tb-simple-legend]="!displayLegendValues">
<ng-container *ngIf="displayLegendValues; else simpleLegend">
<ng-container *ngIf="horizontalLegendPosition; else verticalLegend">
<ng-container *ngTemplateOutlet="horizontalLegend"></ng-container>
</ng-container>
</ng-container>
</div>
<ng-template #horizontalLegend>
<table class="tb-time-series-chart-legend-table">
<thead>
<tr>
<th></th>
<th *ngFor="let legendKey of legendKeys">
<ng-container *ngTemplateOutlet="legendItem; context:{legendKey: legendKey}"></ng-container>
</th>
</tr>
</thead>
<tbody>
<ng-container *ngIf="legendConfig.showMin === true">
<ng-container *ngTemplateOutlet="legendDataRow; context:{label: 'legend.Min', type: 'min'}"></ng-container>
</ng-container>
<ng-container *ngIf="legendConfig.showMax === true">
<ng-container *ngTemplateOutlet="legendDataRow; context:{label: 'legend.Max', type: 'max'}"></ng-container>
</ng-container>
<ng-container *ngIf="legendConfig.showAvg === true">
<ng-container *ngTemplateOutlet="legendDataRow; context:{label: 'legend.Avg', type: 'avg'}"></ng-container>
</ng-container>
<ng-container *ngIf="legendConfig.showTotal === true">
<ng-container *ngTemplateOutlet="legendDataRow; context:{label: 'legend.Total', type: 'total'}"></ng-container>
</ng-container>
<ng-container *ngIf="legendConfig.showLatest === true">
<ng-container *ngTemplateOutlet="legendDataRow; context:{label: 'legend.Latest', type: 'latest'}"></ng-container>
</ng-container>
</tbody>
</table>
</ng-template>
<ng-template #verticalLegend>
<table class="tb-time-series-chart-legend-table vertical">
<thead>
<tr>
<th></th>
<th class="tb-time-series-chart-legend-type-label right" *ngIf="legendConfig.showMin === true">{{ 'legend.Min' | translate }}</th>
<th class="tb-time-series-chart-legend-type-label right" *ngIf="legendConfig.showMax === true">{{ 'legend.Max' | translate }}</th>
<th class="tb-time-series-chart-legend-type-label right" *ngIf="legendConfig.showAvg === true">{{ 'legend.Avg' | translate }}</th>
<th class="tb-time-series-chart-legend-type-label right" *ngIf="legendConfig.showTotal === true">{{ 'legend.Total' | translate }}</th>
<th class="tb-time-series-chart-legend-type-label right" *ngIf="legendConfig.showLatest === true">{{ 'legend.Latest' | translate }}</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let legendKey of legendKeys">
<th>
<ng-container *ngTemplateOutlet="legendItem; context:{legendKey: legendKey, left: true}"></ng-container>
</th>
<td *ngIf="legendConfig.showMin === true" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex].min }}
</td>
<td *ngIf="legendConfig.showMax === true" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex].max }}
</td>
<td *ngIf="legendConfig.showAvg === true" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex].avg }}
</td>
<td *ngIf="legendConfig.showTotal === true" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex].total }}
</td>
<td *ngIf="legendConfig.showLatest === true" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex].latest }}
</td>
</tr>
</tbody>
</table>
</ng-template>
<ng-template #simpleLegend>
<ng-container *ngFor="let legendKey of legendKeys">
<ng-container *ngTemplateOutlet="legendItem; context:{legendKey: legendKey}"></ng-container>
</ng-container>
</ng-template>
<ng-template #legendItem let-legendKey="legendKey" let-left="left">
<div class="tb-time-series-chart-legend-item"
[class.left]="left">
<div class="tb-time-series-chart-legend-item-label"
(mouseenter)="onLegendKeyEnter(legendKey)"
(mouseleave)="onLegendKeyLeave(legendKey)"
(click)="toggleLegendKey(legendKey)">
<div class="tb-time-series-chart-legend-item-label-circle" [style]="{background: !legendKey.dataKey.hidden ? legendKey.dataKey.color : null}"></div>
<div [style]="!legendKey.dataKey.hidden ? legendLabelStyle : disabledLegendLabelStyle">{{ legendKey.dataKey.label }}</div>
</div>
</div>
</ng-template>
<ng-template #legendDataRow let-label="label" let-type="type">
<tr>
<th class="tb-time-series-chart-legend-type-label">{{ label | translate }}</th>
<td *ngFor="let legendKey of legendKeys" class="tb-time-series-chart-legend-value">
{{ legendData.data[legendKey.dataIndex][type] }}
</td>
</tr>
</ng-template>
</div>
</div>