@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.js CHANGED
@@ -5,8 +5,8 @@
5
5
  })(this, (function (exports, api, common, util) { 'use strict';
6
6
 
7
7
  var PKG_NAME = "@hpcc-js/chart";
8
- var PKG_VERSION = "2.83.4";
9
- var BUILD_VERSION = "2.105.12";
8
+ var PKG_VERSION = "2.84.1";
9
+ var BUILD_VERSION = "2.106.1";
10
10
 
11
11
  /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -50,6 +50,35 @@
50
50
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
51
51
  }
52
52
 
53
+ function __values(o) {
54
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
55
+ if (m) return m.call(o);
56
+ if (o && typeof o.length === "number") return {
57
+ next: function () {
58
+ if (o && i >= o.length) o = void 0;
59
+ return { value: o && o[i++], done: !o };
60
+ }
61
+ };
62
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
63
+ }
64
+
65
+ function __read(o, n) {
66
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
67
+ if (!m) return o;
68
+ var i = m.call(o), r, ar = [], e;
69
+ try {
70
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
71
+ }
72
+ catch (error) { e = { error: error }; }
73
+ finally {
74
+ try {
75
+ if (r && !r.done && (m = i["return"])) m.call(i);
76
+ }
77
+ finally { if (e) throw e.error; }
78
+ }
79
+ return ar;
80
+ }
81
+
53
82
  function __spreadArray(to, from, pack) {
54
83
  if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
55
84
  if (ar || !(i in from)) {
@@ -2433,12 +2462,22 @@
2433
2462
  })
2434
2463
  .merge(focusChart)
2435
2464
  .each(function () {
2465
+ var e_1, _a;
2436
2466
  context.copyPropsTo(context.focusChart, ["layers"]);
2437
2467
  var layerIdx = 0;
2438
- for (var _i = 0, _a = context.layers(); _i < _a.length; _i++) {
2439
- var layer = _a[_i];
2440
- layer.copyPropsTo(context.focusChart.layers()[layerIdx]);
2441
- layerIdx++;
2468
+ try {
2469
+ for (var _b = __values(context.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2470
+ var layer = _c.value;
2471
+ layer.copyPropsTo(context.focusChart.layers()[layerIdx]);
2472
+ layerIdx++;
2473
+ }
2474
+ }
2475
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2476
+ finally {
2477
+ try {
2478
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2479
+ }
2480
+ finally { if (e_1) throw e_1.error; }
2442
2481
  }
2443
2482
  context.focusChart
2444
2483
  .xAxisFocus(false)
@@ -2489,7 +2528,7 @@
2489
2528
  if (!retVal.length) {
2490
2529
  return masterColumns;
2491
2530
  }
2492
- return __spreadArray([masterColumns[0]], retVal, true);
2531
+ return __spreadArray([masterColumns[0]], __read(retVal), false);
2493
2532
  };
2494
2533
  XYAxis.prototype.layerColumnIndices = function (host) {
2495
2534
  var masterColumns = host.columns();
@@ -2518,24 +2557,44 @@
2518
2557
  XYAxis.prototype.layerExit = function (host, element, duration) {
2519
2558
  };
2520
2559
  XYAxis.prototype.chartsEnter = function (host, element, duration) {
2560
+ var e_2, _a;
2521
2561
  if (duration === void 0) { duration = 250; }
2522
2562
  this.layerEnter(this, element, duration);
2523
- for (var _i = 0, _a = this.layers(); _i < _a.length; _i++) {
2524
- var w = _a[_i];
2525
- w["__xyAxisElement"] = element.append("g")
2526
- .attr("class", w.class());
2527
- w
2528
- .target(w["__xyAxisElement"].node())
2529
- .layerEnter(this, element, duration);
2563
+ try {
2564
+ for (var _b = __values(this.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2565
+ var w = _c.value;
2566
+ w["__xyAxisElement"] = element.append("g")
2567
+ .attr("class", w.class());
2568
+ w
2569
+ .target(w["__xyAxisElement"].node())
2570
+ .layerEnter(this, element, duration);
2571
+ }
2572
+ }
2573
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2574
+ finally {
2575
+ try {
2576
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2577
+ }
2578
+ finally { if (e_2) throw e_2.error; }
2530
2579
  }
2531
2580
  };
2532
2581
  XYAxis.prototype.chartsUpdate = function (width, height, duration) {
2582
+ var e_3, _a;
2533
2583
  this.layerUpdate(this, this.svgData, duration);
2534
- for (var _i = 0, _a = this.layers(); _i < _a.length; _i++) {
2535
- var w = _a[_i];
2536
- w
2537
- .resize({ width: width, height: height })
2538
- .layerUpdate(this, w["__xyAxisElement"], duration);
2584
+ try {
2585
+ for (var _b = __values(this.layers()), _c = _b.next(); !_c.done; _c = _b.next()) {
2586
+ var w = _c.value;
2587
+ w
2588
+ .resize({ width: width, height: height })
2589
+ .layerUpdate(this, w["__xyAxisElement"], duration);
2590
+ }
2591
+ }
2592
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2593
+ finally {
2594
+ try {
2595
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
2596
+ }
2597
+ finally { if (e_3) throw e_3.error; }
2539
2598
  }
2540
2599
  };
2541
2600
  XYAxis.prototype.exit = function (domNode, element) {
@@ -3338,7 +3397,7 @@
3338
3397
  columnGRect.exit().transition().duration(duration)
3339
3398
  .style("opacity", 0)
3340
3399
  .remove();
3341
- var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; }));
3400
+ var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, __spreadArray([], __read(dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; })), false));
3342
3401
  var stackedTotalText = element.selectAll(".stackedTotalText").data(context.showDomainTotal() ? [domainSums[dataRowIdx]] : []);
3343
3402
  var stackedTotalTextEnter = stackedTotalText.enter().append("g")
3344
3403
  .attr("class", "stackedTotalText")
@@ -3392,6 +3451,7 @@
3392
3451
  .remove();
3393
3452
  };
3394
3453
  Column.prototype.calcInnerText = function (offset, innerText, valueText) {
3454
+ var e_1, _a;
3395
3455
  var fontFamily = this.innerTextFontFamily_exists() ? this.innerTextFontFamily() : "Verdana";
3396
3456
  var fontSize = this.innerTextFontSize();
3397
3457
  var valueFontFamily = this.valueFontFamily_exists() ? this.valueFontFamily() : "Verdana";
@@ -3418,15 +3478,24 @@
3418
3478
  else if (fullWidth2 < offset) {
3419
3479
  var excessWidth = offset - fullWidth2;
3420
3480
  var _text = "";
3421
- for (var _i = 0, innerText_1 = innerText; _i < innerText_1.length; _i++) {
3422
- var letter = innerText_1[_i];
3423
- if (this.textSize(_text + letter, fontFamily, fontSize).width > excessWidth) {
3424
- innerText = _text + "...";
3425
- break;
3481
+ try {
3482
+ for (var innerText_1 = __values(innerText), innerText_1_1 = innerText_1.next(); !innerText_1_1.done; innerText_1_1 = innerText_1.next()) {
3483
+ var letter = innerText_1_1.value;
3484
+ if (this.textSize(_text + letter, fontFamily, fontSize).width > excessWidth) {
3485
+ innerText = _text + "...";
3486
+ break;
3487
+ }
3488
+ else {
3489
+ _text += letter;
3490
+ }
3426
3491
  }
3427
- else {
3428
- _text += letter;
3492
+ }
3493
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3494
+ finally {
3495
+ try {
3496
+ if (innerText_1_1 && !innerText_1_1.done && (_a = innerText_1.return)) _a.call(innerText_1);
3429
3497
  }
3498
+ finally { if (e_1) throw e_1.error; }
3430
3499
  }
3431
3500
  category = 2;
3432
3501
  }
@@ -8808,7 +8877,7 @@
8808
8877
  this._usageArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8809
8878
  .style("fill", "green")
8810
8879
  .on("mousemove", function (d) {
8811
- var _a = _this._d3Arc.centroid(d), x = _a[0], y = _a[1];
8880
+ var _a = __read(_this._d3Arc.centroid(d), 2), x = _a[0], y = _a[1];
8812
8881
  _this.tip({ x: x, y: y, label: _this.valueDescription() });
8813
8882
  })
8814
8883
  .on("mouseout", function (d) {
@@ -8819,7 +8888,7 @@
8819
8888
  this._meanArc = element.append("path").datum({ startAngle: value2Angle(0), endAngle: value2Angle(0) })
8820
8889
  .style("fill", "black")
8821
8890
  .on("mousemove", function (d) {
8822
- var _a = _this._d3Arc.centroid(d), x = _a[0], y = _a[1];
8891
+ var _a = __read(_this._d3Arc.centroid(d), 2), x = _a[0], y = _a[1];
8823
8892
  _this.tip({ x: x, y: y, label: _this.tickValueDescription() });
8824
8893
  })
8825
8894
  .on("mouseout", function (d) {
@@ -8833,7 +8902,7 @@
8833
8902
  .style("stroke", "black")
8834
8903
  .attr("d", "M 0 0 l -3 -3 l 6 0 z")
8835
8904
  .on("mousemove", function (d) {
8836
- var _a = context._d3Arc.centroid(context._meanArc.datum()), x = _a[0], y = _a[1];
8905
+ var _a = __read(context._d3Arc.centroid(context._meanArc.datum()), 2), x = _a[0], y = _a[1];
8837
8906
  context.tip({ x: x, y: y, label: context.tickValueDescription() });
8838
8907
  })
8839
8908
  .on("mouseout", function (d) {
@@ -9120,7 +9189,7 @@
9120
9189
  .padRadius(outerRadius)
9121
9190
  .outerRadius(outerRadius);
9122
9191
  this._quadIdxArr = [[], [], [], []];
9123
- var data = __spreadArray([], this.data(), true).sort(function (a, b) {
9192
+ var data = __spreadArray([], __read(this.data()), false).sort(function (a, b) {
9124
9193
  return a[1] - b[1] > 0 ? -1 : 1;
9125
9194
  });
9126
9195
  var arc = this._slices.selectAll(".arc").data(this.d3Pie(data), function (d) { return d.data[0]; });
@@ -9214,7 +9283,7 @@
9214
9283
  .attr("points", function (d, i) {
9215
9284
  var pos = context.d3LabelArc.centroid(d);
9216
9285
  var pos1 = context.d3Arc.centroid(d);
9217
- var pos2 = __spreadArray([], pos, true);
9286
+ var pos2 = __spreadArray([], __read(pos), false);
9218
9287
  pos[0] = labelRadius * (context.isLeftSide(midAngle(d)) ? 1 : -1);
9219
9288
  pos[1] = context._labelPositions[i].top;
9220
9289
  return [pos1, pos2, pos];
@@ -9431,7 +9500,7 @@
9431
9500
  var data = host.orientation() === "horizontal" ?
9432
9501
  this.data().map(function (r) { return [host.dataPos(r[0]), host.valuePos(r[1]), r[2]]; }) :
9433
9502
  this.data().map(function (r) { return [host.valuePos(r[1]), host.dataPos(r[0]), r[2]]; });
9434
- var maxWeight = common.max(data, function (r) { return r[2]; });
9503
+ var maxWeight = this.maxWeight_exists() ? this.maxWeight() : common.max(data, function (r) { return r[2]; });
9435
9504
  if (this.paletteID() !== "default") {
9436
9505
  var gradient = {};
9437
9506
  var count = 8;
@@ -9465,6 +9534,7 @@
9465
9534
  Heat.prototype.publish("radiusY", 25, "number", "Point Y radius (25 by default)");
9466
9535
  Heat.prototype.publish("radiusAsPercent", false, "boolean", "Calculate RadiusX + RadiusY as % of size");
9467
9536
  Heat.prototype.publish("blur", 15, "number", "Point blur radius (15 by default)");
9537
+ Heat.prototype.publish("maxWeight", undefined, "number", "Clamp max weight to value (optional), omitting uses max data point", undefined, { optional: true });
9468
9538
  Heat.prototype.publish("minOpacity", 0.05, "number", "Minimum point opacity (0.05 by default)");
9469
9539
  // The following code is a modified version of
9470
9540
  // - https://github.com/mourner/simpleheat
@@ -9553,6 +9623,12 @@
9553
9623
  // draw a grayscale heatmap by putting a blurred ellipse at each data point
9554
9624
  for (var i = 0, len = this._data.length, p = void 0; i < len; i++) {
9555
9625
  p = this._data[i];
9626
+ if (p[2] < 0) {
9627
+ p[2] = 0;
9628
+ }
9629
+ else if (p[2] > this._max) {
9630
+ p[2] = this._max;
9631
+ }
9556
9632
  ctx.globalAlpha = Math.max(p[2] / this._max, minOpacity === undefined ? 0.05 : minOpacity);
9557
9633
  ctx.drawImage(this._ellipse, p[0] - this._r, p[1] - this._r);
9558
9634
  }
@@ -10443,7 +10519,7 @@
10443
10519
  var _this = this;
10444
10520
  _super.prototype.update.call(this, domNode, element);
10445
10521
  var context = this;
10446
- var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], this.data().map(function (d) { return d[1]; }), false));
10522
+ var maxValue = Math.max.apply(Math, __spreadArray([this.valueDomainHigh_exists() ? this.valueDomainHigh() : 0], __read(this.data().map(function (d) { return d[1]; })), false));
10447
10523
  this._valueScale
10448
10524
  .domain([0, maxValue])
10449
10525
  .range([0, this.radians(this.valueMaxAngle())]);
@@ -10577,7 +10653,7 @@
10577
10653
  var StatChart = /** @class */ (function (_super) {
10578
10654
  __extends(StatChart, _super);
10579
10655
  function StatChart() {
10580
- var _this = _super !== null && _super.apply(this, arguments) || this;
10656
+ var _this = _super.call(this) || this;
10581
10657
  _this._bellCurve = new Scatter()
10582
10658
  .columns(["", "Std. Dev."])
10583
10659
  .paletteID("Quartile")
@@ -10601,6 +10677,8 @@
10601
10677
  .valueFontSize(0)
10602
10678
  .lineColor(rainbow(90, 0, 100))
10603
10679
  .innerRectColor(rainbow(10, 0, 100));
10680
+ _this
10681
+ .columns(["Min", "25%", "50%", "75%", "Max", "Mean", "Std. Dev."]);
10604
10682
  return _this;
10605
10683
  }
10606
10684
  StatChart.prototype.stdDev = function (degrees) {
@@ -10610,7 +10688,7 @@
10610
10688
  return this._tickFormatter(this.stdDev(degrees));
10611
10689
  };
10612
10690
  StatChart.prototype.quartile = function (q) {
10613
- return this.data()[0][q];
10691
+ return this.quartiles()[q];
10614
10692
  };
10615
10693
  StatChart.prototype.formatQ = function (q) {
10616
10694
  return this._tickFormatter(this.quartile(q));
@@ -10626,31 +10704,19 @@
10626
10704
  return [this.quartile(0), this.quartile(4)];
10627
10705
  }
10628
10706
  };
10629
- StatChart.prototype.mean = function (_) {
10630
- if (!arguments.length)
10631
- return this._mean;
10632
- this._mean = _;
10633
- if (this.data()[0]) {
10634
- this.data()[0][5] = _;
10635
- }
10636
- return this;
10707
+ StatChart.prototype.min = function () {
10708
+ return this.quartile(0);
10637
10709
  };
10638
- StatChart.prototype.standardDeviation = function (_) {
10639
- if (!arguments.length)
10640
- return this._standardDeviation;
10641
- this._standardDeviation = _;
10642
- if (this.data()[0]) {
10643
- this.data()[0][6] = _;
10644
- }
10645
- return this;
10710
+ StatChart.prototype.max = function () {
10711
+ return this.quartile(4);
10646
10712
  };
10647
- StatChart.prototype.quartiles = function (_) {
10713
+ StatChart.prototype.data = function (_) {
10648
10714
  if (!arguments.length)
10649
- return this._quartiles;
10650
- this._quartiles = _;
10651
- if (this.data()[0]) {
10652
- this.data()[0] = _.concat(this.data()[0].slice(-2));
10653
- }
10715
+ return [__spreadArray(__spreadArray([], __read(this.quartiles()), false), [this.mean(), this.standardDeviation()], false)];
10716
+ var row = _[0];
10717
+ this.quartiles([row[0], row[1], row[2], row[3], row[4]]);
10718
+ this.mean(row[5]);
10719
+ this.standardDeviation(row[6]);
10654
10720
  return this;
10655
10721
  };
10656
10722
  StatChart.prototype.enter = function (domNode, element) {
@@ -10658,16 +10724,17 @@
10658
10724
  _super.prototype.enter.call(this, domNode, element);
10659
10725
  this._bellCurve.target(element.append("div").node());
10660
10726
  this._candle.target(element.append("div").node());
10661
- this._selectMode = element.append("div")
10727
+ this._selectElement = element.append("div")
10662
10728
  .style("position", "absolute")
10663
10729
  .style("top", "0px")
10664
10730
  .style("right", "0px").append("select")
10665
10731
  .on("change", function () {
10666
- _this.render();
10732
+ _this.view(_this._selectElement.node().value);
10733
+ _this.lazyRender();
10667
10734
  });
10668
- this._selectMode.append("option").attr("value", "min_max").text("Min / Max");
10669
- this._selectMode.append("option").attr("value", "25_75").text("25% / 75%");
10670
- this._selectMode.append("option").attr("value", "normal").text("Normal");
10735
+ this._selectElement.append("option").attr("value", "min_max").text("Min / Max");
10736
+ this._selectElement.append("option").attr("value", "25_75").text("25% / 75%");
10737
+ this._selectElement.append("option").attr("value", "normal").text("Normal");
10671
10738
  };
10672
10739
  StatChart.prototype.bellTicks = function (mode) {
10673
10740
  var ticks;
@@ -10702,14 +10769,14 @@
10702
10769
  { label: this.formatQ(4), value: this.quartile(4) }
10703
10770
  ];
10704
10771
  }
10705
- var _a = this.domain(this._selectMode.node().value), domainLow = _a[0], domainHigh = _a[1];
10772
+ var _a = __read(this.domain(this._selectElement.node().value), 2), domainLow = _a[0], domainHigh = _a[1];
10706
10773
  return ticks
10707
10774
  .filter(function (sd) { return sd.value >= domainLow && sd.value <= domainHigh; })
10708
10775
  .map(function (sd) { return ({ label: sd.label, value: sd.value.toString() }); });
10709
10776
  };
10710
10777
  StatChart.prototype.updateScatter = function () {
10711
- var mode = this._selectMode.node().value;
10712
- var _a = this.domain(mode), domainLow = _a[0], domainHigh = _a[1];
10778
+ var mode = this._selectElement.node().value;
10779
+ var _a = __read(this.domain(mode), 2), domainLow = _a[0], domainHigh = _a[1];
10713
10780
  var padding = (domainHigh - domainLow) * (this.domainPadding() / 100);
10714
10781
  this._bellCurve
10715
10782
  .xAxisDomainLow(domainLow - padding)
@@ -10743,19 +10810,20 @@
10743
10810
  StatChart.prototype.update = function (domNode, element) {
10744
10811
  _super.prototype.update.call(this, domNode, element);
10745
10812
  this._tickFormatter = myFormatter(this.tickFormat());
10746
- if (this.data()[0] && this.data()[0].length === 7) {
10747
- this.quartiles(this.data()[0].slice(0, 5));
10748
- this.mean(this.data()[0][5]);
10749
- this.standardDeviation(this.data()[0][6]);
10750
- }
10813
+ this._selectElement.node().value = this.view();
10751
10814
  this.updateScatter();
10752
10815
  this.updateCandle();
10753
10816
  };
10754
10817
  return StatChart;
10755
10818
  }(common.HTMLWidget));
10819
+ StatChart.prototype._class += " chart_Stat";
10820
+ StatChart.prototype.publish("view", "min_max", "set", "View", ["min_max", "25_75", "normal"]);
10756
10821
  StatChart.prototype.publish("tickFormat", ".2e", "string", "X-Axis Tick Format");
10757
10822
  StatChart.prototype.publish("candleHeight", 20, "number", "Height of candle widget (pixels)");
10758
10823
  StatChart.prototype.publish("domainPadding", 10, "number", "Domain value padding");
10824
+ StatChart.prototype.publish("mean", .5, "number", "Mean");
10825
+ StatChart.prototype.publish("standardDeviation", .125, "number", "Standard Deviation (σ)");
10826
+ StatChart.prototype.publish("quartiles", [0, .25, .5, .75, 1], "object", "Quartiles (Min, 25%, 50%, 75%, Max)");
10759
10827
 
10760
10828
  var Step = /** @class */ (function (_super) {
10761
10829
  __extends(Step, _super);