@hpcc-js/graph 2.72.0 → 2.77.0

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/dist/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  }(this, (function (exports, common, util$3, api, react, html) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/graph";
8
- var PKG_VERSION = "2.72.0";
9
- var BUILD_VERSION = "2.93.0";
8
+ var PKG_VERSION = "2.77.0";
9
+ var BUILD_VERSION = "2.99.0";
10
10
 
11
11
  /*! *****************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -14462,6 +14462,7 @@
14462
14462
  if (this.data().length === 0)
14463
14463
  return retVal;
14464
14464
  var vertexIndex = {};
14465
+ var valueIdx = 2;
14465
14466
  var mappings = this.mappings().filter(function (mapping) { return mapping.valid(); });
14466
14467
  mappings.forEach(function (mapping, idx) {
14467
14468
  var view = this._db.rollupView([mapping.column()]);
@@ -14472,7 +14473,8 @@
14472
14473
  __id: id,
14473
14474
  __category: mapping.column(),
14474
14475
  name: row.key,
14475
- origRow: row.values
14476
+ origRow: row.value,
14477
+ value: row.value[idx][valueIdx]
14476
14478
  });
14477
14479
  vertexIndex[id] = retVal.vertices.length - 1;
14478
14480
  }
@@ -14490,7 +14492,7 @@
14490
14492
  __id: sourceID + "_" + targetID,
14491
14493
  source: vertexIndex[sourceID],
14492
14494
  target: vertexIndex[targetID],
14493
- value: mapping2_1.aggregate(value.value)
14495
+ value: value.value[0][valueIdx]
14494
14496
  });
14495
14497
  });
14496
14498
  });
@@ -14506,12 +14508,20 @@
14506
14508
  Sankey$1.prototype.update = function (domNode, element) {
14507
14509
  _super.prototype.update.call(this, domNode, element);
14508
14510
  this._palette = this._palette.switch(this.paletteID());
14511
+ var strokeWidth = this.vertexStrokeWidth();
14509
14512
  var sankeyData = this.sankeyData();
14513
+ var sw2 = strokeWidth * 2;
14510
14514
  this._d3Sankey
14511
- .extent([[0, 0], [this.width(), this.height()]])
14515
+ .extent([
14516
+ [strokeWidth, strokeWidth],
14517
+ [this.width() - sw2, this.height() - sw2]
14518
+ ])
14512
14519
  .nodeWidth(this.vertexWidth())
14513
14520
  .nodePadding(this.vertexPadding());
14514
- this._d3Sankey({ nodes: sankeyData.vertices, links: sankeyData.edges });
14521
+ this._d3Sankey({
14522
+ nodes: sankeyData.vertices,
14523
+ links: sankeyData.edges
14524
+ });
14515
14525
  var context = this;
14516
14526
  // Links ---
14517
14527
  var link = element.selectAll(".link").data(sankeyData.edges);
@@ -14523,8 +14533,10 @@
14523
14533
  })
14524
14534
  .merge(link)
14525
14535
  .attr("d", d3SankeyLinkHorizontal())
14526
- .style("stroke-width", function (d) { return Math.max(1, d.dy); })
14527
- .sort(function (a, b) { return b.dy - a.dy; })
14536
+ .style("stroke-width", function (d) {
14537
+ return Math.max(1, d.width);
14538
+ })
14539
+ .sort(function (a, b) { return b.width - a.width; })
14528
14540
  .select("title")
14529
14541
  .text(function (d) {
14530
14542
  return d.source.name + " → " + d.target.name + "\n" + d.value;
@@ -14557,23 +14569,33 @@
14557
14569
  */
14558
14570
  .merge(node)
14559
14571
  .attr("transform", function (d) {
14560
- return "translate(" + d.x + "," + d.y + ")";
14572
+ var _x = 0;
14573
+ var _y = 0;
14574
+ if (d.x0)
14575
+ _x = d.x0;
14576
+ if (d.y0)
14577
+ _y = d.y0;
14578
+ return "translate(" + (_x + strokeWidth) + "," + (_y + strokeWidth) + ")";
14561
14579
  })
14562
14580
  .each(function () {
14563
14581
  var n = common.select(this);
14564
14582
  n.select("rect")
14565
- .attr("height", function (d) { return d.dy; })
14583
+ .attr("height", function (d) { return d.y1 - d.y0; })
14566
14584
  .attr("width", context._d3Sankey.nodeWidth())
14567
14585
  .style("fill", function (d) { return context._palette(d.name); })
14586
+ .style("stroke", function (d) { return context.vertexStrokeColor(); })
14587
+ .style("stroke-width", function (d) { return strokeWidth; })
14568
14588
  .style("cursor", (context.xAxisMovement() || context.yAxisMovement()) ? null : "default");
14569
14589
  n.select("text")
14570
14590
  .attr("x", -6)
14571
- .attr("y", function (d) { return d.dy / 2; })
14591
+ .attr("y", function (d) {
14592
+ return (d.y1 - d.y0) / 2;
14593
+ })
14572
14594
  .attr("dy", ".35em")
14573
14595
  .attr("text-anchor", "end")
14574
14596
  .attr("transform", null)
14575
14597
  .text(function (d) { return d.name; })
14576
- .filter(function (d) { return d.x < context.width() / 2; })
14598
+ .filter(function (d) { return d.x0 < context.width() / 2; })
14577
14599
  .attr("x", 6 + context._d3Sankey.nodeWidth())
14578
14600
  .attr("text-anchor", "start");
14579
14601
  });
@@ -14623,6 +14645,8 @@
14623
14645
  Sankey$1.prototype._palette = common.Palette.ordinal("default");
14624
14646
  Sankey$1.prototype.publish("paletteID", "default", "set", "Color palette for this widget", Sankey$1.prototype._palette.switch());
14625
14647
  Sankey$1.prototype.publish("mappings", [], "propertyArray", "Source Columns", null, { autoExpand: SankeyColumn });
14648
+ Sankey$1.prototype.publish("vertexStrokeWidth", 1, "number", "Vertex Stroke Width");
14649
+ Sankey$1.prototype.publish("vertexStrokeColor", "darkgray", "string", "Vertex Stroke Color");
14626
14650
  Sankey$1.prototype.publish("vertexWidth", 36, "number", "Vertex Width");
14627
14651
  Sankey$1.prototype.publish("vertexPadding", 40, "number", "Vertex Padding");
14628
14652
  Sankey$1.prototype.publish("xAxisMovement", false, "boolean", "Enable x-axis movement");
@@ -17061,6 +17085,7 @@
17061
17085
  _this._masterVerticesMap = {};
17062
17086
  _this._prevEdges = [];
17063
17087
  _this._masterEdges = [];
17088
+ _this._masterEdgesMap = {};
17064
17089
  _this._prevHierarchy = [];
17065
17090
  _this._masterHierarchy = [];
17066
17091
  _this._masterHierarchyMap = {};
@@ -17097,19 +17122,24 @@
17097
17122
  var columns = this.subgraphColumns();
17098
17123
  var idIdx = this.indexOf(columns, this.subgraphIDColumn(), "id");
17099
17124
  var labelIdx = this.indexOf(columns, this.subgraphLabelColumn(), "label");
17100
- var subgraphs = this.subgraphs();
17101
- var diff = util$3.compare2(this._prevSubgraphs, subgraphs, function (d) { return d[idIdx]; });
17125
+ var subgraphs = this.subgraphs().map(function (sg) {
17126
+ return {
17127
+ id: "" + sg[idIdx],
17128
+ text: "" + sg[labelIdx],
17129
+ origData: toJsonObj(sg, columns)
17130
+ };
17131
+ });
17132
+ var diff = util$3.compare2(this._prevSubgraphs, subgraphs, function (d) { return d.id; });
17102
17133
  diff.exit.forEach(function (item) {
17103
- _this._masterSubgraphs = _this._masterSubgraphs.filter(function (i) { return i.id !== item[idIdx]; });
17134
+ _this._masterSubgraphs = _this._masterSubgraphs.filter(function (i) { return i.id !== item.id; });
17135
+ delete _this._masterSubgraphsMap[item.id];
17104
17136
  });
17105
17137
  diff.enter.forEach(function (item) {
17106
- var sg = {
17107
- id: "" + item[idIdx],
17108
- text: "" + item[labelIdx],
17109
- origData: toJsonObj(item, columns)
17110
- };
17111
- _this._masterSubgraphs.push(sg);
17112
- _this._masterSubgraphsMap[sg.id] = sg;
17138
+ _this._masterSubgraphs.push(item);
17139
+ _this._masterSubgraphsMap[item.id] = item;
17140
+ });
17141
+ diff.update.forEach(function (item) {
17142
+ _this._masterSubgraphsMap[item.id].origData = item.origData;
17113
17143
  });
17114
17144
  this._prevSubgraphs = subgraphs;
17115
17145
  };
@@ -17141,11 +17171,15 @@
17141
17171
  var diff = util$3.compare2(this._prevVertices, vertices, function (d) { return d.id; });
17142
17172
  diff.exit.forEach(function (item) {
17143
17173
  _this._masterVertices = _this._masterVertices.filter(function (i) { return i.id !== item.id; });
17174
+ delete _this._masterVerticesMap[item.id];
17144
17175
  });
17145
17176
  diff.enter.forEach(function (item) {
17146
17177
  _this._masterVertices.push(item);
17147
17178
  _this._masterVerticesMap[item.id] = item;
17148
17179
  });
17180
+ diff.update.forEach(function (item) {
17181
+ _this._masterVerticesMap[item.id].origData = item.origData;
17182
+ });
17149
17183
  this._prevVertices = vertices;
17150
17184
  };
