@hpcc-js/chart 2.83.3 → 2.84.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.es6.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { INDChart, ITooltip, I2DChart, I1DChart, I2DAggrChart } from '@hpcc-js/api';
2
- import { select, scaleTime, timeParse, timeFormat, scaleLog, format, scalePow, scaleLinear, scaleBand, publish, SVGWidget, brushSelection, d3Event, hsl, min as min$1, max as max$1, Utility, brush, brushX, brushY, scaleSqrt, extent, Text, local, FAChar, descending as descending$1, HTMLWidget, thresholdSturges, tickStep, range, drag, event, dispatch, interpolate, interpolateHcl, Palette, rgb, CanvasWidget, zoom } from '@hpcc-js/common';
2
+ import { publish, select, scaleTime, timeParse, timeFormat, scaleLog, format, scalePow, scaleLinear, scaleBand, SVGWidget, Utility, brush, brushX, brushY, brushSelection, d3Event, hsl, min as min$1, max as max$1, scaleSqrt, extent, local, Text, FAChar, descending as descending$1, HTMLWidget, thresholdSturges, tickStep, range, drag, event, dispatch, interpolateHcl, interpolate, Palette, rgb, CanvasWidget, zoom } from '@hpcc-js/common';
3
3
  import { normalizeRadians, degreesToRadians } from '@hpcc-js/util';
4
4
 
5
5
  var PKG_NAME = "@hpcc-js/chart";
6
- var PKG_VERSION = "2.83.3";
7
- var BUILD_VERSION = "2.105.9";
6
+ var PKG_VERSION = "2.84.0";
7
+ var BUILD_VERSION = "2.106.0";
8
8
 
9
9
  /******************************************************************************
10
10
  Copyright (c) Microsoft Corporation.
@@ -48,6 +48,35 @@ function __metadata(metadataKey, metadataValue) {
48
48
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
49
49
  }
50
50
 
51
+ function __values(o) {
52
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
53
+ if (m) return m.call(o);
54
+ if (o && typeof o.length === "number") return {
55
+ next: function () {
56
+ if (o && i >= o.length) o = void 0;
57
+ return { value: o && o[i++], done: !o };
58
+ }
59
+ };
60
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
61
+ }
62
+
63
+ function __read(o, n) {
64
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
65
+ if (!m) return o;
66
+ var i = m.call(o), r, ar = [], e;
67
+ try {
68
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
69
+ }
70
+ catch (error) { e = { error: error }; }
71
+ finally {
72
+ try {
73
+ if (r && !r.done && (m = i["return"])) m.call(i);
74
+ }
75
+ finally { if (e) throw e.error; }
76
+ }
77
+ return ar;
78
+ }
79
+
51
80
  function __spreadArray(to, from, pack) {
52
81
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
53
82
  if (ar || !(i in from)) {
@@ -2431,12 +2460,22 @@ var XYAxis = /** @class */ (function (_super) {
2431
2460
  })
2432
2461
  .merge(focusChart)
