@refinitiv-ui/efx-grid 6.0.35 → 6.0.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,10 @@ declare namespace RangeBarPlugin {
15
15
  end?: number|null,
16
16
  low?: string|null,
17
17
  high?: string|null,
18
- last?: string|null
18
+ last?: string|null,
19
+ vwap?: string|null,
20
+ close?: string|null,
21
+ tick?: string|null
19
22
  };
20
23
 
21
24
  type Options = {
@@ -17,6 +17,9 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
17
17
  * @property {string=} low="" Field used as minimum range
18
18
  * @property {string=} high="" Field used as maximum range
19
19
  * @property {string=} last="" Field used as current absolute value (white bar)
20
+ * @property {string=} vwap="" Field used as volume weighted average price (VWAP)
21
+ * @property {string=} close="" Field used as close price
22
+ * @property {string=} tick="" Field used as tick color
20
23
  */
21
24
 
22
25
  /** @typedef {Object} RangeBarPlugin~Options
@@ -26,15 +29,15 @@ import { injectCss, prettifyCss } from "../../tr-grid-util/es6/Util.js";
26
29
  // TODO: promote "valueLabel" option, that provide the user can show valueLabel in ef-led-gauge (default is false)
27
30
  // @property {boolean=} valueLabel=false If disabled, it will be show text label in top of ef-led-gaguge
28
31
 
29
- /** Used for tranfrom value from raw value to normalize value
32
+ /** Used for tranfrom value from raw value to normalize value (Percent value between -100 to 100)
30
33
  * @private
31
34
  * @param {number} low
32
- * @param {number} last
35
+ * @param {number} current
33
36
  * @param {number} high
34
37
  * @return {number}
35
38
  */
36
- var _normalizeValue = function _normalizeValue(low, last, high) {
37
- return (low - last) * 200 / (low - high) - 100;
39
+ var _normalizeValue = function _normalizeValue(low, current, high) {
40
+ return (low - current) * 200 / (low - high) - 100;
38
41
  };
39
42
 
40
43
  /** Used for convert the rangeBarOption and rowData into an object that has the properties of low, last, and high.
@@ -43,26 +46,37 @@ var _normalizeValue = function _normalizeValue(low, last, high) {
43
46
  * @param {Object} rowData
44
47
  * @return {Object}
45
48
  */
46
- var _getLowLastHighValue = function _getLowLastHighValue(rBarOpt, rowData) {
47
- var low, high, last;
49
+ var _getRangeBarData = function _getRangeBarData(rBarOpt, rowData) {
50
+ var low, high, last, close, vwap, tick;
48
51
  if (rBarOpt.field) {
49
- // Doesn't defined low,last,high
52
+ // Doesn't defined range bar data, use field instead
50
53
  low = rBarOpt.start;
51
54
  last = rowData[rBarOpt.field];
52
55
  high = rBarOpt.end;
53
56
  } else {
54
- // Defined low,last,high case
57
+ // Defined range bar data
55
58
  low = rowData[rBarOpt.low];
56
59
  last = rowData[rBarOpt.last];
57
60
  high = rowData[rBarOpt.high];
61
+ close = rowData[rBarOpt.close];
62
+ vwap = rowData[rBarOpt.vwap];
63
+ tick = rowData[rBarOpt.tick];
58
64
  }
59
65
  return {
60
66
  low: low,
61
67
  last: last,
62
- high: high
68
+ high: high,
69
+ close: close,
70
+ vwap: vwap,
71
+ tick: tick
63
72
  };
64
73
  };
65
74
 
75
+ /** @type {Array<string>}
76
+ * @constant
77
+ */
78
+ var TICK_COLOR_MAPPING = ["var(--color-scheme-neutral)", "var(--color-scheme-tickup)", "var(--color-scheme-tickdown)"]; // ["level", "up", "down"]
79
+
66
80
  /** @constructor
67
81
  * @extends {GridPlugin}
68
82
  */
@@ -253,6 +267,15 @@ RangeBarPlugin.prototype.getColumnConfigObject = function (colIndex, out_obj) {
253
267
  if (opt.high != null) {
254
268
  rangeBar.high = opt.high;
255
269
  }
270
+ if (opt.close != null) {
271
+ rangeBar.close = opt.close;
272
+ }
273
+ if (opt.vwap != null) {
274
+ rangeBar.vwap = opt.vwap;
275
+ }
276
+ if (opt.tick != null) {
277
+ rangeBar.tick = opt.tick;
278
+ }
256
279
  return out_obj;
257
280
  };
258
281
 
@@ -285,7 +308,7 @@ RangeBarPlugin.prototype.getValue = function (colRef, rowRef) {
285
308
  if (!rowData) {
286
309
  return null;
287
310
  }
288
- return _getLowLastHighValue(rBarOpt, rowData);
311
+ return _getRangeBarData(rBarOpt, rowData);
289
312
  };
290
313
 
291
314
  /** @public
@@ -310,16 +333,16 @@ RangeBarPlugin.prototype.getTooltipText = function (colRef, rowRef) {
310
333
  if (typeof rowRef === "string") {
311
334
  rowRef = dv.getRowIndex(rowRef);
312
335
  }
313
- if (rowRef == "" || rowRef < 0) {
336
+ if (rowRef < 0) {
314
337
  return "";
315
338
  }
316
339
  var rowData = this._getRow(dv, rowRef);
317
340
  if (!rowData) {
318
341
  return "";
319
342
  }
320
- var lowLastHigh = _getLowLastHighValue(rBarOpt, rowData);
343
+ var rangeBarValues = _getRangeBarData(rBarOpt, rowData);
321
344
  if (this._tooltip) {
322
- var textTooltip = this._calculateTooltip(rBarOpt, lowLastHigh);
345
+ var textTooltip = this._calculateTooltip(rBarOpt, rangeBarValues);
323
346
  return textTooltip;
324
347
  }
325
348
  return "";
@@ -327,13 +350,16 @@ RangeBarPlugin.prototype.getTooltipText = function (colRef, rowRef) {
327
350
 
328
351
  /** @private
329
352
  * @param {RangeBarPlugin~RangeDefinition} rBarOpt range
330
- * @param {!Object} lowLastHigh
353
+ * @param {!Object} rangeBarValues
331
354
  * @return {string} tooltip string value
332
355
  */
333
- RangeBarPlugin.prototype._calculateTooltip = function (rBarOpt, lowLastHigh) {
334
- var low = lowLastHigh.low;
335
- var last = lowLastHigh.last;
336
- var high = lowLastHigh.high;
356
+ RangeBarPlugin.prototype._calculateTooltip = function (rBarOpt, rangeBarValues) {
357
+ var low = rangeBarValues.low;
358
+ var last = rangeBarValues.last;
359
+ var high = rangeBarValues.high;
360
+ var vwap = rangeBarValues.vwap;
361
+ var close = rangeBarValues.close;
362
+ var priceGraph = rBarOpt.priceGraph;
337
363
  var textTooltip;
338
364
  if (rBarOpt["field"]) {
339
365
  // doesn't provide low,last,high case
@@ -343,7 +369,13 @@ RangeBarPlugin.prototype._calculateTooltip = function (rBarOpt, lowLastHigh) {
343
369
  var lowValue = low != null ? low : '--';
344
370
  var lastValue = last != null ? last : '--';
345
371
  var highValue = high != null ? high : '--';
346
- textTooltip = 'Low: ' + lowValue + " " + 'Last: ' + lastValue + " " + 'High: ' + highValue;
372
+ if (priceGraph) {
373
+ var vwapValue = vwap != null ? vwap : '--';
374
+ var closeValue = close != null ? close : '--';
375
+ textTooltip = 'Low: ' + lowValue + " " + 'Last: ' + lastValue + " " + 'High: ' + highValue + " " + 'VWAP: ' + vwapValue + " " + 'Close: ' + closeValue + " ";
376
+ } else {
377
+ textTooltip = 'Low: ' + lowValue + " " + 'Last: ' + lastValue + " " + 'High: ' + highValue;
378
+ }
347
379
  }
348
380
  return textTooltip;
349
381
  };
@@ -375,6 +407,10 @@ RangeBarPlugin.prototype._calculateTooltip = function (rBarOpt, lowLastHigh) {
375
407
  RangeBarPlugin.prototype._setColumnRangeBar = function (colIndex, columnOptions) {
376
408
  var rDef = columnOptions["rangeBar"];
377
409
  if (rDef) {
410
+ if (rDef["vwap"] || rDef["close"] || rDef["tick"]) {
411
+ rDef["priceGraph"] = true; // activate price graph mode
412
+ }
413
+
378
414
  var colData = this._newColumnData(colIndex);
379
415
  if (rDef === true || typeof rDef["field"] === "string") {
380
416
  // The start and end properties were overwritten by the extension, so the value will be returned from the get configuration even if the user does not set it (minor issue).
@@ -423,16 +459,17 @@ RangeBarPlugin.prototype._onPostSectionBinding = function (e) {
423
459
  if (!rBarOpt) {
424
460
  continue;
425
461
  }
462
+ var priceGraph = rBarOpt["priceGraph"];
426
463
  for (var r = fromR; r < toR; ++r) {
427
464
  var cell = section.getCell(c, r, false);
428
465
  if (!cell) {
429
466
  continue;
430
467
  }
431
468
  var rowData = this._getRowData(dataRows[r]);
432
- var lowLastHigh = _getLowLastHighValue(rBarOpt, rowData);
433
- var low = lowLastHigh.low;
434
- var last = lowLastHigh.last;
435
- var high = lowLastHigh.high;
469
+ var rangeBarData = _getRangeBarData(rBarOpt, rowData);
470
+ var low = rangeBarData.low;
471
+ var last = rangeBarData.last;
472
+ var high = rangeBarData.high;
436
473
  var content = cell.getContent();
437
474
  var rangeBar = content ? content._rangeBar : null;
438
475
  if (!rangeBar) {
@@ -442,7 +479,7 @@ RangeBarPlugin.prototype._onPostSectionBinding = function (e) {
442
479
  content = rangeBar;
443
480
  }
444
481
  if (this._tooltip) {
445
- var textTooltip = this._calculateTooltip(rBarOpt, lowLastHigh);
482
+ var textTooltip = this._calculateTooltip(rBarOpt, rangeBarData);
446
483
  cell.setTooltip(textTooltip); // WARNING: this may be confuse with auto-tooltip extension
447
484
  }
448
485
 
@@ -464,22 +501,45 @@ RangeBarPlugin.prototype._onPostSectionBinding = function (e) {
464
501
 
465
502
  // Clear the current range for apply a new one.
466
503
  rangeBar.range.length = 0;
504
+ if (priceGraph) {
505
+ var close = rangeBarData.close;
506
+ var vwap = rangeBarData.vwap;
507
+ var vwapNormalize = _normalizeValue(low, vwap, high);
508
+ var rangeColor;
509
+ if (close > last) {
510
+ rangeColor = "var(--color-scheme-tickdown)";
511
+ } else {
512
+ rangeColor = "var(--color-scheme-tickup)";
513
+ }
514
+ var leftSegmentValue = _normalizeValue(low, close, high);
515
+ var rangeValue;
516
+ if (lastNormalize < leftSegmentValue) {
517
+ rangeValue = [lastNormalize, leftSegmentValue];
518
+ } else {
519
+ rangeValue = [leftSegmentValue, lastNormalize];
520
+ }
521
+ rangeBar.range = rangeValue;
522
+ rangeBar.topValue = lastNormalize;
523
+ rangeBar.bottomValue = vwapNormalize;
524
+ rangeBar.style.setProperty("--range-color", rangeColor);
525
+ rangeBar.style.setProperty("--bottom-selected-color", "var(--neutral-color)");
526
+ rangeBar.style.setProperty("--top-selected-color", TICK_COLOR_MAPPING[rangeBarData.tick]);
527
+ rangeBar.style.setProperty("--clash-color", "var(--color-scheme-secondary)");
528
+ } else {
529
+ // applied range when the last value out of range, by set new low/high with last value
530
+ if (last < low) {
531
+ var lowNormalize = _normalizeValue(last, low, high);
532
+ rangeBar.range = [lastNormalize, lowNormalize];
533
+ } else if (last > high) {
534
+ var highNormalize = _normalizeValue(low, high, last);
535
+ rangeBar.range = [highNormalize, lastNormalize];
536
+ }
537
+ // else {} // It is not necessary to apply a range in the case of equal low and high values
467
538
 
468
- // applied range when the last value out of range, by set new low/high with last value
469
- if (last < low) {
470
- lastNormalize = _normalizeValue(last, last, high);
471
- var lowNormalize = _normalizeValue(last, low, high);
472
- rangeBar.range = [lastNormalize, lowNormalize];
473
- } else if (last > high) {
474
- lastNormalize = _normalizeValue(low, last, last);
475
- var highNormalize = _normalizeValue(low, high, last);
476
- rangeBar.range = [highNormalize, lastNormalize];
477
- }
478
- // else {} // It is not necessary to apply a range in the case of equal low or high values
479
-
480
- rangeBar.topValue = lastNormalize;
481
- if (this.valueLabel) {
482
- rangeBar.topLabel = last;
539
+ rangeBar.topValue = lastNormalize;
540
+ if (this.valueLabel) {
541
+ rangeBar.topLabel = last;
542
+ }
483
543
  }
484
544
  cell.setContent(content);
485
545
  }
@@ -18,6 +18,8 @@ declare class GroupDefinitions {
18
18
 
19
19
  public getGroups(): (any)[];
20
20
 
21
+ public getGroupIds(): (string)[];
22
+
21
23
  public getGroupMap(): { [key: string]: any };
22
24
 
23
25
  public cloneGroupMap(): { [key: string]: any };
@@ -36,6 +38,8 @@ declare class GroupDefinitions {
36
38
 
37
39
  public getParentId(childId: string, groupLevel?: number|null): string;
38
40
 
41
+ public removeAllGroups(): boolean;
42
+
39
43
  public setGroups(groupDefs?: (any)[]|null): void;
40
44
 
41
45
  public addGroup(groupDef: any): string;
@@ -46,7 +50,7 @@ declare class GroupDefinitions {
46
50
 
47
51
  public hasGroupChild(parentId: string, childId: string): boolean;
48
52
 
49
- public addGroupChild(parentId: string, childId: string): boolean;
53
+ public addGroupChild(parentId: string, childId: string, position?: number|null): boolean;
50
54
 
51
55
  public removeGroupChild(parentId: string, childId?: string|null): boolean;
52
56
 
@@ -56,6 +60,8 @@ declare class GroupDefinitions {
56
60
 
57
61
  public setGroupChildren(groupId: string, newChildList: (string)[]|null): boolean;
58
62
 
63
+ public getGroupName(groupId: string): string;
64
+
59
65
  public setGroupName(groupId: string, groupName: string): boolean;
60
66
 
61
67
  }
@@ -187,6 +187,13 @@ GroupDefinitions.prototype.getGroups = function () {
187
187
  }
188
188
  return groupDefs;
189
189
  };
190
+ /** Get array of all existing group ids
191
+ * @public
192
+ * @return {!Array.<string>}
193
+ */
194
+ GroupDefinitions.prototype.getGroupIds = function () {
195
+ return Object.keys(this._groupMap);
196
+ };
190
197
  /** @public
191
198
  * @return {!Object.<string, Object>}
192
199
  */
@@ -293,7 +300,18 @@ GroupDefinitions.prototype.getParentId = function (childId, groupLevel) {
293
300
  return parentId || "";
294
301
  };
295
302
 
296
-
303
+ /** Remove all existing group definitions
304
+ * @public
305
+ * @return {boolean}
306
+ */
307
+ GroupDefinitions.prototype.removeAllGroups = function () {
308
+ for(var groupId in this._groupMap) { // eslint-disable-line
309
+ this._groupMap = {};
310
+ this._childToParent = {};
311
+ return true;
312
+ }
313
+ return false;
314
+ };
297
315
  /** Remove all existing group definitions and replace them with the given definitions.
298
316
  * @public
299
317
  * @param {Array.<Object>=} groupDefs Use null or empty array to remove all existing groups
@@ -438,9 +456,10 @@ GroupDefinitions.prototype.hasGroupChild = function (parentId, childId) {
438
456
  /** @public
439
457
  * @param {string} parentId Group id
440
458
  * @param {string} childId
459
+ * @param {number=} position
441
460
  * @return {boolean}
442
461
  */
443
- GroupDefinitions.prototype.addGroupChild = function (parentId, childId) {
462
+ GroupDefinitions.prototype.addGroupChild = function (parentId, childId, position) {
444
463
  var groupDef = this._groupMap[parentId];
445
464
 
446
465
  if(childId && groupDef) {
@@ -453,7 +472,11 @@ GroupDefinitions.prototype.addGroupChild = function (parentId, childId) {
453
472
  if(childDef) {
454
473
  childDef.parentId = parentId;
455
474
  }
456
- chdr.push(childId);
475
+ if(position != null && position >= 0) {
476
+ chdr.splice(position, 0, childId);
477
+ } else {
478
+ chdr.push(childId);
479
+ }
457
480
  return true;
458
481
  }
459
482
  }
@@ -562,6 +585,18 @@ GroupDefinitions.prototype.setGroupChildren = function (groupId, newChildList) {
562
585
  }
563
586
  return false;
564
587
  };
588
+
589
+ /** @public
590
+ * @param {string} groupId
591
+ * @return {string}
592
+ */
593
+ GroupDefinitions.prototype.getGroupName = function (groupId) {
594
+ var groupDef = this._groupMap[groupId];
595
+ if(groupDef) {
596
+ return groupDef.name || "";
597
+ }
598
+ return "";
599
+ };
565
600
  /** @public
566
601
  * @param {string} groupId
567
602
  * @param {string} groupName
@@ -578,5 +613,6 @@ GroupDefinitions.prototype.setGroupName = function (groupId, groupName) {
578
613
 
579
614
  return false;
580
615
  };
616
+
581
617
  export default GroupDefinitions;
582
618
  export { GroupDefinitions };
@@ -1,5 +1,6 @@
1
1
  import Ext from "../../../../tr-grid-util/es6/Ext.js";
2
2
  import GroupDefinitions from "../../../../tr-grid-util/es6/GroupDefinitions.js"; // eslint-disable-line
3
+ import { isEmptyObject } from "../../../../tr-grid-util/es6/Util.js";
3
4
  import ElementWrapper from "./components/ElementWrapper.js";
4
5
  import ILayoutGrid from "./ILayoutGrid.js"; // eslint-disable-line
5
6
  import LayoutGrid from "./LayoutGrid.js";
@@ -32,6 +33,13 @@ declare namespace Core {
32
33
  dataSource: DataView|null
33
34
  };
34
35
 
36
+ type BatchInfo = {
37
+ reset?: string|null,
38
+ insertion?: string|null,
39
+ removal?: string|null,
40
+ moving?: string|null
41
+ };
42
+
35
43
  type CellReference = Core.MouseInfo|ElementWrapper|Element|null;
36
44
 
37
45
  type ColumnOptions = {
@@ -395,6 +403,10 @@ declare class Core extends ElementWrapper {
395
403
 
396
404
  public getColumnGroupChildIds(groupId: string): (string)[]|null;
397
405
 
406
+ public startBatch(batchType: string): boolean;
407
+
408
+ public stopBatch(batchType: string): boolean;
409
+
398
410
  public getColumnId(colIndex: number): string;
399
411
 
400
412
  public getColumnIds(): (string)[];
package/lib/versions.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "tr-grid-util": "1.3.101",
2
+ "tr-grid-util": "1.3.103",
3
3
  "@grid/column-dragging": "1.0.13",
4
4
  "@grid/row-segmenting": "1.0.23",
5
5
  "@grid/statistics-row": "1.0.14",
@@ -12,7 +12,7 @@
12
12
  "tr-grid-column-grouping": "1.0.47",
13
13
  "tr-grid-column-resizing": "1.0.28",
14
14
  "tr-grid-column-selection": "1.0.28",
15
- "tr-grid-column-stack": "1.0.57",
15
+ "tr-grid-column-stack": "1.0.58",
16
16
  "tr-grid-conditional-coloring": "1.0.61",
17
17
  "tr-grid-content-wrap": "1.0.20",
18
18
  "tr-grid-contextmenu": "1.0.38",
@@ -22,7 +22,7 @@
22
22
  "tr-grid-pagination": "1.0.24",
23
23
  "tr-grid-percent-bar": "1.0.22",
24
24
  "tr-grid-printer": "1.0.16",
25
- "tr-grid-range-bar": "2.0.3",
25
+ "tr-grid-range-bar": "2.0.4",
26
26
  "tr-grid-row-dragging": "1.0.27",
27
27
  "tr-grid-row-filtering": "1.0.55",
28
28
  "tr-grid-row-grouping": "1.0.80",
package/package.json CHANGED
@@ -66,5 +66,5 @@
66
66
  "publishConfig": {
67
67
  "access": "public"
68
68
  },
69
- "version": "6.0.35"
69
+ "version": "6.0.36"
70
70
  }