@hpcc-js/chart 2.83.4 → 2.84.1

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
@@ -3,8 +3,8 @@ import { publish, select, scaleTime, timeParse, timeFormat, scaleLog, format, sc
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.4";
7
- var BUILD_VERSION = "2.105.12";
6
+ var PKG_VERSION = "2.84.1";
7
+ var BUILD_VERSION = "2.106.1";
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
  }
@@ -8806,7 +8875,7 @@ var Gauge = /** @class */ (function (_super) {
8806
8875
  this._usageArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8807
8876
  .style("fill", "green")
8808
8877
  .on("mousemove", function (d) {
8809
- 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];
8810
8879
  _this.tip({ x: x, y: y, label: _this.valueDescription() });
8811
8880
  })
8812
8881
  .on("mouseout", function (d) {
@@ -8817,7 +8886,7 @@ var Gauge = /** @class */ (function (_super) {
8817
8886
  this._meanArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8818
8887
  .style("fill", "black")
8819
8888
  .on("mousemove", function (d) {
8820
- 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];
8821
8890
  _this.tip({ x: x, y: y, label: _this.tickValueDescription() });
8822
8891
  })
8823
8892
  .on("mouseout", function (d) {
@@ -8831,7 +8900,7 @@ var Gauge = /** @class */ (function (_super) {
8831
8900
  .style("stroke", "black")
8832
8901
  .attr("d", "M 0 0 l -3 -3 l 6 0 z")
8833
8902
  .on("mousemove", function (d) {
8834
- 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];
8835
8904
  context.tip({ x: x, y: y, label: context.tickValueDescription() });
8836
8905
  })
8837
8906
  .on("mouseout", function (d) {
@@ -9118,7 +9187,7 @@ var Pie = /** @class */ (function (_super) {
9118
9187
  .padRadius(outerRadius)
9119
9188
  .outerRadius(outerRadius);
9120
9189
  this._quadIdxArr = [[], [], [], []];
9121
- var data = __spreadArray([], this.data(), true).sort(function (a, b) {
9190
+ var data = __spreadArray([], __read(this.data()), false).sort(function (a, b) {
9122
9191
  return a[1] - b[1] > 0 ? -1 : 1;
9123
9192
  });
9124
9193
  var arc = this._slices.selectAll(".arc").data(this.d3Pie(data), function (d) { return d.data[0]; });
@@ -9212,7 +9281,7 @@ var Pie = /** @class */ (function (_super) {
9212
9281
  .attr("points", function (d, i) {
9213
9282
  var pos = context.d3LabelArc.centroid(d);
9214
9283
  var pos1 = context.d3Arc.centroid(d);
9215
- var pos2 = __spreadArray([], pos, true);
9284
+ var pos2 = __spreadArray([], __read(pos), false);
9216
9285
  pos[0] = labelRadius * (context.isLeftSide(midAngle(d)) ? 1 : -1);
9217
9286
  pos[1] = context._labelPositions[i].top;
9218
9287
  return [pos1, pos2, pos];
@@ -9429,7 +9498,7 @@ var Heat = /** @class */ (function (_super) {
9429
9498
  var data = host.orientation() === "horizontal" ?
9430
9499
  this.data().map(function (r) { return [host.dataPos(r[0]), host.valuePos(r[1]), r[2]]; }) :
9431
9500
  this.data().map(function (r) { return [host.valuePos(r[1]), host.dataPos(r[0]), r[2]]; });
9432
- 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]; });
9433
9502
  if (this.paletteID() !== "default") {
9434
9503
  var gradient = {};
9435
9504
  var count = 8;
@@ -9463,6 +9532,7 @@ Heat.prototype.publish("radiusX", 25, "number", "Point X radius (25 by default)"
9463
9532
  Heat.prototype.publish("radiusY", 25, "number", "Point Y radius (25 by default)");
9464
9533
  Heat.prototype.publish("radiusAsPercent", false, "boolean", "Calculate RadiusX + RadiusY as % of size");
9465
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 });
9466
9536
  Heat.prototype.publish("minOpacity", 0.05, "number", "Minimum point opacity (0.05 by default)");
9467
9537
  // The following code is a modified version of
9468
9538
  // - https://github.com/mourner/simpleheat
@@ -9551,6 +9621,12 @@ simpleheat.prototype = {
9551
9621
  // draw a grayscale heatmap by putting a blurred ellipse at each data point
9552
9622
  for (var i = 0, len = this._data.length, p = void 0; i < len; i++) {
9553
9623
  p = this._data[i];
9624
+ if (p[2] < 0) {
9625
+ p[2] = 0;
9626
+ }
9627
+ else if (p[2] > this._max) {
9628
+ p[2] = this._max;
9629
+ }
9554
9630
  ctx.globalAlpha = Math.max(p[2] / this._max, minOpacity === undefined ? 0.05 : minOpacity);
9555
9631
  ctx.drawImage(this._ellipse, p[0] - this._r, p[1] - this._r);
9556
9632
  }
@@ -10441,7 +10517,7 @@ var RadialBar = /** @class */ (function (_super) {
10441
10517
  var _this = this;
10442
10518
  _super.prototype.update.call(this, domNode, element);
10443
10519
  var context = this;
10444
- var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], this.data().map(function (d) { return d[1]; }), false));
10520
+ var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], __read(this.data().map(function (d) { return d[1]; })), false));
10445
10521
  this._valueScale
10446
10522
  .domain([0, maxValue])
10447
10523
  .range([0, this.radians(this.valueMaxAngle())]);
@@ -10575,7 +10651,7 @@ function myFormatter(format$1) {
10575
10651
  var StatChart = /** @class */ (function (_super) {
10576
10652
  __extends(StatChart, _super);
10577
10653
  function StatChart() {
10578
- var _this = _super !== null && _super.apply(this, arguments) || this;
10654
+ var _this = _super.call(this) || this;
10579
10655
  _this._bellCurve = new Scatter()
10580
10656
  .columns(["", "Std. Dev."])
10581
10657
  .paletteID("Quartile")
@@ -10599,6 +10675,8 @@ var StatChart = /** @class */ (function (_super) {
10599
10675
  .valueFontSize(0)
10600
10676
  .lineColor(rainbow(90, 0, 100))
10601
10677
  .innerRectColor(rainbow(10, 0, 100));
10678
+ _this
10679
+ .columns(["Min", "25%", "50%", "75%", "Max", "Mean", "Std. Dev."]);
10602
10680
  return _this;
10603
10681
  }
10604
10682
  StatChart.prototype.stdDev = function (degrees) {
@@ -10608,7 +10686,7 @@ var StatChart = /** @class */ (function (_super) {
10608
10686
  return this._tickFormatter(this.stdDev(degrees));
10609
10687
  };
10610
10688
  StatChart.prototype.quartile = function (q) {
10611
- return this.data()[0][q];
10689
+ return this.quartiles()[q];
10612
10690
  };
10613
10691
  StatChart.prototype.formatQ = function (q) {
10614
10692
  return this._tickFormatter(this.quartile(q));
@@ -10624,31 +10702,19 @@ var StatChart = /** @class */ (function (_super) {
10624
10702
  return [this.quartile(0), this.quartile(4)];
10625
10703
  }
10626
10704
  };
10627
- StatChart.prototype.mean = function (_) {
10628
- if (!arguments.length)
10629
- return this._mean;
10630
- this._mean = _;
10631
- if (this.data()[0]) {
10632
- this.data()[0][5] = _;
10633
- }
10634
- return this;
10705
+ StatChart.prototype.min = function () {
10706
+ return this.quartile(0);
10635
10707
  };
10636
- StatChart.prototype.standardDeviation = function (_) {
10637
- if (!arguments.length)
10638
- return this._standardDeviation;
10639
- this._standardDeviation = _;
10640
- if (this.data()[0]) {
10641
- this.data()[0][6] = _;
10642
- }
10643
- return this;
10708
+ StatChart.prototype.max = function () {
10709
+ return this.quartile(4);
10644
10710
  };
10645
- StatChart.prototype.quartiles = function (_) {
10711
+ StatChart.prototype.data = function (_) {
10646
10712
  if (!arguments.length)
10647
- return this._quartiles;
10648
- this._quartiles = _;
10649
- if (this.data()[0]) {
10650
- this.data()[0] = _.concat(this.data()[0].slice(-2));
10651
- }
10713
+ return [__spreadArray(__spreadArray([], __read(this.quartiles()), false), [this.mean(), this.standardDeviation()], false)];
10714
+ var row = _[0];
10715
+ this.quartiles([row[0], row[1], row[2], row[3], row[4]]);
10716
+ this.mean(row[5]);
10717
+ this.standardDeviation(row[6]);
10652
10718
  return this;
10653
10719
  };
10654
10720
  StatChart.prototype.enter = function (domNode, element) {
@@ -10656,16 +10722,17 @@ var StatChart = /** @class */ (function (_super) {
10656
10722
  _super.prototype.enter.call(this, domNode, element);
10657
10723
  this._bellCurve.target(element.append("div").node());
10658
10724
  this._candle.target(element.append("div").node());
10659
- this._selectMode = element.append("div")
10725
+ this._selectElement = element.append("div")
10660
10726
  .style("position", "absolute")
10661
10727
  .style("top", "0px")
10662
10728
  .style("right", "0px").append("select")
10663
10729
  .on("change", function () {
10664
- _this.render();
10730
+ _this.view(_this._selectElement.node().value);
10731
+ _this.lazyRender();
10665
10732
  });
10666
- this._selectMode.append("option").attr("value", "min_max").text("Min / Max");
10667
- this._selectMode.append("option").attr("value", "25_75").text("25% / 75%");
10668
- this._selectMode.append("option").attr("value", "normal").text("Normal");
10733
+ this._selectElement.append("option").attr("value", "min_max").text("Min / Max");
10734
+ this._selectElement.append("option").attr("value", "25_75").text("25% / 75%");
10735
+ this._selectElement.append("option").attr("value", "normal").text("Normal");
10669
10736
  };
10670
10737
  StatChart.prototype.bellTicks = function (mode) {
10671
10738
  var ticks;
@@ -10700,14 +10767,14 @@ var StatChart = /** @class */ (function (_super) {
10700
10767
  { label: this.formatQ(4), value: this.quartile(4) }
10701
10768
  ];
10702
10769
  }
10703
- var _a = this.domain(this._selectMode.node().value), domainLow = _a[0], domainHigh = _a[1];
10770
+ var _a = __read(this.domain(this._selectElement.node().value), 2), domainLow = _a[0], domainHigh = _a[1];
10704
10771
  return ticks
10705
10772
  .filter(function (sd) { return sd.value >= domainLow && sd.value <= domainHigh; })
10706
10773
  .map(function (sd) { return ({ label: sd.label, value: sd.value.toString() }); });
10707
10774
  };
10708
10775
  StatChart.prototype.updateScatter = function () {
10709
- var mode = this._selectMode.node().value;
10710
- var _a = this.domain(mode), domainLow = _a[0], domainHigh = _a[1];
10776
+ var mode = this._selectElement.node().value;
10777
+ var _a = __read(this.domain(mode), 2), domainLow = _a[0], domainHigh = _a[1];
10711
10778
  var padding = (domainHigh - domainLow) * (this.domainPadding() / 100);
10712
10779
  this._bellCurve
10713
10780
  .xAxisDomainLow(domainLow - padding)
@@ -10741,19 +10808,20 @@ var StatChart = /** @class */ (function (_super) {
10741
10808
  StatChart.prototype.update = function (domNode, element) {
10742
10809
  _super.prototype.update.call(this, domNode, element);
10743
10810
  this._tickFormatter = myFormatter(this.tickFormat());
10744
- if (this.data()[0] && this.data()[0].length === 7) {
10745
- this.quartiles(this.data()[0].slice(0, 5));
10746
- this.mean(this.data()[0][5]);
10747
- this.standardDeviation(this.data()[0][6]);
10748
- }
10811
+ this._selectElement.node().value = this.view();
10749
10812
  this.updateScatter();
10750
10813
  this.updateCandle();
10751
10814
  };
10752
10815
  return StatChart;
10753
10816
  }(HTMLWidget));
10817
+ StatChart.prototype._class += " chart_Stat";
10818
+ StatChart.prototype.publish("view", "min_max", "set", "View", ["min_max", "25_75", "normal"]);
10754
10819
  StatChart.prototype.publish("tickFormat", ".2e", "string", "X-Axis Tick Format");
10755
10820
  StatChart.prototype.publish("candleHeight", 20, "number", "Height of candle widget (pixels)");
10756
10821
  StatChart.prototype.publish("domainPadding", 10, "number", "Domain value padding");
10822
+ StatChart.prototype.publish("mean", .5, "number", "Mean");
10823
+ StatChart.prototype.publish("standardDeviation", .125, "number", "Standard Deviation (σ)");
10824
+ StatChart.prototype.publish("quartiles", [0, .25, .5, .75, 1], "object", "Quartiles (Min, 25%, 50%, 75%, Max)");
10757
10825
 
10758
10826
  var Step = /** @class */ (function (_super) {
10759
10827
  __extends(Step, _super);