17151
17185
  DataGraph.prototype.mergeEdges = function () {
@@ -17178,9 +17212,14 @@
17178
17212
  var diff = util$3.compare2(this._masterEdges, edges, function (d) { return d.id; });
17179
17213
  diff.exit.forEach(function (item) {
17180
17214
  _this._masterEdges = _this._masterEdges.filter(function (i) { return i.id !== item.id; });
17215
+ delete _this._masterEdgesMap[item.id];
17181
17216
  });
17182
17217
  diff.enter.forEach(function (item) {
17183
17218
  _this._masterEdges.push(item);
17219
+ _this._masterEdgesMap[item.id] = item;
17220
+ });
17221
+ diff.update.forEach(function (item) {
17222
+ _this._masterEdgesMap[item.id].origData = item.origData;
17184
17223
  });
17185
17224
  this._prevEdges = edges;
17186
17225
  };
@@ -17199,6 +17238,7 @@
17199
17238
  var diff = util$3.compare2(this._prevHierarchy, hierarchy, function (d) { return d.id; });
17200
17239
  diff.exit.forEach(function (item) {
17201
17240
  _this._masterHierarchy = _this._masterHierarchy.filter(function (i) { return i.id !== item.id; });
17241
+ delete _this._masterHierarchyMap[item.id];
17202
17242
  });
