@hpcc-js/chart 2.81.10 → 2.83.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.81.10";
9
- var BUILD_VERSION = "2.104.37";
8
+ var PKG_VERSION = "2.83.1";
9
+ var BUILD_VERSION = "2.105.2";
10
10
 
11
11
  /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -1894,7 +1894,7 @@
1894
1894
  this.svg.style("display", this.hidden() ? "none" : null);
1895
1895
  var overlap = this.calcOverflow(element);
1896
1896
  var lowerPos = this.isHorizontal() ? overlap.left : this.height() - overlap.top - overlap.bottom;
1897
- var upperPos = this.isHorizontal() ? this.width() - overlap.right : 0;
1897
+ var upperPos = this.isHorizontal() ? this.width() - overlap.right - this.padding() : 0 + this.padding();
1898
1898
  this.range(this.reverse() ? [upperPos, lowerPos] : [lowerPos, upperPos]);
1899
1899
  var context = this;
1900
1900
  function doPosition(element) {
@@ -2022,6 +2022,7 @@
2022
2022
  Axis.prototype.publish("ordinalPaddingInner", 0.1, "number", "Determines the ratio of the range that is reserved for blank space between band (0->1)", null, { disable: function (w) { return w.type() !== "ordinal"; } });
2023
2023
  Axis.prototype.publish("ordinalPaddingOuter", 0.1, "number", "Determines the ratio of the range that is reserved for blank space before the first band and after the last band (0->1)", null, { disable: function (w) { return w.type() !== "ordinal"; } });
2024
2024
  Axis.prototype.publish("ordinalMappings", null, "object", "Alternative label mappings (icons)", null, { optional: true });
2025
+ Axis.prototype.publish("padding", 0, "number", "Padding space at top of axis (pixels)", null, { optional: true });
2025
2026
 
2026
2027
  var css_248z$b = ".chart_XYAxis .axis{fill:#000}.chart_XYAxis .axis,.chart_XYAxis .tick>text{font:10px sans-serif}.chart_XYAxis .focus .chart_Axis.value .tick{visibility:hidden}.chart_XYAxis .axis line,.chart_XYAxis .axis path{fill:none;stroke:#000;shape-rendering:crispEdges}.chart_XYAxis .region{opacity:.33}.chart_XYAxis .brush rect.background{z-index:-999}.chart_XYAxis .brush .selection{stroke:#4682b4;stroke-opacity:1;stroke-width:1px;fill:#4682b4;fill-opacity:.125;shape-rendering:crispEdges}.chart_XYAxis .brush path.handle--custom{fill:#eee;stroke:#666}";
2027
2028
  styleInject(css_248z$b);
@@ -2615,6 +2616,8 @@
2615
2616
  XYAxis.prototype.publishProxy("yAxisHidden", "valueAxis", "hidden");
2616
2617
  XYAxis.prototype.publish("regions", [], "array", "Regions");
2617
2618
  XYAxis.prototype.publish("layers", [], "widgetArray", "Layers", null, { render: false });
2619
+ XYAxis.prototype.publishProxy("xAxisPadding", "domainAxis", "padding");
2620
+ XYAxis.prototype.publishProxy("yAxisPadding", "valueAxis", "padding");
2618
2621
 
2619
2622
  var css_248z$a = ".chart_Scatter .area,.chart_Scatter .line,.chart_Scatter .pointShape{pointer-events:none}.chart_Scatter .point .pointSelection{fill:none;stroke:none;pointer-events:all}.chart_Scatter .point .pointSelection.selected{fill:none;stroke:red}";
2620
2623
  styleInject(css_248z$a);
@@ -2934,6 +2937,7 @@
2934
2937
  function Column() {
2935
2938
  var _this = _super.call(this) || this;
2936
2939
  _this.textLocal = common.local();
2940
+ _this.stackedTextLocal = common.local();
2937
2941
  api.INDChart.call(_this);
2938
2942
  api.ITooltip.call(_this);
2939
2943
  _this._selection.skipBringToTop(true);
@@ -2995,6 +2999,7 @@
2995
2999
  if (this.useClonedPalette()) {
2996
3000
  this._palette = this._palette.cloneNotExists(this.paletteID() + "_" + this.id());
2997
3001
  }
3002
+ var formatPct = common.format(context.showValueAsPercentFormat());
2998
3003
  var dataLen = 10;
2999
3004
  var offset = 0;
3000
3005
  switch (host.xAxisType()) {
@@ -3014,30 +3019,26 @@
3014
3019
  .rangeRound(isHorizontal ? [0, dataLen] : [dataLen, 0])
3015
3020
  .paddingInner(this.xAxisSeriesPaddingInner())
3016
3021
  .paddingOuter(0);
3017
- var rowData = this.adjustedData(host);
3018
3022
  var domainSums = [];
3019
3023
  var seriesSums = [];
3020
3024
  var columnLength = this.columns().length;
3021
- if (this.showValue()) {
3022
- switch (this.showValueAsPercent()) {
3023
- case "series":
3024
- rowData.forEach(function (row) {
3025
- row.filter(function (_, idx) { return idx > 0 && idx < columnLength; }).forEach(function (col, idx) {
3026
- if (seriesSums[idx + 1] === undefined) {
3027
- seriesSums[idx + 1] = 0;
3028
- }
3029
- seriesSums[idx + 1] += col;
3030
- });
3031
- });
3032
- break;
3033
- case "domain":
3034
- domainSums = rowData.map(function (row) {
3035
- return row.filter(function (cell, idx) { return idx > 0 && idx < columnLength; }).reduce(function (sum, cell) {
3036
- return sum + cell;
3037
- }, 0);
3038
- });
3039
- break;
3040
- }
3025
+ var rowData = this.data();
3026
+ if (this.showValue() && this.showValueAsPercent() === "series") {
3027
+ rowData.forEach(function (row) {
3028
+ row.filter(function (_, idx) { return idx > 0 && idx < columnLength; }).forEach(function (col, idx) {
3029
+ if (seriesSums[idx + 1] === undefined) {
3030
+ seriesSums[idx + 1] = 0;
3031
+ }
3032
+ seriesSums[idx + 1] += col;
3033
+ });
3034
+ });
3035
+ }
3036
+ if (this.showDomainTotal() || (this.showValue() && this.showValueAsPercent() === "domain")) {
3037
+ domainSums = rowData.map(function (row) {
3038
+ return row.filter(function (cell, idx) { return idx > 0 && idx < columnLength; }).reduce(function (sum, cell) {
3039
+ return sum + cell;
3040
+ }, 0);
3041
+ });
3041
3042
  }
3042
3043
  var column = element.selectAll(".dataRow")
3043
3044
  .data(this.adjustedData(host));
@@ -3099,11 +3100,11 @@
3099
3100
  switch (context.showValueAsPercent()) {
3100
3101
  case "series":
3101
3102
  var seriesSum = typeof dm.sum !== "undefined" ? dm.sum : seriesSums[d.idx];
3102
- valueText = common.format(context.showValueAsPercentFormat())(valueText / seriesSum);
3103
+ valueText = formatPct(valueText / seriesSum);
3103
3104
  break;
3104
3105
  case "domain":
3105
- var domainSum = typeof dm.sum !== "undefined" ? dm.sum : domainSums[d.idx];
3106
- valueText = common.format(context.showValueAsPercentFormat())(valueText / domainSum);
3106
+ var domainSum = typeof dm.sum !== "undefined" ? dm.sum : domainSums[dataRowIdx];
3107
+ valueText = formatPct(valueText / domainSum);
3107
3108
  break;
3108
3109
  case null:
3109
3110
  default:
@@ -3316,7 +3317,8 @@
3316
3317
  var textColor = isOutside ? null : context.textColor(d.row, d.column, d.value, d.origRow);
3317
3318
  // Prevent overlapping labels on stacked columns
3318
3319
  var columns = context.columns();
3319
- var hideValue = isOutside && context.yAxisStacked() && columns.indexOf(d.column) !== columns.length - 1;
3320
+ var hideValue = (context.yAxisStacked() && noRoomInside) ||
3321
+ (isOutside && context.yAxisStacked() && columns.indexOf(d.column) !== columns.length - 1);
3320
3322
  context.textLocal.get(this)
3321
3323
  .pos(pos)
3322
3324
  .anchor(valueAnchor)
@@ -3336,6 +3338,55 @@
3336
3338
  columnGRect.exit().transition().duration(duration)
3337
3339
  .style("opacity", 0)
3338
3340
  .remove();
3341
+ var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; }));
3342
+ var stackedTotalText = element.selectAll(".stackedTotalText").data(context.showDomainTotal() ? [domainSums[dataRowIdx]] : []);
3343
+ var stackedTotalTextEnter = stackedTotalText.enter().append("g")
3344
+ .attr("class", "stackedTotalText")
3345
+ .each(function (d) {
3346
+ context.stackedTextLocal.set(this, new common.Text().target(this).colorStroke_default("transparent"));
3347
+ });
3348
+ stackedTotalTextEnter.merge(stackedTotalText)
3349
+ .each(function (d) {
3350
+ var pos = { x: 0, y: 0 };
3351
+ var domainPos = host.dataPos(dataRow[0]);
3352
+ var valuePos = host.valuePos(value4pos);
3353
+ var valueFontFamily = context.valueFontFamily();
3354
+ var valueFontSize = context.valueFontSize();
3355
+ var textSize = context.textSize(d, valueFontFamily, valueFontSize);
3356
+ var isPositive = parseFloat(d) >= 0;
3357
+ var valueAnchor = "middle";
3358
+ if (isHorizontal) {
3359
+ pos.x = domainPos;
3360
+ if (isPositive) {
3361
+ pos.y = valuePos - textSize.height / 2;
3362
+ }
3363
+ else {
3364
+ pos.y = valuePos + textSize.height / 2;
3365
+ }
3366
+ }
3367
+ else {
3368
+ valueAnchor = "start";
3369
+ pos.y = domainPos;
3370
+ if (isPositive) {
3371
+ pos.x = valuePos + textSize.width / 2;
3372
+ }
3373
+ else {
3374
+ pos.x = valuePos - textSize.width / 2;
3375
+ }
3376
+ }
3377
+ context.stackedTextLocal.get(this)
3378
+ .pos(pos)
3379
+ .anchor(valueAnchor)
3380
+ .fontFamily(valueFontFamily)
3381
+ .fontSize(valueFontSize)
3382
+ .text(d)
3383
+ .render();
3384
+ });
3385
+ stackedTotalText.exit()
3386
+ .each(function (d) {
3387
+ context.textLocal.get(this).target(null);
3388
+ })
3389
+ .remove();
3339
3390
  });
