@refinitiv-ui/efx-grid 6.0.130 → 6.0.131

Sign up to get free protection for your applications and to get access to all the features.
package/lib/grid/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  import {Grid} from "./lib/efx-grid.js";
2
2
  export {Grid}
3
- window.EFX_GRID = { version: "6.0.130" };
3
+ window.EFX_GRID = { version: "6.0.131" };
@@ -0,0 +1,39 @@
1
+
2
+
3
+ declare namespace LEDGuage {
4
+
5
+ type RangeValues = {
6
+ low?: number|null,
7
+ last?: number|null,
8
+ high?: number|null,
9
+ close?: number|null,
10
+ vwap?: number|null,
11
+ tick?: number|null
12
+ };
13
+
14
+ }
15
+
16
+ declare class LEDGuage {
17
+
18
+ constructor();
19
+
20
+ public static createElementWithText(text?: string|null): Element|null;
21
+
22
+ public setPriceGraph(priceGraph?: boolean|null): void;
23
+
24
+ public setRangeValue(rangeBarData: LEDGuage.RangeValues|null): void;
25
+
26
+ public isNoRangeValue(): boolean;
27
+
28
+ public isHighLowEqual(): boolean;
29
+
30
+ public isInvalidRangeValue(): boolean;
31
+
32
+ public getEqualRangeElement(): Element|null;
33
+
34
+ public getLEDGuageElement(): Element|null;
35
+
36
+ }
37
+
38
+ export default LEDGuage;
39
+ export { LEDGuage };
@@ -0,0 +1,261 @@
1
+
2
+
3
+ const TICK_COLOR_MAPPING = ["var(--color-scheme-neutral)", "var(--color-scheme-tickup)", "var(--color-scheme-tickdown)"]; // ["level", "up", "down"]
4
+
5
+ /** @typedef {Object} LEDGuage~RangeValues
6
+ * @description Object of range values.
7
+ * @property {number=} low Field used as minimum range
8
+ * @property {number=} last Field used as current absolute value (white bar)
9
+ * @property {number=} high Field used as maximum range
10
+ * @property {number=} close Field used as close price
11
+ * @property {number=} vwap Field used as volume weighted average price (VWAP)
12
+ * @property {number=} tick Field used as tick color
13
+ */
14
+
15
+ /**
16
+ * @constructor
17
+ */
18
+ var LEDGuage = function () {
19
+ this._elem = document.createElement("ef-led-gauge");
20
+ this._elem.neutralColor = true; // TODO: Color should set by user
21
+ };
22
+
23
+ /** @private
24
+ * @type {number=}
25
+ */
26
+ LEDGuage.prototype._low = null;
27
+ /** @private
28
+ * @type {number=}
29
+ */
30
+ LEDGuage.prototype._last = null;
31
+ /** @private
32
+ * @type {number=}
33
+ */
34
+ LEDGuage.prototype._high = null;
35
+ /** @private
36
+ * @type {number=}
37
+ */
38
+ LEDGuage.prototype._close = null;
39
+ /** @private
40
+ * @type {number=}
41
+ */
42
+ LEDGuage.prototype._vwap = null;
43
+ /** @private
44
+ * @type {number=}
45
+ */
46
+ LEDGuage.prototype._tick = null;
47
+ /** @private
48
+ * @type {boolean}
49
+ */
50
+ LEDGuage.prototype._priceGraph = false;
51
+
52
+ /** @private
53
+ * @param {LEDGuage~RangeValues} rBarOpt range
54
+ * @param {!Object} rangeBarValues
55
+ * @return {string} tooltip string value
56
+ */
57
+ LEDGuage.calculateTooltip = function (rBarOpt, rangeBarValues) {
58
+ var low = rangeBarValues.low;
59
+ var last = rangeBarValues.last;
60
+ var high = rangeBarValues.high;
61
+ var vwap = rangeBarValues.vwap;
62
+ var close = rangeBarValues.close;
63
+ var priceGraph = rBarOpt.priceGraph;
64
+
65
+ var textTooltip;
66
+ if (rBarOpt["field"]) { // WARNING: Field overwrite low last high tooltip
67
+ textTooltip = (last != null ? last : '--');
68
+ } else { // provide low,last,high case
69
+ var lowValue = low != null ? low : '--';
70
+ var lastValue = last != null ? last : '--';
71
+ var highValue = high != null ? high : '--';
72
+ if (priceGraph) {
73
+ var vwapValue = vwap != null ? vwap : '--';
74
+ var closeValue = close != null ? close : '--';
75
+ textTooltip = 'Low: ' + lowValue + " " +
76
+ 'Last: ' + lastValue + " " +
77
+ 'High: ' + highValue + " " +
78
+ 'VWAP: ' + vwapValue + " " +
79
+ 'Close: ' + closeValue + " ";
80
+ } else {
81
+ textTooltip = 'Low: ' + lowValue + " " +
82
+ 'Last: ' + lastValue + " " +
83
+ 'High: ' + highValue;
84
+ }
85
+ }
86
+ return textTooltip;
87
+ };
88
+
89
+ /** Used for convert the rangeBarOption and rowData into an object that has the properties of low, last, and high.
90
+ * @private
91
+ * @param {LEDGuage~RangeValues} rBarOpt
92
+ * @param {Object} rowData
93
+ * @return {LEDGuage~RangeValues}
94
+ */
95
+ LEDGuage.getRangeBarData = function (rBarOpt, rowData) {
96
+ var low, high, last, close, vwap, tick;
97
+ if (rBarOpt.field) {
98
+ // Doesn't defined range bar data, use field instead
99
+ low = rBarOpt.start;
100
+ last = rowData[rBarOpt.field];
101
+ high = rBarOpt.end;
102
+ } else {
103
+ // Defined range bar data
104
+ low = rowData[rBarOpt.low];
105
+ last = rowData[rBarOpt.last];
106
+ high = rowData[rBarOpt.high];
107
+ close = rowData[rBarOpt.close];
108
+ vwap = rowData[rBarOpt.vwap];
109
+ tick = rowData[rBarOpt.tick];
110
+ }
111
+ return {
112
+ low: low,
113
+ last: last,
114
+ high: high,
115
+ close: close,
116
+ vwap: vwap,
117
+ tick: tick
118
+ };
119
+ };
120
+
121
+ /** Used for tranfrom value from raw value to normalize value (Percent value between -100 to 100)
122
+ * @private
123
+ * @param {number} low
124
+ * @param {number} current
125
+ * @param {number} high
126
+ * @return {number}
127
+ */
128
+ LEDGuage.normalizeValue = function (low, current, high) {
129
+ return ((low - current) * 200) / (low - high) - 100;
130
+ };
131
+
132
+ /** Create element and set given text.
133
+ * @public
134
+ * @param {string=} text="" Set text to element
135
+ * @return {Element}
136
+ */
137
+ LEDGuage.createElementWithText = function (text) {
138
+ let span = document.createElement("span");
139
+ span.textContent = text ? text : "";
140
+ return span;
141
+ };
142
+
143
+ /** Set price graph flag to render price graph mode
144
+ * @public
145
+ * @param {boolean=} priceGraph=false
146
+ */
147
+ LEDGuage.prototype.setPriceGraph = function (priceGraph) {
148
+ this._priceGraph = priceGraph;
149
+ };
150
+
151
+ /** Set value to render LED-Guage
152
+ * @public
153
+ * @param {LEDGuage~RangeValues} rangeBarData
154
+ */
155
+ LEDGuage.prototype.setRangeValue = function (rangeBarData) {
156
+ this._low = rangeBarData.low;
157
+ this._last = rangeBarData.last;
158
+ this._high = rangeBarData.high;
159
+ this._close = rangeBarData.close;
160
+ this._vwap = rangeBarData.vwap;
161
+ this._tick = rangeBarData.tick;
162
+ };
163
+
164
+ /**
165
+ * @public
166
+ * @return {boolean}
167
+ */
168
+ LEDGuage.prototype.isNoRangeValue = function () {
169
+ return this._high == null && this._low == null && this._last == null;
170
+ };
171
+
172
+ /**
173
+ * @public
174
+ * @return {boolean}
175
+ */
176
+ LEDGuage.prototype.isHighLowEqual = function () {
177
+ return this._high === this._low && this._high === this._last;
178
+ };
179
+
180
+ /**
181
+ * @public
182
+ * @return {boolean}
183
+ */
184
+ LEDGuage.prototype.isInvalidRangeValue = function () {
185
+ return this._high == null || this._low == null || this._high < this._low;
186
+ };
187
+
188
+ /**
189
+ * @public
190
+ * @return {Element} LEDGuage Element
191
+ */
192
+ LEDGuage.prototype.getEqualRangeElement = function () {
193
+ this._elem.range = [-100, 100];
194
+ this._elem.topValue = 0;
195
+ return this._elem;
196
+ };
197
+
198
+ /**
199
+ * @public
200
+ * @return {Element} LEDGuage Element
201
+ */
202
+ LEDGuage.prototype.getLEDGuageElement = function () {
203
+ let close = this._close;
204
+ let vwap = this._vwap;
205
+ let low = this._low;
206
+ let last = this._last;
207
+ let high = this._high;
208
+ let lastNormalize = LEDGuage.normalizeValue(low, last, high);
209
+ if (this._priceGraph) {
210
+ let vwapNormalize = LEDGuage.normalizeValue(low, vwap, high);
211
+ let rangeColor;
212
+ if (close > last) {
213
+ rangeColor = "var(--color-scheme-tickdown)";
214
+ } else {
215
+ rangeColor = "var(--color-scheme-tickup)";
216
+ }
217
+
218
+ let leftSegmentValue = LEDGuage.normalizeValue(low, close, high);
219
+ let rangeValue;
220
+ if (lastNormalize < leftSegmentValue) {
221
+ rangeValue = [lastNormalize, leftSegmentValue];
222
+ } else {
223
+ rangeValue = [leftSegmentValue, lastNormalize];
224
+ }
225
+ this._elem.range = rangeValue;
226
+ this._elem.topValue = lastNormalize;
227
+ this._elem.bottomValue = vwapNormalize;
228
+ this._elem.style.setProperty("--range-color", rangeColor);
229
+ this._elem.style.setProperty("--bottom-selected-color", "var(--neutral-color)");
230
+ this._elem.style.setProperty("--top-selected-color", TICK_COLOR_MAPPING[this._tick]);
231
+ this._elem.style.setProperty("--clash-color", "var(--color-scheme-secondary)");
232
+ } else {
233
+ // applied range when the last value out of range, by set new low/high with last value
234
+ if (last < low) {
235
+ let lowNormalize = LEDGuage.normalizeValue(last, low, high);
236
+ this._elem.range = [lastNormalize, lowNormalize];
237
+ } else if (last > high) {
238
+ let highNormalize = LEDGuage.normalizeValue(low, high, last);
239
+ this._elem.range = [highNormalize, lastNormalize];
240
+ }
241
+
242
+ if (low === high) { // low equal high case (avoid normalize to infinity)
243
+ this._elem.range = [-100, 100];
244
+ lastNormalize = last < low ? -100 : 100; // topValue will be left or right
245
+ }
246
+
247
+ if (last == null) { // only last is empty (low and high should have value)
248
+ this._elem.range = [];
249
+ lastNormalize = null;
250
+ }
251
+
252
+ this._elem.topValue = lastNormalize;
253
+ }
254
+
255
+ return this._elem;
256
+ };
257
+
258
+
259
+
260
+ export default LEDGuage;
261
+ export { LEDGuage };
@@ -1,7 +1,8 @@
1
- import {Ext} from '../../tr-grid-util/es6/Ext.js';
2
- import {GridPlugin} from '../../tr-grid-util/es6/GridPlugin.js';
3
- import {ElfUtil} from '../../tr-grid-util/es6/ElfUtil.js';
1
+ import { Ext } from '../../tr-grid-util/es6/Ext.js';
2
+ import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
3
+ import { ElfUtil } from '../../tr-grid-util/es6/ElfUtil.js';
4
4
  import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
5
+ import { LEDGuage } from "./LEDGuage.js";
5
6
 
6
7
  declare namespace RangeBarPlugin {
7
8