@openremote/or-attribute-barchart 1.8.0-snapshot.20250818084938

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts ADDED
@@ -0,0 +1,249 @@
1
+ import { LitElement, PropertyValues, TemplateResult } from "lit";
2
+ import { Asset, AssetDatapointIntervalQueryFormula, AssetDatapointQueryUnion, Attribute, AttributeRef, DatapointInterval } from "@openremote/model";
3
+ import * as echarts from "echarts/core";
4
+ import { DatasetComponentOption, DataZoomComponentOption, GridComponentOption, TooltipComponentOption } from "echarts/components";
5
+ import { BarSeriesOption } from "echarts/charts";
6
+ import moment from "moment";
7
+ import "@openremote/or-mwc-components/or-mwc-menu";
8
+ /**
9
+ * Bar chart configuration with options for individual attributes.
10
+ * For example, a list of attributes aligned to the axis on the right side.
11
+ */
12
+ export interface BarChartAttributeConfig {
13
+ rightAxisAttributes?: AttributeRef[];
14
+ faintAttributes?: AttributeRef[];
15
+ methodMaxAttributes?: AttributeRef[];
16
+ methodMinAttributes?: AttributeRef[];
17
+ methodAvgAttributes?: AttributeRef[];
18
+ methodDifferenceAttributes?: AttributeRef[];
19
+ methodMedianAttributes?: AttributeRef[];
20
+ methodModeAttributes?: AttributeRef[];
21
+ methodSumAttributes?: AttributeRef[];
22
+ methodCountAttributes?: AttributeRef[];
23
+ }
24
+ /**
25
+ * Interval configuration for a user to select from.
26
+ * It contains a {@link displayName}, together with a step+interval like "6 hours".
27
+ */
28
+ export interface IntervalConfig {
29
+ displayName: string;
30
+ steps: number;
31
+ orFormat: DatapointInterval;
32
+ momentFormat: moment.unitOfTime.DurationConstructor;
33
+ millis: number;
34
+ }
35
+ /**
36
+ * List of interval options
37
+ */
38
+ export declare enum BarChartInterval {
39
+ AUTO = "auto",
40
+ NONE = "none",
41
+ ONE_MINUTE = "1Minute",
42
+ FIVE_MINUTES = "5Minutes",
43
+ THIRTY_MINUTES = "30Minutes",
44
+ ONE_HOUR = "hour",
45
+ ONE_DAY = "day",
46
+ ONE_WEEK = "week",
47
+ ONE_MONTH = "month",
48
+ ONE_YEAR = "year"
49
+ }
50
+ /**
51
+ * ECharts dataset object with additional optional fields for visualization purposes.
52
+ * For example, {@link assetId} and {@link attrName} can be specified, so their information can be shown alongside the data itself.
53
+ */
54
+ export interface BarChartData extends BarSeriesOption {
55
+ index?: number;
56
+ assetId?: string;
57
+ attrName?: string;
58
+ unit?: string;
59
+ yAxisIndex?: number;
60
+ color?: string;
61
+ }
62
+ export type ECChartOption = echarts.ComposeOption<BarSeriesOption | TooltipComponentOption | GridComponentOption | DatasetComponentOption | DataZoomComponentOption>;
63
+ export declare class OrAttributeBarChart extends LitElement {
64
+ static readonly DEFAULT_COLORS: string[];
65
+ /**
66
+ * Asset data to display in the bar chart. This array needs to be populated.
67
+ * Used for the chart legend, information about units, and retrieval of data points.
68
+ */
69
+ assets: Asset[];
70
+ /**
71
+ * List of attributes to display in the bar chart. This array needs to be populated.
72
+ * Used for the chart legend, and the retrieval of data points.
73
+ * Formatted as a JSON array of;
74
+ *
75
+ * ```[<index of {@link assets}>, {@link Attribute}]```
76
+ */
77
+ assetAttributes: [number, Attribute<any>][];
78
+ /**
79
+ * Realm name to associate all the chart data with.
80
+ */
81
+ realm: string | undefined;
82
+ /**
83
+ * The list of HEX colors representing the line color for each {@link AttributeRef}.
84
+ * Acts as an override, and will fall back to the {@link colors} attribute if not specified.
85
+ * The {@link AttributeRef} object with Asset ID and Attribute name need to be present in the Chart to work.
86
+ * The HEX color should be put in without '#' prefix. For example, you'd use '4d9d2a' instead of '#4d9d2a'.
87
+ */
88
+ readonly attributeColors: [AttributeRef, string][];
89
+ /**
90
+ * The attribute configuration object with, for example, a list of right-axis attributes.
91
+ * See {@link BarChartAttributeConfig} for full documentation on the options.
92
+ */
93
+ readonly attributeConfig?: BarChartAttributeConfig;
94
+ /**
95
+ * List of colors to display attributes values with inside the bar chart.
96
+ * The array corresponds with {@link assetAttributes}, so the 1st color will be used for the 1st attribute.
97
+ */
98
+ readonly colors: string[];
99
+ /**
100
+ * The query object to request attribute data / data points with.
101
+ * Normally, it's of type {@link AssetDatapointIntervalQuery}, including a start- and end time.
102
+ */
103
+ readonly datapointQuery: AssetDatapointQueryUnion;
104
+ /**
105
+ * Selected timeframe using a [start date, end date] array format.
106
+ */
107
+ timeframe?: [Date, Date];
108
+ /**
109
+ * Custom ECharts options object to configure the chart appearance.
110
+ * See their documentation for more info: https://echarts.apache.org/en/option.html
111
+ */
112
+ chartOptions?: ECChartOption;
113
+ /**
114
+ * Shows a right-side legend with the list of visible attributes.
115
+ */
116
+ showLegend: boolean;
117
+ /**
118
+ * Shows the right-side legend (toggled with {@link showLegend}) in a compact / dense format.
119
+ */
120
+ denseLegend: boolean;
121
+ /**
122
+ * Displays the bar chart in a vertically "stacked" configuration.
123
+ * It will display a cumulative effect of all data series on top of each other.
124
+ */
125
+ stacked: boolean;
126
+ /**
127
+ * Enables time control for the user, allowing them to customize the {@link timeframe} shown.
128
+ * Leaving this disabled/unset will show them in a "read-only" state.
129
+ */
130
+ timestampControls: boolean;
131
+ /**
132
+ * Number of decimals to display for attributes.
133
+ */
134
+ decimals: number;
135
+ /**
136
+ * A JSON array list of strings that represent the prefix options in the UI, such as "current" or "last".
137
+ * In combination with {@link timeWindowOptions}, it provides a timeframe like "current 1 hour" to display data of.
138
+ */
139
+ timePrefixOptions: string[];
140
+ /**
141
+ * The selected option from {@link timePrefixOptions}, such as "current" or "last".
142
+ * In combination with {@link timeWindowOptions}, it provides a timeframe like "current 1 hour" to display data of.
143
+ */
144
+ timePrefixKey?: string;
145
+ /**
146
+ * A JSON object containing a list of time window options, like "1 day", "6 hours" or "52 weeks".
147
+ * In combination with {@link timePrefixOptions}, it provides a timeframe like "last 6 hours" to display data of.
148
+ * The input should contain a JavaScript {@link Map}, containing the following:
149
+ * - A {@link string} with a unique key like "6hours",
150
+ * - A combination of any {@link moment.unitOfTime.DurationConstructor} and {@link number}, like ["hours", 6]
151
+ *
152
+ * Example input: `{"6hours": ["hours", 6], "4weeks": ["weeks", 4]}`
153
+ */
154
+ timeWindowOptions: Map<string, [moment.unitOfTime.DurationConstructor, number]>;
155
+ /**
156
+ * The key value of the selected option from {@link timeWindowOptions}, such as "1day", "6hours" or "52weeks".
157
+ * In combination with {@link timePrefixOptions}, it provides a timeframe like "last 6 hours" to display data of.
158
+ */
159
+ timeWindowKey?: string;
160
+ /**
161
+ * A JSON object containing a list of interval options, like "30minutes", "hour" or "day".
162
+ * It determines the interval to display data in sections. For example, split the data every 5 minutes of the past hour.
163
+ * In combination with the active formula in {@link datapointQuery}, such as AVG and MIN/MAX, it will show a '5 minute' average of the past hour.
164
+ * The input should contain a JavaScript {@link Map}, containing the following:
165
+ * - A {@link BarChartInterval} string with a unique key like "hour" or "day",
166
+ * - A {@link IntervalConfig} object with details on the interval, such as the display name and the unit of time.
167
+ *
168
+ * Example input:
169
+ * ```
170
+ * {"30minutes": {
171
+ * displayName: "30Minutes", // translated automatically
172
+ * steps: 30,
173
+ * orFormat: "minute",
174
+ * momentFormat: "minutes", // using moment.js format
175
+ * millis: 1800000
176
+ * }}
177
+ * ```
178
+ */
179
+ intervalOptions: Map<BarChartInterval, IntervalConfig>;
180
+ /**
181
+ * The key value of the selected option from {@link intervalOptions}, such as "30minute", "hour" or "week".
182
+ * In combination with the active formula in {@link datapointQuery}, such as AVG and MIN/MAX, it will show a '5 minute' average of the past hour.
183
+ */
184
+ interval?: BarChartInterval;
185
+ /**
186
+ * Whether a custom {@link timeframe} has been configured by the user or not.
187
+ * If it's a default value provided by us, it will be `false`.
188
+ * If a user customized the timeframe, it will be `true`.
189
+ * @protected
190
+ */
191
+ protected _isCustomWindow: boolean;
192
+ /**
193
+ * Loading state when fetching data from a remote source.
194
+ * Show a "loading indicator" in the UI when set to `true`.
195
+ * @protected
196
+ */
197
+ protected _loading: boolean;
198
+ /**
199
+ * Cached array of {@link BarChartData} objects to display in the chart.
200
+ * It contains custom data, but data from the ECharts library as well (see {@link BarSeriesOption} for details)
201
+ * @protected
202
+ */
203
+ protected _data?: BarChartData[];
204
+ protected _chartElem: HTMLDivElement;
205
+ protected _chart?: echarts.ECharts;
206
+ protected _style: CSSStyleDeclaration;
207
+ protected _startOfPeriod?: number;
208
+ protected _endOfPeriod?: number;
209
+ protected _latestError?: string;
210
+ protected _dataAbortController?: AbortController;
211
+ protected _containerResizeObserver?: ResizeObserver;
212
+ protected _intervalConfig?: IntervalConfig;
213
+ static get styles(): import("lit").CSSResult[];
214
+ connectedCallback(): void;
215
+ disconnectedCallback(): void;
216
+ willUpdate(changedProps: PropertyValues): void;
217
+ updated(changedProps: PropertyValues): void;
218
+ render(): TemplateResult<1>;
219
+ protected _getTimeControlsTemplate(disabled?: boolean): TemplateResult;
220
+ protected _getTimeframeStatusTemplate(timeframe?: [Date, Date] | undefined): TemplateResult;
221
+ protected _getLegendTemplate(): TemplateResult;
222
+ protected _openTimeDialog(startTimestamp?: number, endTimestamp?: number): void;
223
+ /**
224
+ * Removes all active Chart bars color highlights, by reducing/increasing opacity.
225
+ * @protected
226
+ */
227
+ protected _removeDatasetHighlights(chart?: echarts.ECharts | undefined): void;
228
+ /**
229
+ * Adds a Chart bar color highlight, by reducing/increasing opacity.
230
+ * So the given bar (represented by {@link assetId} and {@link attrName} will be emphasized, while others are less visible.
231
+ * @param attrRef - Asset ID and attribute name to be highlighted
232
+ * @param chart - ECharts instance to add the highlight to.
233
+ */
234
+ protected _addDatasetHighlight(attrRef: AttributeRef, chart?: echarts.ECharts | undefined): void;
235
+ protected _applyChartResponsiveness(): void;
236
+ protected _cleanup(): void;
237
+ protected _getTimeSelectionDates(timePrefixSelected: string, timeWindowSelected: string): [Date, Date];
238
+ protected _shiftTimeframe(currentStart: Date, currentEnd: Date, timeWindowSelected: string, direction: string): void;
239
+ protected _getInterval(start: number, end: number, selectedInterval: BarChartInterval, exact?: boolean): IntervalConfig;
240
+ protected _loadData(): Promise<void>;
241
+ protected _loadAttributeData(asset: Asset, attribute: Attribute<any>, color: string, from: number, to: number, formula: AssetDatapointIntervalQueryFormula, faint?: boolean, label?: string, options?: any, _unit?: any): Promise<BarChartData>;
242
+ protected _updateChartData(): void;
243
+ protected _toggleChartEventListeners(connect: boolean): void;
244
+ protected _getDefaultChartOptions(): ECChartOption;
245
+ protected _getDefaultDatasetOptions(name: string, formula: string, color: string, faint?: boolean): BarChartData;
246
+ static getDefaultTimePrefixOptions(): string[];
247
+ static getDefaultTimeWindowOptions(): Map<string, [moment.unitOfTime.DurationConstructor, number]>;
248
+ static getDefaultIntervalOptions(): Map<BarChartInterval, IntervalConfig>;
249
+ }
package/lib/index.js ADDED
@@ -0,0 +1,289 @@
1
+ var OrAttributeBarChart_1,__decorate=this&&this.__decorate||function(t,e,i,r){var o,a=arguments.length,s=a<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,r);else for(var n=t.length-1;n>=0;n--)(o=t[n])&&(s=(a<3?o(s):a>3?o(e,i,s):o(e,i))||s);return a>3&&s&&Object.defineProperty(e,i,s),s},__awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))(function(o,a){function s(t){try{l(r.next(t))}catch(t){a(t)}}function n(t){try{l(r.throw(t))}catch(t){a(t)}}function l(t){var e;t.done?o(t.value):((e=t.value)instanceof i?e:new i(function(t){t(e)})).then(s,n)}l((r=r.apply(t,e||[])).next())})};import{css as t,html as e,LitElement as i,unsafeCSS as r}from"lit";import{customElement as o,property as a,state as s,query as n}from"lit/decorators.js";import l from"i18next";import{AssetModelUtil as d}from"@openremote/model";import m,{DefaultColor3 as h,DefaultColor4 as u,Util as c}from"@openremote/core";import*as p from"echarts/core";import{DataZoomComponent as f,GridComponent as v,TooltipComponent as y}from"echarts/components";import{BarChart as g}from"echarts/charts";import{CanvasRenderer as _}from"echarts/renderers";import{UniversalTransition as b}from"echarts/features";import{InputType as O}from"@openremote/or-mwc-components/or-mwc-input";import x from"moment";import{getAssetDescriptorIconTemplate as w}from"@openremote/or-icon";import{isAxiosError as C}from"@openremote/rest";import{OrMwcDialog as A,showDialog as E}from"@openremote/or-mwc-components/or-mwc-dialog";import{showSnackbar as $}from"@openremote/or-mwc-components/or-mwc-snackbar";import{cache as N}from"lit/directives/cache.js";import"@openremote/or-mwc-components/or-mwc-menu";import{getContentWithMenuTemplate as T}from"@openremote/or-mwc-components/or-mwc-menu";import{when as M}from"lit/directives/when.js";import{createRef as D,ref as B}from"lit/directives/ref.js";p.use([v,y,f,g,_,b]);export var BarChartInterval;!function(t){t.AUTO="auto",t.NONE="none",t.ONE_MINUTE="1Minute",t.FIVE_MINUTES="5Minutes",t.THIRTY_MINUTES="30Minutes",t.ONE_HOUR="hour",t.ONE_DAY="day",t.ONE_WEEK="week",t.ONE_MONTH="month",t.ONE_YEAR="year"}(BarChartInterval||(BarChartInterval={}));let style=t`
2
+ :host {
3
+ --internal-or-chart-text-color: var(--or-chart-text-color, var(--or-app-color3, ${r(h)}));
4
+ --internal-or-chart-graph-fill-color: var(--or-chart-graph-fill-color, var(--or-app-color4, ${r(u)}));
5
+ --internal-or-chart-graph-point-hover-border-color: var(--or-chart-graph-point-hover-border-color, var(--or-app-color3, ${r(h)}));
6
+ width: 100%;
7
+ display: block;
8
+ }
9
+
10
+ .button-icon {
11
+ align-self: center;
12
+ padding: 10px;
13
+ cursor: pointer;
14
+ }
15
+
16
+ .mdc-dialog .mdc-dialog__surface {
17
+ min-width: 600px;
18
+ height: calc(100vh - 50%);
19
+ }
20
+
21
+ :host([hidden]) {
22
+ display: none;
23
+ }
24
+
25
+ #container {
26
+ display: flex;
27
+ min-width: 0;
28
+ flex-direction: row;
29
+ height: 100%;
30
+ }
31
+
32
+ #period-controls {
33
+ display: flex;
34
+ flex-direction: column;
35
+ align-items: center;
36
+ }
37
+
38
+ #period-dropdown-controls {
39
+ flex: 0;
40
+ display: flex;
41
+ }
42
+
43
+ #period-dropdown-controls > *:first-child {
44
+ margin-right: -2px;
45
+ }
46
+
47
+ #period-dropdown-controls > *:last-child {
48
+ margin-left: -2px;
49
+ }
50
+
51
+ .navigate {
52
+ flex-direction: column;
53
+ }
54
+
55
+ #controls {
56
+ display: flex;
57
+ flex-wrap: wrap;
58
+ width: 100%;
59
+ flex-direction: column;
60
+ justify-content: center;
61
+ }
62
+
63
+ #attribute-list {
64
+ overflow: hidden auto;
65
+ min-height: 50px;
66
+ flex: 1 1 0;
67
+ width: 100%;
68
+ display: flex;
69
+ flex-direction: column;
70
+ }
71
+
72
+ .attribute-list-dense {
73
+ flex-wrap: wrap;
74
+ }
75
+
76
+ .attribute-list-item {
77
+ cursor: pointer;
78
+ display: flex;
79
+ flex-direction: row;
80
+ align-items: center;
81
+ padding: 0;
82
+ min-height: 50px;
83
+ }
84
+
85
+ .attribute-list-item-dense {
86
+ min-height: 28px;
87
+ }
88
+
89
+ .attribute-list-item-label {
90
+ display: flex;
91
+ flex: 1 1 0;
92
+ line-height: 16px;
93
+ flex-direction: column;
94
+ }
95
+
96
+ .attribute-list-item-bullet {
97
+ width: 12px;
98
+ height: 12px;
99
+ border-radius: 7px;
100
+ margin-right: 10px;
101
+ }
102
+
103
+ .attribute-list-item .button.delete {
104
+ display: none;
105
+ }
106
+
107
+ .attribute-list-item:hover .button.delete {
108
+ display: block;
109
+ }
110
+
111
+ #controls > * {
112
+ margin-top: 5px;
113
+ margin-bottom: 5px;
114
+ }
115
+
116
+ .dialog-container {
117
+ display: flex;
118
+ flex-direction: row;
119
+ flex: 1 1 0;
120
+ }
121
+
122
+ .dialog-container > * {
123
+ flex: 1 1 0;
124
+ }
125
+
126
+ .dialog-container > or-mwc-input {
127
+ background-color: var(--or-app-color2);
128
+ border-left: 3px solid var(--or-app-color4);
129
+ }
130
+
131
+ #chart-container {
132
+ flex: 1 1 0;
133
+ position: relative;
134
+ overflow: hidden;
135
+ /*min-height: 400px;
136
+ max-height: 550px;*/
137
+ }
138
+
139
+ #chart-controls {
140
+ display: flex;
141
+ flex-direction: column;
142
+ margin-top: 10px;
143
+ margin-right: -4px;
144
+ }
145
+
146
+ #chart {
147
+ width: 100%;
148
+ height: 100%;
149
+ }
150
+
151
+ @media screen and (max-width: 1280px) {
152
+ #chart-container {
153
+ }
154
+ }
155
+
156
+ @media screen and (max-width: 769px) {
157
+ .mdc-dialog .mdc-dialog__surface {
158
+ min-width: auto;
159
+
160
+ max-width: calc(100vw - 32px);
161
+ max-height: calc(100% - 32px);
162
+ }
163
+
164
+ #container {
165
+ flex-direction: column;
166
+ }
167
+
168
+ #controls {
169
+ min-width: 100%;
170
+ padding-left: 0;
171
+ }
172
+
173
+ .interval-controls,
174
+ #period-controls {
175
+ flex-direction: row;
176
+ justify-content: left;
177
+ align-items: center;
178
+ gap: 8px;
179
+ }
180
+ }
181
+ `,OrAttributeBarChart=OrAttributeBarChart_1=class extends i{constructor(){super(...arguments),this.assets=[],this.assetAttributes=[],this.realm=null==m?void 0:m.displayRealm,this.attributeColors=[],this.colors=OrAttributeBarChart_1.DEFAULT_COLORS,this.showLegend=!1,this.denseLegend=!1,this.stacked=!1,this.timestampControls=!0,this.decimals=2,this.timePrefixOptions=OrAttributeBarChart_1.getDefaultTimePrefixOptions(),this.timeWindowOptions=OrAttributeBarChart_1.getDefaultTimeWindowOptions(),this.intervalOptions=OrAttributeBarChart_1.getDefaultIntervalOptions(),this._isCustomWindow=!1,this._loading=!1}static get styles(){return[style]}connectedCallback(){super.connectedCallback(),this._style=window.getComputedStyle(this)}disconnectedCallback(){super.disconnectedCallback(),this._cleanup()}willUpdate(t){return t.has("realm")&&t.get("realm")&&(this.assets=[],this.assetAttributes=[]),t.has("timePrefixOptions")&&this.timePrefixOptions&&(null!=this.timePrefixKey||(this.timePrefixKey=this.timePrefixOptions[0])),t.has("timeWindowOptions")&&this.timeWindowOptions&&(null!=this.timeWindowKey||(this.timeWindowKey=Array.from(this.timeWindowOptions.keys())[0])),t.has("intervalOptions")&&this.intervalOptions&&(null!=this.interval||(this.interval=Array.from(this.intervalOptions.keys())[0])),super.willUpdate(t)}updated(t){var e,i,r;if(super.updated(t),t.has("attributeColors")||t.has("datapointQuery")||t.has("timeframe")||t.has("interval")||t.has("timePrefixKey")||t.has("timeWindowKey")||t.has("attributeConfig")||t.has("assetAttributes")||t.has("realm")){this._data=void 0,this._chart&&this._cleanup();let t=this._getTimeSelectionDates(this.timePrefixKey,this.timeWindowKey);this._startOfPeriod=this.timeframe?this.timeframe[0].getTime():t[0].getTime(),this._endOfPeriod=this.timeframe?this.timeframe[1].getTime():t[1].getTime(),this._intervalConfig=this._getInterval(this._startOfPeriod,this._endOfPeriod,this.interval),this._loadData()}this._data&&(this._chart||(console.debug("Initializing chart..."),this.chartOptions=Object.assign(Object.assign({},this._getDefaultChartOptions()),this.chartOptions),this._chart=p.init(this._chartElem),this._chart.setOption(this.chartOptions),this._toggleChartEventListeners(!0)),t.has("_data")&&(null==(r=null==(i=null==(e=this._data)?void 0:e[0])?void 0:i.data)?void 0:r.length)&&this._updateChartData())}render(){var t;let i=this._loading||!!this._latestError;return e`
182
+ <div id="container">
183
+ ${M(this._loading,()=>e`
184
+ <div style="position: absolute; height: 100%; width: 100%;">
185
+ <or-loading-indicator ?overlay="false"></or-loading-indicator>
186
+ </div>
187
+ `)}
188
+ ${M(this._latestError,()=>{var t;return e`
189
+ <div style="position: absolute; height: 100%; width: 100%; display: flex; justify-content: center; align-items: center;">
190
+ <or-translate .value="${null!=(t=this._latestError)?t:"errorOccurred"}"></or-translate>
191
+ </div>
192
+ `})}
193
+ ${M(Object.keys(this.attributeConfig||{}).filter(t=>t.startsWith("method")).every(t=>0===this.attributeConfig[t].length),()=>e`
194
+ <div style="position: inherit; height: 100%; width: 100%; display: flex; justify-content: center; align-items: center; z-index: 1; pointer-events: none;">
195
+ <or-translate .value="${"dashboard.selectMethod"}"></or-translate>
196
+ </div>
197
+ `)}
198
+ ${M(null==(t=this._data)?void 0:t.every(t=>{var e;return!(null==(e=t.data)?void 0:e.length)}),()=>e`
199
+ <div style="position: inherit; height: 100%; width: 100%; display: flex; justify-content: center; align-items: center; z-index: 1; pointer-events: none;">
200
+ <or-translate .value="${"dashboard.noData"}"></or-translate>
201
+ </div>
202
+ `)}
203
+ <div id="chart-container">
204
+ <div id="chart" style="visibility: ${i?"hidden":"visible"}"></div>
205
+ </div>
206
+
207
+ ${M(this.timestampControls||this.showLegend,()=>e`
208
+ <div id="chart-controls">
209
+ <div id="controls">
210
+ ${M(this.timestampControls&&this.timePrefixKey&&this.timePrefixOptions&&this.timeWindowKey&&this.timeWindowOptions,()=>this._getTimeControlsTemplate(i||!!this.timeframe),()=>{var t,i,r,o;return e`
211
+ <div style="display: flex; justify-content: center;">
212
+ <or-mwc-input .type="${O.BUTTON}" label="${l.t(null!=(i=null==(t=this.timePrefixKey)?void 0:t.toLowerCase())?i:"???")}" disabled style="margin-right: -2px;"></or-mwc-input>
213
+ <or-mwc-input .type="${O.BUTTON}" label="${l.t(null!=(o=null==(r=this.timeWindowKey)?void 0:r.toLowerCase())?o:"???")}" disabled style="margin-left: -2px;"></or-mwc-input>
214
+ </div>
215
+ `})}
216
+ ${M(this.timeframe,()=>this._getTimeframeStatusTemplate(this.timeframe))}
217
+ </div>
218
+ ${N(M(this.showLegend,()=>this._getLegendTemplate()))}
219
+ </div>
220
+ `)}
221
+ </div>
222
+ `}_getTimeControlsTemplate(t=!0){var i,r,o,a;return e`
223
+ <div id="period-controls">
224
+ <div id="period-dropdown-controls">
225
+ <!-- Time prefix selection -->
226
+ ${T(e`<or-mwc-input .type="${O.BUTTON}" label="${this.timeframe?"dashboard.customTimeSpan":this.timePrefixKey}" ?disabled="${t}"></or-mwc-input>`,t?null:this.timePrefixOptions.map(t=>({value:t})),this.timePrefixKey,t=>{this.timeframe=void 0,this.timePrefixKey=t.toString()},void 0,void 0,void 0,!0)}
227
+ <!-- Time window selection -->
228
+ ${T(e`<or-mwc-input .type="${O.BUTTON}" label="${this._isCustomWindow?"timeframe":l.t(null!=(r=null==(i=this.timeWindowKey)?void 0:i.toLowerCase())?r:"")}" ?disabled="${t}"></or-mwc-input>`,t?null:Array.from(this.timeWindowOptions.keys()).map(t=>({value:t,text:t.toLowerCase(),translate:!0})),this.timeWindowKey,t=>{this.timeframe=void 0,this.timeWindowKey=t.toString()},void 0,void 0,void 0,!0)}
229
+ </div>
230
+ <!-- Interval selection -->
231
+ ${T(e`<or-mwc-input .type="${O.BUTTON}" label="${l.t(`intervalBy${null==(a=null==(o=this._intervalConfig)?void 0:o.displayName)?void 0:a.toLowerCase()}`)}"></or-mwc-input>`,Array.from(this.intervalOptions.keys()).map(t=>({value:t,text:`intervalBy${t.toLowerCase()}`,translate:!0})),this.interval,t=>this.interval=t,void 0,void 0,void 0,!0)}
232
+ </div>
233
+ <div class="navigate" style="text-align: right">
234
+ <!-- Scroll left button -->
235
+ <or-icon class="button button-icon" ?disabled="${t}" icon="chevron-left"
236
+ @click="${()=>this._shiftTimeframe(this.timeframe?this.timeframe[0]:new Date(this._startOfPeriod),this.timeframe?this.timeframe[1]:new Date(this._endOfPeriod),this.timeWindowKey,"previous")}"></or-icon>
237
+ <!-- Scroll right button -->
238
+ <or-icon class="button button-icon" ?disabled="${t}" icon="chevron-right"
239
+ @click="${()=>this._shiftTimeframe(this.timeframe?this.timeframe[0]:new Date(this._startOfPeriod),this.timeframe?this.timeframe[1]:new Date(this._endOfPeriod),this.timeWindowKey,"next")}"></or-icon>
240
+ <!-- Button that opens custom time selection or restores to widget setting-->
241
+ <or-icon class="button button-icon" ?disabled="${t}" icon="${this.timeframe?"restore":"calendar-clock"}"
242
+ @click="${()=>this.timeframe?(this._isCustomWindow=!1,this.timeframe=void 0):this._openTimeDialog(this._startOfPeriod,this._endOfPeriod)}"></or-icon>
243
+ </div>
244
+ `}_getTimeframeStatusTemplate(t=this.timeframe){return e`
245
+ <div style="margin-left: 18px; font-size: 12px; display: flex; justify-content: flex-end;">
246
+ <table style="text-align: right;">
247
+ <thead>
248
+ <tr>
249
+ <th style="font-weight: normal; text-align: right;"><or-translate value="from"></or-translate></th>
250
+ <th style="font-weight: normal; text-align: right;">${x(t[0]).format("lll")}</th>
251
+ </tr>
252
+ </thead>
253
+ <tbody>
254
+ <tr>
255
+ <td style="text-align: right;"><or-translate value="to"></or-translate></td>
256
+ <td style="text-align: right;">${x(t[1]).format("lll")}</td>
257
+ </tr>
258
+ </tbody>
259
+ </table>
260
+ </div>
261
+ `}_getLegendTemplate(){return e`
262
+ <div id="attribute-list" class="${this.denseLegend?"attribute-list-dense":void 0}">
263
+ ${M(null==this.assetAttributes||0===this.assetAttributes.length,()=>e`
264
+ <div>
265
+ <or-translate value="noAttributesConnected"></or-translate>
266
+ </div>
267
+ `)}
268
+ ${this.assetAttributes&&this.assetAttributes.map(([t,i],r)=>{var o,a,s;let n=this.assets[t];if(!n)return e`Error`;let m=r%this.colors.length,h=null==(o=this.attributeColors.find(t=>t[0].id===n.id&&t[0].name===i.name))?void 0:o[1],u=d.getAttributeAndValueDescriptors(n.type,i.name,i),p=c.getAttributeLabel(i,u[0],n.type,!0),f=(null==(s=null==(a=this.attributeConfig)?void 0:a.rightAxisAttributes)?void 0:s.find(t=>n.id===t.id&&i.name===t.name))?l.t("right"):void 0,v=(null!=h?h:this.colors[m])||"",y=Object.entries(this.attributeConfig||{}).filter(([t])=>t.includes("method")).sort(([t],[e])=>t.localeCompare(e)).reduce((t,[e,r])=>(r.some(t=>t.id===n.id&&t.name===i.name)&&t.push(l.t(`${e}-short`)),t),[]);return e`
269
+ <div class="attribute-list-item ${this.denseLegend?"attribute-list-item-dense":void 0}"
270
+ @mouseenter="${()=>this._addDatasetHighlight({id:this.assets[t].id,name:i.name})}"
271
+ @mouseleave="${()=>this._removeDatasetHighlights()}">
272
+ <span style="margin-right: 10px; --or-icon-width: 20px;">${w(d.getAssetDescriptor(this.assets[t].type),void 0,void 0,v.split("#")[1])}</span>
273
+ <div class="attribute-list-item-label ${this.denseLegend?"attribute-list-item-label-dense":void 0}">
274
+ <div style="display: flex; justify-content: space-between;">
275
+ <span style="font-size:12px; ${this.denseLegend?"margin-right: 8px":void 0}">${this.assets[t].name}</span>
276
+ ${M(f,()=>e`<span style="font-size:12px; color:grey">(${f})</span>`)}
277
+ </div>
278
+ <span style="font-size:12px; color:grey; white-space:pre-line;">${p} <br> (${y.join(", ")})</span>
279
+ </div>
280
+ </div>
281
+ `})}
282
+ </div>
283
+ `}_openTimeDialog(t,i){let r=D(),o=D();E(new A().setHeading(l.t("timeframe")).setContent(()=>e`
284
+ <div>
285
+ <or-mwc-input ${B(r)} type="${O.DATETIME}" required label="${l.t("start")}" .value="${t}"></or-mwc-input>
286
+ <or-mwc-input ${B(o)} type="${O.DATETIME}" required label="${l.t("ending")}" .value="${i}"></or-mwc-input>
287
+ </div>
288
+ `).setActions([{actionName:"cancel",content:"cancel"},{actionName:"ok",content:"ok",action:()=>{var t,e;(null==(t=r.value)?void 0:t.value)&&(null==(e=o.value)?void 0:e.value)&&r.value.value<o.value.value?(this._isCustomWindow=!0,this.timeframe=[new Date(r.value.value),new Date(o.value.value)]):$(void 0,l.t("errorOccurred"))}}]))}_removeDatasetHighlights(t=this._chart){var e;if(t){let i=t.getOption();null==(e=i.series)||e.forEach(t=>{null!=t.itemStyle||(t.itemStyle={}),.2===t.itemStyle.opacity||.99===t.itemStyle.opacity?t.itemStyle.opacity=.31:t.itemStyle.opacity=1}),t.setOption(i)}}_addDatasetHighlight(t,e=this._chart){var i;if(e){let r=e.getOption();null==(i=r.series)||i.forEach(e=>{null!=e.itemStyle||(e.itemStyle={}),e.assetId!==t.id||e.attrName!==t.name?.31===e.itemStyle.opacity?e.itemStyle.opacity=.2:e.itemStyle.opacity=.3:.31===e.itemStyle.opacity&&(e.itemStyle.opacity=.99)}),e.setOption(r)}}_applyChartResponsiveness(){var t,e,i;if(this.shadowRoot){let e=this.shadowRoot.getElementById("container");if(e){let i=e.clientWidth<600;e.style.flexDirection=i?"column":"row";let r=this.shadowRoot.getElementById("controls");r&&(r.style.flexDirection=i?"row":"column");let o=this.shadowRoot.getElementById("period-controls");o&&(o.style.flexDirection=i?"row":"column");let a=this.shadowRoot.getElementById("attribute-list");a&&(a.style.gap=i?"4px 12px":"",a.style.maxHeight=i?"90px":"",a.style.flexFlow=i?"row wrap":"column nowrap",a.style.padding=i?"0":"5px 0"),this.shadowRoot.querySelectorAll(".attribute-list-item").forEach(t=>{t.style.minHeight=i?"0px":"44px",t.style.paddingLeft=i?"":"16px",t.children[1].style.flexDirection=i?"row":"column",t.children[1].style.gap=i?"4px":""}),null==(t=this._chart)||t.resize()}}let r=Math.max(1,(this._endOfPeriod-this._startOfPeriod)/this._intervalConfig.millis-1),o=(null==(e=this._chartElem)?void 0:e.clientWidth)?this._chartElem.clientWidth/50:Number.MAX_SAFE_INTEGER,a=Math.max(1,Math.min(r,Math.floor(1.5*o)));null==(i=this._chart)||i.setOption({xAxis:{show:a>1,splitNumber:a,minInterval:this._intervalConfig.millis,axisLabel:{rotate:45*(a>o)}}})}_cleanup(){this._chart&&(console.debug("Destroying bar chart..."),this._toggleChartEventListeners(!1),this._chart.dispose(),this._chart=void 0,this.requestUpdate())}_getTimeSelectionDates(t,e){var i;let r=x(),o=x(),a=null==(i=this.timeWindowOptions)?void 0:i.get(e);if(!a)throw Error(`Unsupported time window selected: ${e}`);let[s,n]=a;switch(t){case"this":1===n?(r=x().startOf(s),o=x().endOf(s)):(r=x().subtract(.5*n,s),o=x().add(.5*n,s));break;case"last":r=x().subtract(n,s).startOf(s),o=1===n?x().startOf(s):x();break;default:console.error("Could not get time selection dates. The time prefix was not set correctly.")}return[r.toDate(),o.toDate()]}_shiftTimeframe(t,e,i,r){let o=this.timeWindowOptions.get(i);if(!o)throw Error(`Unsupported time window selected: ${i}`);let[a,s]=o,n=x(t);"previous"===r?n.subtract(s,a):n.add(s,a);let l=x(e);"previous"===r?l.subtract(s,a):l.add(s,a),this.timeframe=[n.toDate(),l.toDate()]}_getInterval(t,e,i,r=!1){let o=(e-t)/1e3/60/60,a=r?o:Math.round(o);if(i===BarChartInterval.AUTO)if(a<=1)return{displayName:"5Minutes-auto",steps:5,orFormat:"MINUTE",momentFormat:"minutes",millis:3e5};else if(a<=6)return{displayName:"30Minutes-auto",steps:30,orFormat:"MINUTE",momentFormat:"minutes",millis:18e5};else if(a<=24)return{displayName:"hour-auto",steps:1,orFormat:"HOUR",momentFormat:"hours",millis:36e5};else if(a<=744)return{displayName:"day-auto",steps:1,orFormat:"DAY",momentFormat:"days",millis:864e5};else if(a<=8760)return{displayName:"week-auto",steps:1,orFormat:"WEEK",momentFormat:"weeks",millis:6048e5};else return{displayName:"month-auto",steps:1,orFormat:"MONTH",momentFormat:"months",millis:2592e6};if(i===BarChartInterval.NONE){let t=this._endOfPeriod-this._startOfPeriod;return{displayName:"none",steps:Math.ceil(t/6e4),orFormat:"MINUTE",momentFormat:"minutes",millis:t}}let s=this.intervalOptions.get(i);if(x.duration(s.steps,s.momentFormat).asHours()<=a)return s;console.warn("Selected interval is larger than the timeframe! Changing to a valid timeframe...");let n=Array.from(this.intervalOptions.entries());for(let t=n.length-1;t>=0;t--){let[e,i]=n[t];if(x.duration(i.steps,i.momentFormat).asHours()<=a)return i}return n[0][1]}_loadData(){return __awaiter(this,void 0,void 0,function*(){var t;let e;if(this._data||!this.assetAttributes||!this.assets||0===this.assets.length||0===this.assetAttributes.length||!this.datapointQuery)return;if(this._loading)if(!this._dataAbortController)return;else this._dataAbortController.abort("Data request overridden"),delete this._dataAbortController;this._loading=!0,this._latestError=void 0;let i=[];try{this._dataAbortController=new AbortController,(e=this.assetAttributes.map((t,e)=>__awaiter(this,[t,e],void 0,function*([t,e],r){var o,a,s,n,m,h,u,p,f,v,y,g,_,b,O,x,w,C,A,E,$,N;let T=this.assets[t],M=!!(null==(a=null==(o=this.attributeConfig)?void 0:o.rightAxisAttributes)?void 0:a.find(t=>t.id===T.id&&t.name===e.name)),D=null==(s=this.attributeColors.find(t=>t[0].id===T.id&&t[0].name===e.name))?void 0:s[1],B=d.getAttributeAndValueDescriptors(T.type,e.name,e),I=!!(null==(m=null==(n=this.attributeConfig)?void 0:n.faintAttributes)?void 0:m.find(t=>t.id===T.id&&t.name===e.name)),P=c.getAttributeLabel(e,B[0],T.type,!1),S=c.resolveUnits(c.getAttributeUnits(e,B[0],T.type)),F=r%this.colors.length,L={signal:null==(h=this._dataAbortController)?void 0:h.signal},W={AVG:{active:!!(null==(p=null==(u=this.attributeConfig)?void 0:u.methodAvgAttributes)?void 0:p.find(t=>t.id===T.id&&t.name===e.name)),formula:"AVG"},COUNT:{active:!!(null==(v=null==(f=this.attributeConfig)?void 0:f.methodCountAttributes)?void 0:v.find(t=>t.id===T.id&&t.name===e.name)),formula:"COUNT"},DIFFERENCE:{active:!!(null==(g=null==(y=this.attributeConfig)?void 0:y.methodDifferenceAttributes)?void 0:g.find(t=>t.id===T.id&&t.name===e.name)),formula:"DIFFERENCE"},MAX:{active:!!(null==(b=null==(_=this.attributeConfig)?void 0:_.methodMaxAttributes)?void 0:b.find(t=>t.id===T.id&&t.name===e.name)),formula:"MAX"},MEDIAN:{active:!!(null==(x=null==(O=this.attributeConfig)?void 0:O.methodMedianAttributes)?void 0:x.find(t=>t.id===T.id&&t.name===e.name)),formula:"MEDIAN"},MIN:{active:!!(null==(C=null==(w=this.attributeConfig)?void 0:w.methodMinAttributes)?void 0:C.find(t=>t.id===T.id&&t.name===e.name)),formula:"MIN"},MODE:{active:!!(null==(E=null==(A=this.attributeConfig)?void 0:A.methodModeAttributes)?void 0:E.find(t=>t.id===T.id&&t.name===e.name)),formula:"MODE"},SUM:{active:!!(null==(N=null==($=this.attributeConfig)?void 0:$.methodSumAttributes)?void 0:N.find(t=>t.id===T.id&&t.name===e.name)),formula:"SUM"}};for(let[t,o]of Object.entries(W).sort(([t],[e])=>t.localeCompare(e)))if(o.active){let a=yield this._loadAttributeData(T,e,null!=D?D:this.colors[F],this._startOfPeriod,this._endOfPeriod,o.formula,I,`${T.name} | ${P}
289
+ ${l.t(o.formula)}`,L,S);a.index=1e3*Object.keys(W).indexOf(t)+(r+1),a.assetId=T.id,a.attrName=e.name,a.unit=S,a.yAxisIndex=+!!M,a.color=null!=D?D:this.colors[F],i.push(a)}})))&&(yield Promise.all(e));let t=i.sort((t,e)=>e.index-t.index).reverse();if(this.stacked){let e=new Set(t.map(t=>t.stack));e.size>1&&e.forEach(e=>{let i=[...t].reverse().find(t=>t.stack===e);i&&(i.label.show=!0)})}this._data=t,this._loading=!1}catch(e){if(console.error(e),(null==e?void 0:e.message)==="canceled")return;if(this._loading=!1,C(e)){if(e.message.includes("timeout")){this._latestError="noAttributeDataTimeout";return}else if((null==(t=e.response)?void 0:t.status)===413){this._latestError="datapointRequestTooLarge";return}}this._latestError="errorOccurred"}})}_loadAttributeData(t,e,i,r,o,a){return __awaiter(this,arguments,void 0,function*(t,e,i,r,o,a,s=!1,n,l,d){var h,u,c,p;let f=this._getDefaultDatasetOptions(null!=n?n:"",a,i,s);if(t.id&&e.name&&this.datapointQuery){let i=structuredClone(this.datapointQuery);i.fromTimestamp=r,i.toTimestamp=o-1,i.formula=a,i.gapFill=!0,i.interval=`${null!=(u=null==(h=this._intervalConfig)?void 0:h.steps)?u:"???"} ${null!=(p=null==(c=this._intervalConfig)?void 0:c.orFormat)?p:"???"}`,console.debug(`Requesting datapoints for '${e.name}' of ${t.id}, between ${x(r).format("lll")} and ${x(o-1).format("lll")}...`);let s=yield m.rest.api.AssetDatapointResource.getDatapoints(t.id,e.name,i,l);200===s.status&&(f.data=s.data.map(t=>({x:t.x,y:t.y})).map(t=>{var e,i;return[(null!=(e=t.x)?e:0)+.5*this._intervalConfig.millis,null==(i=t.y)?void 0:i.toFixed(this.decimals)]}))}return f})}_updateChartData(){var t,e,i,r,o,a,s;if(!this._chart)return void console.error("Could not update bar chart data; the bar chart is not initialized yet.");let n=null==(e=null==(t=this._data)?void 0:t[0])?void 0:e.data;if(n){let t=n[0][0];t!==this._startOfPeriod&&(this._startOfPeriod=t);let e=[...n].reverse()[0][0];e!==this._endOfPeriod&&(this._endOfPeriod=e)}let l=Math.max(1,(this._endOfPeriod-this._startOfPeriod)/this._intervalConfig.millis-1),d=(null==(i=this._chartElem)?void 0:i.clientWidth)?this._chartElem.clientWidth/50:Number.MAX_SAFE_INTEGER,m=Math.max(1,Math.min(l,Math.floor(1.5*d)));this._chart.setOption({xAxis:{show:m>1,splitNumber:m,minInterval:this._intervalConfig.millis,min:this._startOfPeriod,max:this._endOfPeriod,axisLabel:{interval:null==(r=this._intervalConfig)?void 0:r.millis,rotate:45*(m>d)}},dataZoom:{minValueSpan:(null!=(a=null==(o=this._intervalConfig)?void 0:o.millis)?a:0)*4},series:[...(null!=(s=this._data)?s:[]).map(t=>Object.assign({},t))]})}_toggleChartEventListeners(t){var e;t?(this._containerResizeObserver=new ResizeObserver(()=>this._applyChartResponsiveness()),this._containerResizeObserver.observe(this.shadowRoot.getElementById("container"))):(null==(e=this._containerResizeObserver)||e.disconnect(),this._containerResizeObserver=void 0)}_getDefaultChartOptions(){var t,e,i,r,o,a,s,n,d,m,h,u,c,p,f,v,y,g,_,b,O,w,C;let A=Math.max(1,(this._endOfPeriod-this._startOfPeriod)/this._intervalConfig.millis-1),E=(null==(t=this._chartElem)?void 0:t.clientWidth)?this._chartElem.clientWidth/50:Number.MAX_SAFE_INTEGER,$=Math.max(1,Math.min(A,Math.floor(1.5*E)));return{grid:{show:!0,backgroundColor:this._style.getPropertyValue("--internal-or-asset-tree-background-color"),borderColor:this._style.getPropertyValue("--internal-or-chart-text-color"),left:10,right:10,top:10,bottom:10,containLabel:!0},backgroundColor:this._style.getPropertyValue("--internal-or-asset-tree-background-color"),tooltip:{trigger:"axis",confine:!0,axisPointer:{type:"cross",label:{show:!0,formatter:t=>{var e,i,r,o,a;if("x"!==t.axisDimension)return Number(t.value).toFixed(this.decimals).toString();{let s=x(t.value),n=s.clone().subtract((null!=(i=null==(e=this._intervalConfig)?void 0:e.millis)?i:0)/2,"milliseconds"),d=s.clone().add((null!=(o=null==(r=this._intervalConfig)?void 0:r.millis)?o:0)/2,"milliseconds");switch(null==(a=this._intervalConfig)?void 0:a.orFormat){case"MINUTE":case"HOUR":return`${n.format("lll")} - ${d.format("lll")}`;case"DAY":return`${s.format("dddd, LL")}`;case"WEEK":return`${l.t("week")} ${n.format("w, LL")} - ${d.format("LL")}`;default:return`${n.format("LL")} - ${d.format("LL")}`}}}}}},xAxis:{type:"time",show:A>1,axisLine:{lineStyle:{color:this._style.getPropertyValue("--internal-or-chart-text-color")}},splitNumber:$,minInterval:this._intervalConfig.millis,min:this._startOfPeriod,max:this._endOfPeriod,boundaryGap:!1,splitArea:{show:!0,areaStyle:{color:["transparent","rgba(0, 0, 0, 0.05)"]}},axisLabel:{rotate:45*($>E),interval:null==(e=this._intervalConfig)?void 0:e.millis,fontSize:10,formatter:{year:"{yyyy}",month:"{MMMM} '{yy}",day:"{MMM} {d}th",hour:"{HH}:{mm}",minute:"{HH}:{mm}",second:"{HH}:{mm}:{ss}",millisecond:"{d}-{MMM} {HH}:{mm}",none:"{MMM}-{dd} {HH}:{mm}"}}},yAxis:[{type:"value",axisLine:{lineStyle:{color:this._style.getPropertyValue("--internal-or-chart-text-color")}},boundaryGap:["10%","10%"],scale:!0,min:null==(a=null==(o=null==(r=null==(i=this.chartOptions)?void 0:i.options)?void 0:r.scales)?void 0:o.y)?void 0:a.min,max:null==(m=null==(d=null==(n=null==(s=this.chartOptions)?void 0:s.options)?void 0:n.scales)?void 0:d.y)?void 0:m.max},{type:"value",show:(null!=(c=null==(u=null==(h=this.attributeConfig)?void 0:h.rightAxisAttributes)?void 0:u.length)?c:0)>0,axisLine:{lineStyle:{color:this._style.getPropertyValue("--internal-or-chart-text-color")}},boundaryGap:["10%","10%"],scale:!0,min:null==(y=null==(v=null==(f=null==(p=this.chartOptions)?void 0:p.options)?void 0:f.scales)?void 0:v.y1)?void 0:y.min,max:null==(O=null==(b=null==(_=null==(g=this.chartOptions)?void 0:g.options)?void 0:_.scales)?void 0:b.y1)?void 0:O.max}],dataZoom:[{type:"inside",minValueSpan:(null!=(C=null==(w=this._intervalConfig)?void 0:w.millis)?C:0)*4}],series:[]}}_getDefaultDatasetOptions(t,e,i,r=!1){let o=Object.entries(this.attributeConfig||{}).filter(([t,e])=>t.startsWith("method")&&(null==e?void 0:e.length)>0).length>1;return{name:t,type:"bar",data:[],stack:this.stacked?`${e}`:void 0,itemStyle:{color:i,opacity:r?.31:1},emphasis:{},label:{show:!this.stacked,align:"left",verticalAlign:"middle",position:"top",fontStyle:"italic",fontSize:10,rotate:90,distance:10,formatter:t=>{var i,r,a;if(o){let o=null==(a=null==(i=this._data)?void 0:i[null!=(r=t.seriesIndex)?r:0])?void 0:a.data;if((null==o?void 0:o.findIndex(t=>null!=t[1]))===t.dataIndex)return e}return""}}}}static getDefaultTimePrefixOptions(){return["this","last"]}static getDefaultTimeWindowOptions(){return new Map([["Hour",["hours",1]],["6Hours",["hours",6]],["24Hours",["hours",24]],["Day",["days",1]],["7Days",["days",7]],["Week",["weeks",1]],["30Days",["days",30]],["Month",["months",1]],["365Days",["days",365]],["Year",["years",1]]])}static getDefaultIntervalOptions(){return new Map([[BarChartInterval.AUTO,{displayName:"auto",steps:1,orFormat:"MINUTE",momentFormat:"minutes",millis:6e4}],[BarChartInterval.ONE_MINUTE,{displayName:"1Minute",steps:1,orFormat:"MINUTE",momentFormat:"minutes",millis:6e4}],[BarChartInterval.FIVE_MINUTES,{displayName:"5Minutes",steps:5,orFormat:"MINUTE",momentFormat:"minutes",millis:3e5}],[BarChartInterval.THIRTY_MINUTES,{displayName:"30Minutes",steps:30,orFormat:"MINUTE",momentFormat:"minutes",millis:18e5}],[BarChartInterval.ONE_HOUR,{displayName:"hour",steps:1,orFormat:"HOUR",momentFormat:"hours",millis:36e5}],[BarChartInterval.ONE_DAY,{displayName:"day",steps:1,orFormat:"DAY",momentFormat:"days",millis:864e5}],[BarChartInterval.ONE_WEEK,{displayName:"week",steps:1,orFormat:"WEEK",momentFormat:"weeks",millis:6048e5}],[BarChartInterval.ONE_MONTH,{displayName:"month",steps:1,orFormat:"MONTH",momentFormat:"months",millis:2592e6}],[BarChartInterval.ONE_YEAR,{displayName:"year",steps:1,orFormat:"YEAR",momentFormat:"years",millis:31536e6}]])}};OrAttributeBarChart.DEFAULT_COLORS=["#3869B1","#DA7E30","#3F9852","#CC2428","#6B4C9A","#922427","#958C3D","#535055"],__decorate([a({type:Object})],OrAttributeBarChart.prototype,"assets",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"assetAttributes",void 0),__decorate([a({type:String})],OrAttributeBarChart.prototype,"realm",void 0),__decorate([a({type:Array})],OrAttributeBarChart.prototype,"attributeColors",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"attributeConfig",void 0),__decorate([a({type:Array})],OrAttributeBarChart.prototype,"colors",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"datapointQuery",void 0),__decorate([a({type:Array})],OrAttributeBarChart.prototype,"timeframe",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"chartOptions",void 0),__decorate([a({type:Boolean})],OrAttributeBarChart.prototype,"showLegend",void 0),__decorate([a({type:Boolean})],OrAttributeBarChart.prototype,"denseLegend",void 0),__decorate([a({type:Boolean})],OrAttributeBarChart.prototype,"stacked",void 0),__decorate([a({type:Boolean})],OrAttributeBarChart.prototype,"timestampControls",void 0),__decorate([a({type:Number})],OrAttributeBarChart.prototype,"decimals",void 0),__decorate([a({type:Array})],OrAttributeBarChart.prototype,"timePrefixOptions",void 0),__decorate([a({type:String})],OrAttributeBarChart.prototype,"timePrefixKey",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"timeWindowOptions",void 0),__decorate([a({type:String})],OrAttributeBarChart.prototype,"timeWindowKey",void 0),__decorate([a({type:Object})],OrAttributeBarChart.prototype,"intervalOptions",void 0),__decorate([a({type:String})],OrAttributeBarChart.prototype,"interval",void 0),__decorate([s()],OrAttributeBarChart.prototype,"_isCustomWindow",void 0),__decorate([s()],OrAttributeBarChart.prototype,"_loading",void 0),__decorate([s()],OrAttributeBarChart.prototype,"_data",void 0),__decorate([n("#chart")],OrAttributeBarChart.prototype,"_chartElem",void 0),OrAttributeBarChart=OrAttributeBarChart_1=__decorate([o("or-attribute-barchart")],OrAttributeBarChart);export{OrAttributeBarChart};