2433
2462
  .each(function () {
2463
+ var e_1, _a;
2434
2464
  context.copyPropsTo(context.focusChart, ["layers"]);
2435
2465
  var layerIdx = 0;
2436
- for (var _i = 0, _a = context.layers(); _i < _a.length; _i++) {
2437
- var layer = _a[_i];
2438
- layer.copyPropsTo(context.focusChart.layers()[layerIdx]);
2439
- layerIdx++;
2466
+ try {
2467
+ for (var _b = __values(context.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2468
+ var layer = _c.value;
2469
+ layer.copyPropsTo(context.focusChart.layers()[layerIdx]);
2470
+ layerIdx++;
2471
+ }
2472
+ }
2473
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2474
+ finally {
2475
+ try {
2476
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2477
+ }
2478
+ finally { if (e_1) throw e_1.error; }
2440
2479
  }
2441
2480
  context.focusChart
2442
2481
  .xAxisFocus(false)
@@ -2487,7 +2526,7 @@ var XYAxis = /** @class */ (function (_super) {
2487
2526
  if (!retVal.length) {
2488
2527
  return masterColumns;
2489
2528
  }
2490
- return __spreadArray([masterColumns[0]], retVal, true);
2529
+ return __spreadArray([masterColumns[0]], __read(retVal), false);
2491
2530
  };
2492
2531
  XYAxis.prototype.layerColumnIndices = function (host) {
2493
2532
  var masterColumns = host.columns();
@@ -2516,24 +2555,44 @@ var XYAxis = /** @class */ (function (_super) {
2516
2555
  XYAxis.prototype.layerExit = function (host, element, duration) {
2517
2556
  };
2518
2557
  XYAxis.prototype.chartsEnter = function (host, element, duration) {
2558
+ var e_2, _a;
2519
2559
  if (duration === void 0) { duration = 250; }
2520
2560
  this.layerEnter(this, element, duration);
2521
- for (var _i = 0, _a = this.layers(); _i < _a.length; _i++) {
2522
- var w = _a[_i];
2523
- w["__xyAxisElement"] = element.append("g")
2524
- .attr("class", w.class());
2525
- w
2526
- .target(w["__xyAxisElement"].node())
2527
- .layerEnter(this, element, duration);
2561
+ try {
2562
+ for (var _b = __values(this.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2563
+ var w = _c.value;
2564
+ w["__xyAxisElement"] = element.append("g")
2565
+ .attr("class", w.class());
2566
+ w
2567
+ .target(w["__xyAxisElement"].node())
2568
+ .layerEnter(this, element, duration);
2569
+ }
2570
+ }
2571
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2572
+ finally {
2573
+ try {
2574
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2575
+ }
2576
+ finally { if (e_2) throw e_2.error; }
2528
2577
  }
2529
2578
  };
2530
2579
  XYAxis.prototype.chartsUpdate = function (width, height, duration) {
2580
+ var e_3, _a;
2531
2581
  this.layerUpdate(this, this.svgData, duration);
2532
- for (var _i = 0, _a = this.layers(); _i < _a.length; _i++) {
2533
- var w = _a[_i];
2534
- w
2535
- .resize({ width: width, height: height })
2536
- .layerUpdate(this, w["__xyAxisElement"], duration);
2582
+ try {
2583
+ for (var _b = __values(this.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2584
+ var w = _c.value;
2585
+ w
2586
+ .resize({ width: width, height: height })
2587
+ .layerUpdate(this, w["__xyAxisElement"], duration);
2588
+ }
2589
+ }
2590
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2591
+ finally {
2592
+ try {
2593
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2594
+ }
2595
+ finally { if (e_3) throw e_3.error; }
2537
2596
  }
2538
2597
  };
2539
2598
  XYAxis.prototype.exit = function (domNode, element) {
@@ -3336,7 +3395,7 @@ var Column = /** @class */ (function (_super) {
3336
3395
  columnGRect.exit().transition().duration(duration)
3337
3396
  .style("opacity", 0)
3338
3397
  .remove();
3339
- var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; }));
3398
+ var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, __spreadArray([], __read(dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; })), false));
3340
3399
  var stackedTotalText = element.selectAll(".stackedTotalText").data(context.showDomainTotal() ? [domainSums[dataRowIdx]] : []);
3341
3400
  var stackedTotalTextEnter = stackedTotalText.enter().append("g")
3342
3401
  .attr("class", "stackedTotalText")
@@ -3390,6 +3449,7 @@ var Column = /** @class */ (function (_super) {
3390
3449
  .remove();
3391
3450
  };
3392
3451
  Column.prototype.calcInnerText = function (offset, innerText, valueText) {
3452
+ var e_1, _a;
3393
3453
  var fontFamily = this.innerTextFontFamily_exists() ? this.innerTextFontFamily() : "Verdana";
3394
3454
  var fontSize = this.innerTextFontSize();
3395
3455
  var valueFontFamily = this.valueFontFamily_exists() ? this.valueFontFamily() : "Verdana";
@@ -3416,15 +3476,24 @@ var Column = /** @class */ (function (_super) {
3416
3476
  else if (fullWidth2 < offset) {
3417
3477
  var excessWidth = offset - fullWidth2;
3418
3478
  var _text = "";
3419
- for (var _i = 0, innerText_1 = innerText; _i < innerText_1.length; _i++) {
3420
- var letter = innerText_1[_i];
3421
- if (this.textSize(_text + letter, fontFamily, fontSize).width > excessWidth) {
3422
- innerText = _text + "...";
3423
- break;
3479
+ try {
3480
+ for (var innerText_1 = __values(innerText), innerText_1_1 = innerText_1.next(); !innerText_1_1.done; innerText_1_1 = innerText_1.next()) {
3481
+ var letter = innerText_1_1.value;
3482
+ if (this.textSize(_text + letter, fontFamily, fontSize).width > excessWidth) {
3483
+ innerText = _text + "...";
3484
+ break;
3485
+ }
3486
+ else {
3487
+ _text += letter;
3488
+ }
3424
3489
  }
3425
- else {
3426
- _text += letter;
3490
+ }
3491
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3492
+ finally {
3493
+ try {
3494
+ if (innerText_1_1 && !innerText_1_1.done && (_a = innerText_1.return)) _a.call(innerText_1);
3427
3495
  }
3496
+ finally { if (e_1) throw e_1.error; }
3428
3497
  }
3429
3498
  category = 2;
3430
3499
  }
@@ -5213,8 +5282,6 @@ function areaRingEnd() {
5213
5282
  areaPoint(x00$2, y00$2);
5214
5283
  }
5215
5284
 
5216
- var pathArea = areaStream;
5217
-
5218
5285
  var x0$2 = Infinity,
5219
5286
  y0$2 = x0$2,
5220
5287
  x1 = -x0$2,
@@ -5240,8 +5307,6 @@ function boundsPoint(x, y) {
5240
5307
  if (y > y1) y1 = y;
5241
5308
  }
5242
5309
 
5243
- var boundsStream$1 = boundsStream;
5244
-
5245
5310
  // TODO Enforce positive area for exterior, negative area for interior?
5246
5311
 
5247
5312
  var X0 = 0,
@@ -5339,8 +5404,6 @@ function centroidPointRing(x, y) {
5339
5404
  centroidPoint(x0$1 = x, y0$1 = y);
5340
5405
  }
5341
5406
 
5342
- var pathCentroid = centroidStream;
5343
-
5344
5407
  function PathContext(context) {
5345
5408
  this._context = context;
5346
5409
  }
@@ -5424,8 +5487,6 @@ function lengthPoint(x, y) {
5424
5487
  x0 = x, y0 = y;
5425
5488
  }
5426
5489
 
5427
- var pathMeasure = lengthStream;
5428
-
5429
5490
  function PathString() {
5430
5491
  this._string = [];
5431
5492
  }
@@ -5500,23 +5561,23 @@ function geoPath(projection, context) {
5500
5561
  }
5501
5562
 
5502
5563
  path.area = function(object) {
5503
- geoStream(object, projectionStream(pathArea));
5504
- return pathArea.result();
5564
+ geoStream(object, projectionStream(areaStream));
5565
+ return areaStream.result();
5505
5566
  };
5506
5567
 
5507
5568
  path.measure = function(object) {
5508
- geoStream(object, projectionStream(pathMeasure));
5509
- return pathMeasure.result();
5569
+ geoStream(object, projectionStream(lengthStream));
5570
+ return lengthStream.result();
5510
5571
  };
5511
5572
 
5512
5573
  path.bounds = function(object) {
5513
- geoStream(object, projectionStream(boundsStream$1));
5514
- return boundsStream$1.result();
5574
+ geoStream(object, projectionStream(boundsStream));
5575
+ return boundsStream.result();
5515
5576
  };
5516
5577
 
5517
5578
  path.centroid = function(object) {
5518
- geoStream(object, projectionStream(pathCentroid));
5519
- return pathCentroid.result();
5579
+ geoStream(object, projectionStream(centroidStream));
5580
+ return centroidStream.result();
5520
5581
  };
5521
5582
 
5522
5583
  path.projection = function(_) {
@@ -8814,7 +8875,7 @@ var Gauge = /** @class */ (function (_super) {
8814
8875
  this._usageArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8815
8876
  .style("fill", "green")
8816
8877
  .on("mousemove", function (d) {
8817
- var _a = _this._d3Arc.centroid(d), x = _a[0], y = _a[1];
8878
+ var _a = __read(_this._d3Arc.centroid(d), 2), x = _a[0], y = _a[1];
8818
8879
  _this.tip({ x: x, y: y, label: _this.valueDescription() });
8819
8880
  })
8820
8881
  .on("mouseout", function (d) {
@@ -8825,7 +8886,7 @@ var Gauge = /** @class */ (function (_super) {
8825
8886
  this._meanArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8826
8887
  .style("fill", "black")
8827
8888
  .on("mousemove", function (d) {
8828
- var _a = _this._d3Arc.centroid(d), x = _a[0], y = _a[1];
8889
+ var _a = __read(_this._d3Arc.centroid(d), 2), x = _a[0], y = _a[1];
8829
8890
  _this.tip({ x: x, y: y, label: _this.tickValueDescription() });
8830
8891
  })
8831
8892
  .on("mouseout", function (d) {
@@ -8839,7 +8900,7 @@ var Gauge = /** @class */ (function (_super) {
8839
8900
  .style("stroke", "black")
8840
8901
  .attr("d", "M 0 0 l -3 -3 l 6 0 z")
8841
8902
  .on("mousemove", function (d) {
8842
- var _a = context._d3Arc.centroid(context._meanArc.datum()), x = _a[0], y = _a[1];
8903
+ var _a = __read(context._d3Arc.centroid(context._meanArc.datum()), 2), x = _a[0], y = _a[1];
8843
8904
  context.tip({ x: x, y: y, label: context.tickValueDescription() });
8844
8905
  })
8845
8906
  .on("mouseout", function (d) {
@@ -9126,7 +9187,7 @@ var Pie = /** @class */ (function (_super) {
9126
9187
  .padRadius(outerRadius)
9127
9188
  .outerRadius(outerRadius);
9128
9189
  this._quadIdxArr = [[], [], [], []];
9129
- var data = __spreadArray([], this.data(), true).sort(function (a, b) {
9190
+ var data = __spreadArray([], __read(this.data()), false).sort(function (a, b) {
9130
9191
  return a[1] - b[1] > 0 ? -1 : 1;
9131
9192
  });
9132
9193
  var arc = this._slices.selectAll(".arc").data(this.d3Pie(data), function (d) { return d.data[0]; });
@@ -9220,7 +9281,7 @@ var Pie = /** @class */ (function (_super) {
9220
9281
  .attr("points", function (d, i) {
9221
9282
  var pos = context.d3LabelArc.centroid(d);
9222
9283
  var pos1 = context.d3Arc.centroid(d);
9223
- var pos2 = __spreadArray([], pos, true);
9284
+ var pos2 = __spreadArray([], __read(pos), false);
9224
9285
  pos[0] = labelRadius * (context.isLeftSide(midAngle(d)) ? 1 : -1);
9225
9286
  pos[1] = context._labelPositions[i].top;
9226
9287
  return [pos1, pos2, pos];
@@ -9437,7 +9498,7 @@ var Heat = /** @class */ (function (_super) {
9437
9498
  var data = host.orientation() === "horizontal" ?
9438
9499
  this.data().map(function (r) { return [host.dataPos(r[0]), host.valuePos(r[1]), r[2]]; }) :
9439
9500
  this.data().map(function (r) { return [host.valuePos(r[1]), host.dataPos(r[0]), r[2]]; });
9440
- var maxWeight = max$1(data, function (r) { return r[2]; });
9501
+ var maxWeight = this.maxWeight_exists() ? this.maxWeight() : max$1(data, function (r) { return r[2]; });
9441
9502
  if (this.paletteID() !== "default") {
9442
9503
  var gradient = {};
9443
9504
  var count = 8;
@@ -9471,6 +9532,7 @@ Heat.prototype.publish("radiusX", 25, "number", "Point X radius (25 by default)"
9471
9532
  Heat.prototype.publish("radiusY", 25, "number", "Point Y radius (25 by default)");
9472
9533
  Heat.prototype.publish("radiusAsPercent", false, "boolean", "Calculate RadiusX + RadiusY as % of size");
9473
9534
  Heat.prototype.publish("blur", 15, "number", "Point blur radius (15 by default)");
9535
+ Heat.prototype.publish("maxWeight", undefined, "number", "Clamp max weight to value (optional), omitting uses max data point", undefined, { optional: true });
9474
9536
  Heat.prototype.publish("minOpacity", 0.05, "number", "Minimum point opacity (0.05 by default)");
9475
9537
  // The following code is a modified version of
9476
9538
  // - https://github.com/mourner/simpleheat
@@ -10449,7 +10511,7 @@ var RadialBar = /** @class */ (function (_super) {
10449
10511
  var _this = this;
10450
10512
  _super.prototype.update.call(this, domNode, element);
10451
10513
  var context = this;
10452
- var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], this.data().map(function (d) { return d[1]; }), false));
10514
+ var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], __read(this.data().map(function (d) { return d[1]; })), false));
10453
10515
  this._valueScale
10454
10516
  .domain([0, maxValue])
10455
10517
  .range([0, this.radians(this.valueMaxAngle())]);
@@ -10583,7 +10645,7 @@ function myFormatter(format$1) {
10583
10645
  var StatChart = /** @class */ (function (_super) {
10584
10646
  __extends(StatChart, _super);
10585
10647
  function StatChart() {
10586
- var _this = _super !== null && _super.apply(this, arguments) || this;
10648
+ var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this;
10587
10649
  _this._bellCurve = new Scatter()
10588
10650
  .columns(["", "Std. Dev."])
10589
10651
  .paletteID("Quartile")
@@ -10708,14 +10770,14 @@ var StatChart = /** @class */ (function (_super) {
10708
10770
  { label: this.formatQ(4), value: this.quartile(4) }
10709
10771
  ];
10710
10772
  }
10711
- var _a = this.domain(this._selectMode.node().value), domainLow = _a[0], domainHigh = _a[1];
10773
+ var _a = __read(this.domain(this._selectMode.node().value), 2), domainLow = _a[0], domainHigh = _a[1];
10712
10774
  return ticks
10713
10775
  .filter(function (sd) { return sd.value >= domainLow && sd.value <= domainHigh; })
10714
10776
  .map(function (sd) { return ({ label: sd.label, value: sd.value.toString() }); });
10715
10777
  };
10716
10778
  StatChart.prototype.updateScatter = function () {
10717
10779
  var mode = this._selectMode.node().value;
10718
- var _a = this.domain(mode), domainLow = _a[0], domainHigh = _a[1];
10780
+ var _a = __read(this.domain(mode), 2), domainLow = _a[0], domainHigh = _a[1];
10719
10781
  var padding = (domainHigh - domainLow) * (this.domainPadding() / 100);
10720
10782
  this._bellCurve
10721
10783
  .xAxisDomainLow(domainLow - padding)
@@ -11126,6 +11188,7 @@ SummaryC.prototype.playInterval = function (_) {
11126
11188
  };
11127
11189
 
11128
11190
  // Word cloud layout by Jason Davies, https://www.jasondavies.com/wordcloud/
11191
+ // Algorithm due to Jonathan Feinberg, http://static.mrfeinberg.com/bv_ch03.pdf
11129
11192
  var cloudRadians = Math.PI / 180;
11130
11193
  var cw = 1 << 11 >> 5;
11131
11194
  var ch = 1 << 11;