17203
17243
  diff.enter.forEach(function (item) {
17204
17244
  _this._masterHierarchy.push(item);
@@ -17330,6 +17370,9 @@
17330
17370
  }(Graph2));
17331
17371
  DataGraph.prototype._class += " graph_DataGraph";
17332
17372
 
17373
+ var css_248z$6 = ".graph_SankeyGraph .node rect{cursor:move;fill-opacity:.9;shape-rendering:crispEdges;stroke:#a9a9a9}.graph_SankeyGraph .node.selected rect{stroke:red}.graph_SankeyGraph .node.over rect{stroke:orange}.graph_SankeyGraph .node.selected.over rect{stroke:red}.graph_SankeyGraph .node text{pointer-events:none;text-shadow:0 1px 0 #fff}.graph_SankeyGraph .node.selected text{fill:red}.graph_SankeyGraph .node.over text{fill:orange}.graph_SankeyGraph .node.selected.over text{fill:red}.graph_SankeyGraph .link{fill:none;stroke:#000;stroke-opacity:.2}.graph_SankeyGraph .link:hover{stroke-opacity:.5}";
17374
+ styleInject(css_248z$6);
17375
+
17333
17376
  var SankeyGraph = /** @class */ (function (_super) {
17334
17377
  __extends(SankeyGraph, _super);
17335
17378
  function SankeyGraph() {
@@ -17441,10 +17484,12 @@
17441
17484
  [0, 0],
17442
17485
  [this.width(), this.height()]
17443
17486
  ]);
17444
- this._d3Sankey({
17445
- nodes: sankeyData.vertices,
17446
- links: sankeyData.edges
17447
- });
17487
+ if (sankeyData.vertices.length > 0) {
17488
+ this._d3Sankey({
17489
+ nodes: sankeyData.vertices,
17490
+ links: sankeyData.edges
17491
+ });
17492
+ }
17448
17493
  var context = this;
17449
17494
  // Links ---
17450
17495
  var link = element.selectAll(".link").data(sankeyData.edges);
@@ -17469,10 +17514,10 @@
17469
17514
  .attr("class", "node")
17470
17515
  .call(this._selection.enter.bind(this._selection))
17471
17516
  .on("click", function (d) {
17472
- context.click(context.rowToObj(d.origRow), "", context._selection.selected(this));
17517
+ context.click(d.origData, "", context._selection.selected(this));
17473
17518
  })
17474
17519
  .on("dblclick", function (d) {
17475
- context.dblclick(context.rowToObj(d.origRow[0]), "", context._selection.selected(this));
17520
+ context.dblclick(d.origData, "", context._selection.selected(this));
17476
17521
  })
17477
17522
  .each(function () {
17478
17523
  var gElement = common.select(this);