@refinitiv-ui/efx-grid 6.1.17 → 6.1.19

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/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.1.17" };
3
+ window.EFX_GRID = { version: "6.1.19" };
@@ -11,8 +11,10 @@ declare namespace HeatMapPlugin {
11
11
  };
12
12
 
13
13
  type HeatMap = {
14
+ mode?: string|null,
14
15
  midPoint?: number|null,
15
- mode?: string|null
16
+ min?: number|null,
17
+ max?: number|null
16
18
  };
17
19
 
18
20
  }
@@ -35,11 +37,13 @@ declare class HeatMapPlugin extends GridPlugin {
35
37
 
36
38
  public setColumnHeatMap(colIndex: number, columnDef: any, opt_grid?: any): void;
37
39
 
40
+ public _getColumnHeatMapOptions(hm: any, options?: any): boolean;
41
+
38
42
  public getColumnHeatMapOptions(colIndex: number, options?: any): any;
39
43
 
40
44
  }
41
45
 
42
- declare function cond(colIndex: number, options?: any): any;
46
+ declare function hmMode(hm: any, options?: any): boolean;
43
47
 
44
48
  export default HeatMapPlugin;
45
49
  export { HeatMapPlugin, HeatMapPlugin as HeatMap, HeatMapPlugin as HeatMapExtension };
@@ -11,8 +11,10 @@ import {ElfUtil} from '../../tr-grid-util/es6/ElfUtil.js';
11
11
 
12
12
  /** @typedef {Object} HeatMapPlugin~HeatMap
13
13
  * @description Available options describing `heatMap` object
14
- * @property {number=} midPoint=0 Middle point between values representing up and down colors
15
14
  * @property {string=} mode="cell" In cell mode, heat map color will be applied to the entire cell
15
+ * @property {number=} midPoint=0 Middle point between values representing up and down colors
16
+ * @property {number=} min Minimum value in the data range; values at or below this will use the lowest intensity color
17
+ * @property {number=} max Maximum value in the data range; values at or above this will use the highest intensity color
16
18
  */
17
19
 
18
20
  /** @constructor
@@ -145,26 +147,15 @@ HeatMapPlugin.prototype.getConfigObject = function (out_obj) {
145
147
  }
146
148
 
147
149
 
148
- let opt = this.getColumnHeatMap(i);
149
-
150
- if (!opt) { // We are only interested in the columns that have heat map informations
151
- continue;
152
- }
150
+ let hm = this.getColumnHeatMap(i);
153
151
 
154
- // default value of midPoint and mode
155
- if(opt.midPoint === 0 && opt.mode === "cell") {
156
- col.heatMap = true;
152
+ if (!hm) { // We are only interested in the columns that have heat map informations
157
153
  continue;
158
154
  }
159
155
 
160
- let heatMap = col.heatMap = {};
161
-
162
- if (opt.midPoint != null) {
163
- heatMap.midPoint = opt.midPoint;
164
- }
165
-
166
- if (opt.mode != null) {
167
- heatMap.mode = opt.mode;
156
+ let heatMap = col["heatMap"] = {};
157
+ if(this._getColumnHeatMapOptions(hm, heatMap)) {
158
+ col["heatMap"] = true; // All settings are at their default value
168
159
  }
169
160
  }
170
161
 
@@ -183,7 +174,23 @@ HeatMapPlugin.prototype.getColumnHeatMap = function (colIndex, grid) {
183
174
  }
184
175
  return null;
185
176
  };
186
-
177
+ /** @private
178
+ * @param {number|string} val
179
+ * @param {*} defaultVal
180
+ * @returns {*}
181
+ */
182
+ HeatMapPlugin._toNumber = function (val, defaultVal) {
183
+ if(val != null) {
184
+ if(typeof val != "number") {
185
+ val = +val;
186
+ if(val !== val) { // NaN checking
187
+ return defaultVal;
188
+ }
189
+ }
190
+ return val;
191
+ }
192
+ return defaultVal;
193
+ };
187
194
  /** @public
188
195
  * @param {number} colIndex
189
196
  * @param {Object} columnDef
@@ -192,42 +199,43 @@ HeatMapPlugin.prototype.getColumnHeatMap = function (colIndex, grid) {
192
199
  * plugin.setColumnHeatMap(1, {
193
200
  * "field": "CF_LAST",
194
201
  * "heatMap": {
195
- * "midPoint": 0, // optional number
196
202
  * "mode": "cell" // optional string (cell|text)
203
+ * "midPoint": 0, // optional number
204
+ * "min": -100, // optional number
205
+ * "max": 100 // optional number
197
206
  * }
198
207
  * });
199
208
  */
