@hpcc-js/chart 2.81.10 → 2.82.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 +73 -26
- package/dist/index.es6.js.map +1 -1
- package/dist/index.js +73 -26
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/package.json +2 -2
- package/src/Column.ts +78 -27
- package/src/__package__.ts +2 -2
- package/src/test.ts +41 -4
- package/types/Column.d.ts +3 -0
- package/types/Column.d.ts.map +1 -1
- package/types/__package__.d.ts +2 -2
- package/types/__package__.d.ts.map +1 -1
- package/types/test.d.ts +5 -1
- package/types/test.d.ts.map +1 -1
- package/types-3.4/Column.d.ts +3 -0
- package/types-3.4/__package__.d.ts +2 -2
- package/types-3.4/test.d.ts +5 -1
package/dist/index.es6.js
CHANGED
|
@@ -3,8 +3,8 @@ import { select, scaleTime, timeParse, timeFormat, scaleLog, format, scalePow, s
|
|
|
3
3
|
import { normalizeRadians, degreesToRadians } from '@hpcc-js/util';
|
|
4
4
|
|
|
5
5
|
var PKG_NAME = "@hpcc-js/chart";
|
|
6
|
-
var PKG_VERSION = "2.
|
|
7
|
-
var BUILD_VERSION = "2.
|
|
6
|
+
var PKG_VERSION = "2.82.0";
|
|
7
|
+
var BUILD_VERSION = "2.105.0";
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
10
10
|
Copyright (c) Microsoft Corporation.
|
|
@@ -2932,6 +2932,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
2932
2932
|
function Column() {
|
|
2933
2933
|
var _this = _super.call(this) || this;
|
|
2934
2934
|
_this.textLocal = local();
|
|
2935
|
+
_this.stackedTextLocal = local();
|
|
2935
2936
|
INDChart.call(_this);
|
|
2936
2937
|
ITooltip.call(_this);
|
|
2937
2938
|
_this._selection.skipBringToTop(true);
|
|
@@ -3012,30 +3013,26 @@ var Column = /** @class */ (function (_super) {
|
|
|
3012
3013
|
.rangeRound(isHorizontal ? [0, dataLen] : [dataLen, 0])
|
|
3013
3014
|
.paddingInner(this.xAxisSeriesPaddingInner())
|
|
3014
3015
|
.paddingOuter(0);
|
|
3015
|
-
var rowData = this.adjustedData(host);
|
|
3016
3016
|
var domainSums = [];
|
|
3017
3017
|
var seriesSums = [];
|
|
3018
3018
|
var columnLength = this.columns().length;
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
});
|
|
3037
|
-
break;
|
|
3038
|
-
}
|
|
3019
|
+
var rowData = this.data();
|
|
3020
|
+
if (this.showValue() && this.showValueAsPercent() === "series") {
|
|
3021
|
+
rowData.forEach(function (row) {
|
|
3022
|
+
row.filter(function (_, idx) { return idx > 0 && idx < columnLength; }).forEach(function (col, idx) {
|
|
3023
|
+
if (seriesSums[idx + 1] === undefined) {
|
|
3024
|
+
seriesSums[idx + 1] = 0;
|
|
3025
|
+
}
|
|
3026
|
+
seriesSums[idx + 1] += col;
|
|
3027
|
+
});
|
|
3028
|
+
});
|
|
3029
|
+
}
|
|
3030
|
+
if (this.showDomainTotal() || (this.showValue() && this.showValueAsPercent() === "domain")) {
|
|
3031
|
+
domainSums = rowData.map(function (row) {
|
|
3032
|
+
return row.filter(function (cell, idx) { return idx > 0 && idx < columnLength; }).reduce(function (sum, cell) {
|
|
3033
|
+
return sum + cell;
|
|
3034
|
+
}, 0);
|
|
3035
|
+
});
|
|
3039
3036
|
}
|
|
3040
3037
|
var column = element.selectAll(".dataRow")
|
|
3041
3038
|
.data(this.adjustedData(host));
|
|
@@ -3100,7 +3097,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
3100
3097
|
valueText = format(context.showValueAsPercentFormat())(valueText / seriesSum);
|
|
3101
3098
|
break;
|
|
3102
3099
|
case "domain":
|
|
3103
|
-
var domainSum = typeof dm.sum !== "undefined" ? dm.sum : domainSums[d.idx];
|
|
3100
|
+
var domainSum = typeof dm.sum !== "undefined" ? dm.sum : domainSums[d.idx - 1];
|
|
3104
3101
|
valueText = format(context.showValueAsPercentFormat())(valueText / domainSum);
|
|
3105
3102
|
break;
|
|
3106
3103
|
case null:
|
|
@@ -3231,7 +3228,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
3231
3228
|
...then ASSUME THERES ROOM ON THE OPPOSITE SIDE
|
|
3232
3229
|
*/
|
|
3233
3230
|
if (isHorizontal) { // Column
|
|
3234
|
-
noRoomInside = dataRect.height < textSize.height;
|
|
3231
|
+
noRoomInside = context.yAxisStacked() ? false : dataRect.height < textSize.height;
|
|
3235
3232
|
isOutside = !context.valueCentered() || noRoomInside;
|
|
3236
3233
|
pos.x = dataRect.x + (dataRect.width / 2);
|
|
3237
3234
|
if (isOutside) {
|
|
@@ -3271,7 +3268,7 @@ var Column = /** @class */ (function (_super) {
|
|
|
3271
3268
|
}
|
|
3272
3269
|
}
|
|
3273
3270
|
else { // Bar
|
|
3274
|
-
noRoomInside = dataRect.width < textSize.width;
|
|
3271
|
+
noRoomInside = context.yAxisStacked() ? false : dataRect.width < textSize.width;
|
|
3275
3272
|
isOutside = !context.valueCentered() || noRoomInside;
|
|
3276
3273
|
pos.y = dataRect.y + (dataRect.height / 2);
|
|
3277
3274
|
if (isOutside) {
|
|
@@ -3334,6 +3331,55 @@ var Column = /** @class */ (function (_super) {
|
|
|
3334
3331
|
columnGRect.exit().transition().duration(duration)
|
|
3335
3332
|
.style("opacity", 0)
|
|
3336
3333
|
.remove();
|
|
3334
|
+
var value4pos = host.yAxisStacked() ? domainSums[dataRowIdx] : Math.max.apply(Math, dataRow.filter(function (_, idx) { return idx > 0 && idx < columnLength; }));
|
|
3335
|
+
var stackedTotalText = element.selectAll(".stackedTotalText").data(context.showDomainTotal() ? [domainSums[dataRowIdx]] : []);
|
|
3336
|
+
var stackedTotalTextEnter = stackedTotalText.enter().append("g")
|
|
3337
|
+
.attr("class", "stackedTotalText")
|
|
3338
|
+
.each(function (d) {
|
|
3339
|
+
context.stackedTextLocal.set(this, new Text().target(this).colorStroke_default("transparent"));
|
|
3340
|
+
});
|
|
3341
|
+
stackedTotalTextEnter.merge(stackedTotalText)
|
|
3342
|
+
.each(function (d) {
|
|
3343
|
+
var pos = { x: 0, y: 0 };
|
|
3344
|
+
var domainPos = host.dataPos(dataRow[0]);
|
|
3345
|
+
var valuePos = host.valuePos(value4pos);
|
|
3346
|
+
var valueFontFamily = context.valueFontFamily();
|
|
3347
|
+
var valueFontSize = context.valueFontSize();
|
|
3348
|
+
var textSize = context.textSize(d, valueFontFamily, valueFontSize);
|
|
3349
|
+
var isPositive = parseFloat(d) >= 0;
|
|
3350
|
+
var valueAnchor = "middle";
|
|
3351
|
+
if (isHorizontal) {
|
|
3352
|
+
pos.x = domainPos;
|
|
3353
|
+
if (isPositive) {
|
|
3354
|
+
pos.y = valuePos - textSize.height / 2;
|
|
3355
|
+
}
|
|
3356
|
+
else {
|
|
3357
|
+
pos.y = valuePos + textSize.height / 2;
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
else {
|
|
3361
|
+
valueAnchor = "start";
|
|
3362
|
+
pos.y = domainPos;
|
|
3363
|
+
if (isPositive) {
|
|
3364
|
+
pos.x = valuePos + textSize.width / 2;
|
|
3365
|
+
}
|
|
3366
|
+
else {
|
|
3367
|
+
pos.x = valuePos - textSize.width / 2;
|
|
3368
|
+
}
|
|
3369
|
+
}
|
|
3370
|
+
context.stackedTextLocal.get(this)
|
|
3371
|
+
.pos(pos)
|
|
3372
|
+
.anchor(valueAnchor)
|
|
3373
|
+
.fontFamily(valueFontFamily)
|
|
3374
|
+
.fontSize(valueFontSize)
|
|
3375
|
+
.text(d)
|
|
3376
|
+
.render();
|
|
3377
|
+
});
|
|
3378
|
+
stackedTotalText.exit()
|
|
3379
|
+
.each(function (d) {
|
|
3380
|
+
context.textLocal.get(this).target(null);
|
|
3381
|
+
})
|
|
3382
|
+
.remove();
|
|
3337
3383
|
});
|
|
3338
3384
|
column.exit().transition().duration(duration)
|
|
3339
3385
|
.remove();
|
|
@@ -3420,6 +3466,7 @@ Column.prototype.publish("showInnerText", false, "boolean", "Show Label in colum
|
|
|
3420
3466
|
Column.prototype.publish("showValueFormat", ",", "string", "D3 Format for Value", null, { disable: function (w) { return !w.showValue() || !!w.showValueAsPercent(); } });
|
|
3421
3467
|
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 });
|
|
3422
3468
|
Column.prototype.publish("showValueAsPercentFormat", ".0%", "string", "D3 Format for %", null, { disable: function (w) { return !w.showValue() || !w.showValueAsPercent(); } });
|
|
3469
|
+
Column.prototype.publish("showDomainTotal", false, "boolean", "Show Total Value for Stacked Columns", null);
|
|
3423
3470
|
Column.prototype.publish("valueCentered", false, "boolean", "Show Value in center of column");
|
|
3424
3471
|
Column.prototype.publish("valueAnchor", "middle", "set", "text-anchor for shown value text", ["start", "middle", "end"]);
|
|
3425
3472
|
Column.prototype.publish("xAxisSeriesPaddingInner", 0, "number", "Determines the ratio of the range that is reserved for blank space between band (0->1)");
|