3340
3391
  column.exit().transition().duration(duration)
3341
3392
  .remove();
@@ -3422,6 +3473,7 @@
3422
3473
  Column.prototype.publish("showValueFormat", ",", "string", "D3 Format for Value", null, { disable: function (w) { return !w.showValue() || !!w.showValueAsPercent(); } });
3423
3474
  Column.prototype.publish("showValueAsPercent", null, "set", "If showValue is true, optionally show value as a percentage by Series or Domain", [null, "series", "domain"], { disable: function (w) { return !w.showValue(); }, optional: true });
3424
3475
  Column.prototype.publish("showValueAsPercentFormat", ".0%", "string", "D3 Format for %", null, { disable: function (w) { return !w.showValue() || !w.showValueAsPercent(); } });
3476
+ Column.prototype.publish("showDomainTotal", false, "boolean", "Show Total Value for Stacked Columns", null);
3425
3477
  Column.prototype.publish("valueCentered", false, "boolean", "Show Value in center of column");
3426
3478
  Column.prototype.publish("valueAnchor", "middle", "set", "text-anchor for shown value text", ["start", "middle", "end"]);
3427
3479
  Column.prototype.publish("xAxisSeriesPaddingInner", 0, "number", "Determines the ratio of the range that is reserved for blank space between band (0->1)");