200
209
  HeatMapPlugin.prototype.setColumnHeatMap = function (colIndex, columnDef, opt_grid) {
201
- let hmMode = "";
202
- let midPoint = 0;
210
+ const hmOptions = {};
203
211
  let field = columnDef ? /** @type{string} */(columnDef["field"]) : "";
204
- let hmOptions = field ? columnDef["heatMap"] || columnDef["heatmap"] : null;
205
- if(hmOptions) {
206
- let userMode = hmOptions["mode"] || hmOptions["type"];
207
- hmMode = (typeof userMode == "string") ? userMode : "cell";
208
-
209
- let userMidPoint = /** @type{number} */(hmOptions["midPoint"]);
210
- if(typeof userMidPoint != "number") {
211
- userMidPoint = +userMidPoint;
212
+ if(field) {
213
+ let userHeatMap = columnDef["heatMap"] || columnDef["heatmap"];
214
+ if(userHeatMap) {
215
+ let userMode = userHeatMap["mode"] || userHeatMap["type"];
216
+ hmOptions["mode"] = (typeof userMode == "string") ? userMode : "cell";
217
+
218
+ hmOptions["midPoint"] = HeatMapPlugin._toNumber(userHeatMap["midPoint"], 0);
219
+ hmOptions["min"] = HeatMapPlugin._toNumber(userHeatMap["min"], null);
220
+ hmOptions["max"] = HeatMapPlugin._toNumber(userHeatMap["max"], null);
212
221
  }
213
- midPoint = (userMidPoint) ? userMidPoint : 0;
214
222
  }
223
+
215
224
  if(opt_grid) {
216
- this._setColumnHeatMap(opt_grid, colIndex, hmMode, midPoint, field);
225
+ this._setColumnHeatMap(opt_grid, colIndex, field, hmOptions);
217
226
  } else {
218
227
  for(let i = this._hosts.length; --i >= 0;) {
219
- this._setColumnHeatMap(this._hosts[i], colIndex, hmMode, midPoint, field);
228
+ this._setColumnHeatMap(this._hosts[i], colIndex, field, hmOptions);
220
229
  }
221
230
  }
222
231
  };
223
232
  /** @private
224
233
  * @param {Object} grid core grid object
225
234
  * @param {number} colIndex
226
- * @param {string} hmMode
227
- * @param {number} midPoint
228
235
  * @param {string} field
236
+ * @param {!Object} hmOptions
229
237
  */
230
- HeatMapPlugin.prototype._setColumnHeatMap = function (grid, colIndex, hmMode, midPoint, field) {
238
+ HeatMapPlugin.prototype._setColumnHeatMap = function (grid, colIndex, field, hmOptions) {
231
239
  let dv = grid.getDataSource();
232
240
  if(!dv) {
233
241
  return;
@@ -236,6 +244,7 @@ HeatMapPlugin.prototype._setColumnHeatMap = function (grid, colIndex, hmMode, mi
236
244
  let colData = this._newColumnData(colIndex);
237
245
  let painter = /** @type{CellPainter} */(colData["painter"]);
238
246
 
247
+ const hmMode = hmOptions["mode"]; // No mode means no heat map for the column
239
248
  let cond, sect, rowCount, r, cell;
240
249
  if(hmMode && field) { // Update or create new painter for heatMap
241
250
  if(painter) {
@@ -258,10 +267,10 @@ HeatMapPlugin.prototype._setColumnHeatMap = function (grid, colIndex, hmMode, mi
258
267
  painter = colData["painter"] = new CellPainter();
259
268
  }
260
269
 
261
- painter["midPoint"] = midPoint; // For saving
262
- painter["mode"] = hmMode;
270
+ // Serialize user settings
271
+ this._getColumnHeatMapOptions(hmOptions, painter);
263
272
 
264
- cond = painter.addHeatmapWithTheme(field, midPoint, (hmMode === "text"));
273
+ cond = painter.addHeatmapWithTheme(field, painter["midPoint"] || 0, (hmMode === "text"));
265
274
  cond.refId = "_hm" + HeatMapPlugin._runningId++;
266
275
 
267
276
  let colStats = dv.enableColumnStats(field, true, cond.refId);
@@ -272,44 +281,63 @@ HeatMapPlugin.prototype._setColumnHeatMap = function (grid, colIndex, hmMode, mi
272
281
 
273
282
  grid.enableColumnClass(colIndex, "heat-map", true);
274
283
  grid["requestRowRefresh"]();
275
- } else {
276
- if(painter) {
277
- if(this._clearPainter(colData, grid)) {
278
- // Clear existing heatMap styles
279
- grid.enableColumnClass(colIndex, "heat-map", false);
280
- sect = grid.getSection("content");
281
- rowCount = sect.getRowCount();
282
- for(r = 0; r < rowCount; ++r) {
283
- cell = sect.getCell(colIndex, r, false);
284
- if(cell) {
285
- cell.setStyle("color", "");
286
- cell.setStyle("backgroundColor", "");
287
- }
284
+ } else if(painter) {
285
+ if(this._clearPainter(colData, grid)) {
286
+ // Clear existing heatMap styles
287
+ grid.enableColumnClass(colIndex, "heat-map", false);
288
+ sect = grid.getSection("content");
289
+ rowCount = sect.getRowCount();
290
+ for(r = 0; r < rowCount; ++r) {
291
+ cell = sect.getCell(colIndex, r, false);
292
+ if(cell) {
293
+ cell.setStyle("color", "");
294
+ cell.setStyle("backgroundColor", "");
288
295
  }
289
296
  }
290
297
  }
291
298
  }
292
299
  };
293
300
  /** @public
301
+ * @param {!Object} hm HeatMap configuration object
302
+ * @param {Object=} options
303
+ * @return {boolean} Returns true if all settings are at their default value
304
+ */
305
+ HeatMapPlugin.prototype._getColumnHeatMapOptions = function(hm, options) {
306
+ if(hm) {
307
+ let isDefault = true;
308
+ if(!options) { options = {}; }
309
+ let val = hm["midPoint"];
310
+ if(val != null && val !== 0) {
311
+ options["midPoint"] = val;
312
+ isDefault = false;
313
+ }
314
+ val = hm["mode"];
315
+ if(val != null && val !== "cell") {
316
+ options["mode"] = val;
317
+ isDefault = false;
318
+ }
319
+ val = hm["min"];
320
+ if(val != null) {
321
+ options["min"] = val;
322
+ isDefault = false;
323
+ }
324
+ val = hm["max"];
325
+ if(val != null) {
326
+ options["max"] = val;
327
+ isDefault = false;
328
+ }
329
+ return isDefault;
330
+ }
331
+ return false;
332
+ };
333
+ /** @public
294
334
  * @param {number} colIndex
295
335
  * @param {Object=} options
296
336
  * @return {!Object}
297
- * @example
298
- * var obj = {
299
- * "heatMap": {
300
- * "midPoint": 0, // optional number
301
- * "mode": "cell", // optional string
302
- * }
303
- * };
304
337
  */
305
338
  HeatMapPlugin.prototype.getColumnHeatMapOptions = function(colIndex, options) {
306
339
  if(!options) { options = {}; }
307
-
308
- let hm = this.getColumnHeatMap(colIndex);
309
- if(hm) {
310
- options["midPoint"] = hm["midPoint"];
311
- options["mode"] = hm["mode"];
312
- }
340
+ this._getColumnHeatMapOptions(this.getColumnHeatMap(colIndex), options);
313
341
  return options;
314
342
  };
315
343
 
@@ -360,8 +388,8 @@ HeatMapPlugin.prototype._onSectionBinding = function (e) {
360
388
  let painter = this.getColumnHeatMap(c, grid);
361
389
  if(painter) {
362
390
  let columnStats = painter.getColumnStats();
363
- let min = columnStats.getMin();
364
- let max = columnStats.getMax();
391
+ let min = painter["min"] != null ? painter["min"] : columnStats.getMin();
392
+ let max = painter["max"] != null ? painter["max"] : columnStats.getMax();
365
393
  for (let r = fromR; r < toR; ++r) {
366
394
  let cell = section.getCell(c, r, false);
367
395
  if(cell) {
@@ -1305,11 +1305,9 @@ RowGroupingPlugin.prototype._updateDisplayColumn = function () {
1305
1305
  */
1306
1306
  RowGroupingPlugin.prototype._getColumnSizeLimit = function (section) {
1307
1307
  if (!this._headerSpanning && section) {
1308
- let cell = section.getCell(this._headerColumn, 0, false);
1309
- if(cell) {
1310
- let sizeLimit = cell.getWidth() - 27; // Ensure padding will subtract icon width (25px for halo, 27px for solar)
1311
- return sizeLimit > 0 ? sizeLimit : 0;
1312
- }
1308
+ const columnWidth = section.getColumnWidth(this._headerColumn);
1309
+ let sizeLimit = columnWidth - 27; // Ensure padding will subtract icon width (25px for halo, 27px for solar)
1310
+ return sizeLimit > 0 ? sizeLimit : 0;
1313
1311
  }
1314
1312
  return -1; // Negative value means no limit
1315
1313
  };
package/lib/versions.json CHANGED
@@ -18,14 +18,14 @@
18
18
  "tr-grid-content-wrap": "1.0.20",
19
19
  "tr-grid-contextmenu": "1.0.44",
20
20
  "tr-grid-filter-input": "0.9.43",
21
- "tr-grid-heat-map": "1.0.30",
21
+ "tr-grid-heat-map": "1.0.33",
22
22
  "tr-grid-in-cell-editing": "1.0.94",
23
23
  "tr-grid-pagination": "1.0.24",
24
24
  "tr-grid-percent-bar": "1.0.24",
25
25
  "tr-grid-range-bar": "2.0.9",
26
26
  "tr-grid-row-dragging": "1.0.39",
27
27
  "tr-grid-row-filtering": "1.0.90",
28
- "tr-grid-row-grouping": "1.0.89",
28
+ "tr-grid-row-grouping": "1.0.91",
29
29
  "tr-grid-row-selection": "1.0.33",
30
30
  "tr-grid-rowcoloring": "1.0.26",
31
31
  "tr-grid-textformatting": "1.0.49",
package/package.json CHANGED
@@ -77,5 +77,5 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  },
80
- "version": "6.1.17"
80
+ "version": "6.1.19"
81
81
  }