@websy/websy-designs 1.4.37 → 1.5.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/websy-designs-es6.debug.js +233 -90
- package/dist/websy-designs-es6.js +242 -88
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +233 -90
- package/dist/websy-designs.js +242 -88
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
|
@@ -7182,6 +7182,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7182
7182
|
lineWidth: 2,
|
|
7183
7183
|
forceZero: true,
|
|
7184
7184
|
grouping: 'grouped',
|
|
7185
|
+
groupPadding: 3,
|
|
7185
7186
|
fontSize: 14,
|
|
7186
7187
|
symbolSize: 20,
|
|
7187
7188
|
showTrackingLine: true,
|
|
@@ -7190,7 +7191,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7190
7191
|
legendPosition: 'bottom',
|
|
7191
7192
|
tooltipWidth: 200,
|
|
7192
7193
|
brushHeight: 50,
|
|
7193
|
-
minBandWidth: 30
|
|
7194
|
+
minBandWidth: 30,
|
|
7195
|
+
allowUnevenBands: true
|
|
7194
7196
|
};
|
|
7195
7197
|
this.elementId = elementId;
|
|
7196
7198
|
this.options = _extends({}, DEFAULTS, options);
|
|
@@ -7221,24 +7223,39 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7221
7223
|
}
|
|
7222
7224
|
|
|
7223
7225
|
xAxis += 'Axis';
|
|
7224
|
-
|
|
7225
|
-
var width = _this42[xAxis].step();
|
|
7226
|
-
|
|
7227
7226
|
var output;
|
|
7228
7227
|
|
|
7229
|
-
var
|
|
7228
|
+
var width = _this42.options.data[xAxis.replace('Brush', '').replace('Axis', '')].bandWidth;
|
|
7230
7229
|
|
|
7231
|
-
if (_this42.
|
|
7232
|
-
|
|
7233
|
-
|
|
7230
|
+
if (_this42.customBottomRange) {
|
|
7231
|
+
for (var index = 0; index < _this42.customBottomRange.length; index++) {
|
|
7232
|
+
if (input > _this42.customBottomRange[index]) {
|
|
7233
|
+
if (_this42.customBottomRange[index + 1]) {
|
|
7234
|
+
if (input < _this42.customBottomRange[index + 1]) {
|
|
7235
|
+
output = index;
|
|
7236
|
+
break;
|
|
7237
|
+
}
|
|
7238
|
+
} else {
|
|
7239
|
+
output = index;
|
|
7240
|
+
break;
|
|
7241
|
+
}
|
|
7242
|
+
}
|
|
7243
|
+
}
|
|
7244
|
+
} else {
|
|
7245
|
+
var domain = _toConsumableArray(_this42[xAxis].domain());
|
|
7234
7246
|
|
|
7235
|
-
|
|
7236
|
-
|
|
7237
|
-
|
|
7247
|
+
if (_this42.options.orientation === 'horizontal') {
|
|
7248
|
+
domain = domain.reverse();
|
|
7249
|
+
}
|
|
7238
7250
|
|
|
7239
|
-
|
|
7240
|
-
|
|
7241
|
-
|
|
7251
|
+
for (var j = 0; j < domain.length; j++) {
|
|
7252
|
+
var breakA = _this42[xAxis](domain[j]) - width / 2;
|
|
7253
|
+
var breakB = breakA + width;
|
|
7254
|
+
|
|
7255
|
+
if (input > breakA && input <= breakB) {
|
|
7256
|
+
output = j;
|
|
7257
|
+
break;
|
|
7258
|
+
}
|
|
7242
7259
|
}
|
|
7243
7260
|
}
|
|
7244
7261
|
|
|
@@ -7258,6 +7275,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7258
7275
|
xAxisCaps = 'Left';
|
|
7259
7276
|
}
|
|
7260
7277
|
|
|
7278
|
+
if (!that["".concat(xAxis, "Axis")]) {
|
|
7279
|
+
return;
|
|
7280
|
+
}
|
|
7281
|
+
|
|
7261
7282
|
if (!that["".concat(xAxis, "Axis")].invert) {
|
|
7262
7283
|
that["".concat(xAxis, "Axis")].invert = that.invertOverride;
|
|
7263
7284
|
}
|
|
@@ -7318,6 +7339,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7318
7339
|
|
|
7319
7340
|
this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
|
|
7320
7341
|
this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
|
|
7342
|
+
this.errorContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_errorContainer")).attr('class', 'websy-vis-error-container').html(" \n <div>\n <div id=\"".concat(this.elementId, "_errorTitle\"></div>\n <div id=\"").concat(this.elementId, "_errorMessage\"></div>\n </div>\n "));
|
|
7343
|
+
this.loadingContainer = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_loadingContainer"));
|
|
7344
|
+
this.loadingDialog = new WebsyDesigns.LoadingDialog("".concat(this.elementId, "_loadingContainer"));
|
|
7321
7345
|
this.prep(); // el.innerHTML += `
|
|
7322
7346
|
// <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
7323
7347
|
// <div>
|
|
@@ -7457,7 +7481,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7457
7481
|
|
|
7458
7482
|
this.options.data.series.forEach(function (s) {
|
|
7459
7483
|
if (_this43.options.data[xData].scale !== 'Time') {
|
|
7460
|
-
|
|
7484
|
+
if (_this43.customBottomRange && _this43.customBottomRange.length > 0) {
|
|
7485
|
+
xPoint = _this43.customBottomRange[x0] + (_this43.customBottomRange[x0 + 1] - _this43.customBottomRange[x0]) / 2;
|
|
7486
|
+
} else {
|
|
7487
|
+
xPoint = _this43[xAxis](_this43.parseX(xLabel));
|
|
7488
|
+
}
|
|
7489
|
+
|
|
7461
7490
|
s.data.forEach(function (d) {
|
|
7462
7491
|
if (d.x.value === xLabel) {
|
|
7463
7492
|
if (!tooltipTitle) {
|
|
@@ -7561,7 +7590,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7561
7590
|
};
|
|
7562
7591
|
|
|
7563
7592
|
if (xPoint > this.plotWidth / 2) {
|
|
7564
|
-
posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15
|
|
7593
|
+
posOptions.left = xPoint - this.options.tooltipWidth - 15; // + this.options.margin.left + this.options.margin.axisLeft + 15)
|
|
7565
7594
|
|
|
7566
7595
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7567
7596
|
// posOptions.left -= (this[xAxis].bandwidth())
|
|
@@ -7571,7 +7600,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7571
7600
|
posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15;
|
|
7572
7601
|
|
|
7573
7602
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7574
|
-
posOptions.left += this[xAxis
|
|
7603
|
+
posOptions.left += this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
|
|
7575
7604
|
}
|
|
7576
7605
|
}
|
|
7577
7606
|
|
|
@@ -7582,7 +7611,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7582
7611
|
var adjuster = 0;
|
|
7583
7612
|
|
|
7584
7613
|
if (this.options.data[xData].scale !== 'Time') {
|
|
7585
|
-
adjuster = this[xAxis
|
|
7614
|
+
adjuster = this.options.data[xAxis.replace('Axis', '')].bandWidth / 2; // - this.options.margin.top
|
|
7586
7615
|
}
|
|
7587
7616
|
|
|
7588
7617
|
posOptions = {
|
|
@@ -7605,8 +7634,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7605
7634
|
// xPoint = x0
|
|
7606
7635
|
// }
|
|
7607
7636
|
|
|
7608
|
-
if (this.options.data[xData].scale !== 'Time') {
|
|
7609
|
-
xPoint += this[xAxis
|
|
7637
|
+
if (this.options.data[xData].scale !== 'Time' && this.customBottomRange.length === 0) {
|
|
7638
|
+
xPoint += this.options.data[xAxis.replace('Axis', '')].bandWidth / 2; // - this.options.margin.top
|
|
7610
7639
|
}
|
|
7611
7640
|
|
|
7612
7641
|
var trackingXStart = xPoint;
|
|
@@ -7670,6 +7699,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7670
7699
|
|
|
7671
7700
|
if (!this.options.data) {// tell the user no data has been provided
|
|
7672
7701
|
} else {
|
|
7702
|
+
this.processedX = {};
|
|
7673
7703
|
this.transition = d3.transition().duration(this.options.transitionDuration);
|
|
7674
7704
|
|
|
7675
7705
|
if (this.options.data.bottom.scale && this.options.data.bottom.scale === 'Time') {
|
|
@@ -7727,12 +7757,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7727
7757
|
// the legend gets rendered so that we can get its actual size
|
|
7728
7758
|
|
|
7729
7759
|
if (this.options.showLegend === true) {
|
|
7730
|
-
var legendData =
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7760
|
+
var legendData = [];
|
|
7761
|
+
|
|
7762
|
+
if (this.options.legendData && this.options.legendData.length > 0) {
|
|
7763
|
+
legendData = this.options.legendData;
|
|
7764
|
+
} else {
|
|
7765
|
+
this.options.data.series.map(function (s, i) {
|
|
7766
|
+
return {
|
|
7767
|
+
value: s.label || s.key,
|
|
7768
|
+
color: s.color || _this44.options.colors[i % _this44.options.colors.length]
|
|
7769
|
+
};
|
|
7770
|
+
});
|
|
7771
|
+
}
|
|
7736
7772
|
|
|
7737
7773
|
if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
|
|
7738
7774
|
this.legendArea.style('width', '100%');
|
|
@@ -7936,18 +7972,34 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7936
7972
|
this.brushNeeded = false;
|
|
7937
7973
|
|
|
7938
7974
|
if (this.options.orientation === 'vertical') {
|
|
7975
|
+
this.options.data.bottom.totalValueCount = this.options.data.bottom.data.reduce(function (a, b) {
|
|
7976
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7977
|
+
return a + 1;
|
|
7978
|
+
}
|
|
7979
|
+
|
|
7980
|
+
return a + b.valueCount;
|
|
7981
|
+
}, 0);
|
|
7982
|
+
|
|
7939
7983
|
if (this.options.maxBandWidth) {
|
|
7940
|
-
this.plotWidth = Math.min(this.plotWidth,
|
|
7984
|
+
this.plotWidth = Math.min(this.plotWidth, this.options.data.bottom.totalValueCount * this.options.maxBandWidth);
|
|
7941
7985
|
} // some if to check if brushing is needed
|
|
7942
7986
|
|
|
7943
7987
|
|
|
7944
|
-
if (this.plotWidth / this.options.data.bottom.
|
|
7988
|
+
if (this.plotWidth / this.options.data.bottom.totalValueCount < this.options.minBandWidth) {
|
|
7945
7989
|
this.brushNeeded = true;
|
|
7946
7990
|
this.plotHeight -= this.options.brushHeight;
|
|
7947
7991
|
}
|
|
7948
7992
|
} else {
|
|
7949
7993
|
// some if to check if brushing is needed
|
|
7950
|
-
|
|
7994
|
+
this.options.data.left.totalValueCount = this.options.data.left.data.reduce(function (a, b) {
|
|
7995
|
+
if (typeof b.valueCount === 'undefined') {
|
|
7996
|
+
return a + 1;
|
|
7997
|
+
}
|
|
7998
|
+
|
|
7999
|
+
return a + b.valueCount;
|
|
8000
|
+
}, 0);
|
|
8001
|
+
|
|
8002
|
+
if (this.plotHeight / this.options.data.left.totalValueCount < this.options.minBandWidth) {
|
|
7951
8003
|
this.brushNeeded = true;
|
|
7952
8004
|
this.plotWidth -= this.options.brushHeight;
|
|
7953
8005
|
}
|
|
@@ -7977,10 +8029,42 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7977
8029
|
|
|
7978
8030
|
var bottomDomain = this.createDomain('bottom');
|
|
7979
8031
|
var bottomBrushDomain = this.createDomain('bottom', true);
|
|
7980
|
-
|
|
8032
|
+
var bottomRange = [0, this.plotWidth];
|
|
8033
|
+
this.customBottomRange = [];
|
|
8034
|
+
|
|
8035
|
+
if (this.options.allowUnevenBands === true) {
|
|
8036
|
+
if (this.options.data.bottom.data && this.options.data.bottom.data[0] && this.options.data.bottom.data[0].valueCount && this.options.data.bottom.scale === 'Ordinal') {
|
|
8037
|
+
var acc = 0;
|
|
8038
|
+
this.customBottomRange = [0].concat(_toConsumableArray(this.options.data.bottom.data.map(function (d) {
|
|
8039
|
+
acc += d.valueCount;
|
|
8040
|
+
return _this44.plotWidth / _this44.options.data.bottom.totalValueCount * acc;
|
|
8041
|
+
})));
|
|
8042
|
+
}
|
|
8043
|
+
}
|
|
8044
|
+
|
|
8045
|
+
this.options.data.bottom.step = this.plotWidth / this.options.data.bottom.totalValueCount;
|
|
8046
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.step;
|
|
8047
|
+
|
|
8048
|
+
if (this.options.data.bottom.padding) {
|
|
8049
|
+
this.totalPadding = this.plotWidth * this.options.data.bottom.padding;
|
|
8050
|
+
var rangeLength = bottomDomain.length;
|
|
8051
|
+
|
|
8052
|
+
if (this.customBottomRange.length > 0) {
|
|
8053
|
+
rangeLength = this.customBottomRange.length;
|
|
8054
|
+
}
|
|
8055
|
+
|
|
8056
|
+
this.bandPadding = this.totalPadding / rangeLength / 2;
|
|
8057
|
+
this.options.data.bottom.bandWidth = (this.plotWidth - this.totalPadding) / this.options.data.bottom.totalValueCount;
|
|
8058
|
+
}
|
|
8059
|
+
|
|
8060
|
+
if (this.options.grouping === 'grouped' && this.options.data.series.length > 1) {
|
|
8061
|
+
this.options.data.bottom.bandWidth = this.options.data.bottom.bandWidth - this.options.groupPadding * 2;
|
|
8062
|
+
}
|
|
8063
|
+
|
|
8064
|
+
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range(bottomRange);
|
|
7981
8065
|
|
|
7982
8066
|
if (!this.brushInitialized) {
|
|
7983
|
-
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range(
|
|
8067
|
+
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range(bottomRange);
|
|
7984
8068
|
}
|
|
7985
8069
|
|
|
7986
8070
|
if (this.bottomAxis.nice) {// this.bottomAxis.nice()
|
|
@@ -8099,6 +8183,12 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8099
8183
|
if (this.options.data.bottom.rotate) {
|
|
8100
8184
|
this.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(this.options.data.bottom && this.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize, "px"));
|
|
8101
8185
|
}
|
|
8186
|
+
|
|
8187
|
+
if (this.customBottomRange.length > 0) {
|
|
8188
|
+
this.bottomAxisLayer.selectAll('g').attr('transform', function (d, i) {
|
|
8189
|
+
return "translate(".concat(_this44.customBottomRange[i] + (_this44.customBottomRange[i + 1] - _this44.customBottomRange[i]) / 2, ", 0)");
|
|
8190
|
+
});
|
|
8191
|
+
}
|
|
8102
8192
|
} // Configure the left axis
|
|
8103
8193
|
|
|
8104
8194
|
|
|
@@ -8216,6 +8306,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8216
8306
|
|
|
8217
8307
|
_this45.renderedKeys[series.key] = series.type;
|
|
8218
8308
|
});
|
|
8309
|
+
this.refLineLayer.selectAll('.reference-line').remove();
|
|
8310
|
+
this.refLineLayer.selectAll('.reference-line-label').remove();
|
|
8219
8311
|
|
|
8220
8312
|
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8221
8313
|
this.options.refLines.forEach(function (l) {
|
|
@@ -8231,20 +8323,20 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8231
8323
|
/* global d3 series index */
|
|
8232
8324
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
8233
8325
|
return d3.area().x(function (d) {
|
|
8234
|
-
return _this46[xAxis](_this46.parseX(d.x.value));
|
|
8326
|
+
return _this46["".concat(xAxis, "Axis")](_this46.parseX(d.x.value));
|
|
8235
8327
|
}).y0(function (d) {
|
|
8236
|
-
return _this46[yAxis](0);
|
|
8328
|
+
return _this46["".concat(yAxis, "Axis")](0);
|
|
8237
8329
|
}).y1(function (d) {
|
|
8238
|
-
return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8330
|
+
return _this46["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8239
8331
|
}).curve(d3[curveStyle || _this46.options.curveStyle]);
|
|
8240
8332
|
};
|
|
8241
8333
|
|
|
8242
|
-
var xAxis = '
|
|
8243
|
-
var yAxis = series.axis === 'secondary' ? '
|
|
8334
|
+
var xAxis = 'bottom';
|
|
8335
|
+
var yAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8244
8336
|
|
|
8245
|
-
if (this.options.
|
|
8246
|
-
xAxis = series.axis === 'secondary' ? '
|
|
8247
|
-
yAxis = '
|
|
8337
|
+
if (this.options.orientation === 'horizontal') {
|
|
8338
|
+
xAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8339
|
+
yAxis = 'bottom';
|
|
8248
8340
|
}
|
|
8249
8341
|
|
|
8250
8342
|
var areas = this.areaLayer.selectAll(".area_".concat(series.key)).data([series.data]); // Exit
|
|
@@ -8262,8 +8354,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8262
8354
|
|
|
8263
8355
|
areas.enter().append('path').attr('d', function (d) {
|
|
8264
8356
|
return drawArea(xAxis, yAxis, series.curveStyle)(d);
|
|
8265
|
-
}).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key))
|
|
8266
|
-
// .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8357
|
+
}).attr('class', "area_".concat(series.key)).attr('id', "area_".concat(series.key)).attr('transform', 'translate(' + (this.options.data[xAxis].scale === 'Time' ? 0 : this.options.data["".concat(xAxis, "Axis")].bandWidth / 2) + ',0)') // .style('stroke-width', series.lineWidth || this.options.lineWidth)
|
|
8267
8358
|
.attr('fill', series.color) // .style('fill-opacity', 0)
|
|
8268
8359
|
.attr('stroke', 'transparent') // .transition(this.transition)
|
|
8269
8360
|
.style('fill-opacity', series.opacity || 0.5);
|
|
@@ -8289,14 +8380,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8289
8380
|
|
|
8290
8381
|
|
|
8291
8382
|
function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
|
|
8292
|
-
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8293
|
-
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8294
8383
|
var output;
|
|
8295
8384
|
|
|
8296
8385
|
if (this.options.orientation === 'horizontal') {
|
|
8297
|
-
output =
|
|
8386
|
+
output = this.options.data[xAxis.replace('Brush', '')].bandWidth;
|
|
8298
8387
|
} else {
|
|
8299
|
-
|
|
8388
|
+
var x = getBarX.call(this, d, i, xAxis);
|
|
8389
|
+
|
|
8390
|
+
if (typeof x === 'undefined' || x === null) {
|
|
8300
8391
|
return null;
|
|
8301
8392
|
}
|
|
8302
8393
|
|
|
@@ -8311,24 +8402,20 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8311
8402
|
}
|
|
8312
8403
|
|
|
8313
8404
|
function getBarWidth(d, i, xAxis) {
|
|
8314
|
-
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8315
|
-
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8316
8405
|
var output;
|
|
8317
8406
|
|
|
8318
8407
|
if (this.options.orientation === 'horizontal') {
|
|
8319
|
-
var width = this["".concat(yAxis, "Axis")](d.y.value);
|
|
8408
|
+
var width = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
8320
8409
|
acummulativeY[d.y.index] += width;
|
|
8321
|
-
output =
|
|
8410
|
+
output = width;
|
|
8322
8411
|
} else {
|
|
8323
|
-
|
|
8412
|
+
var x = getBarX.call(this, d, i, xAxis);
|
|
8413
|
+
|
|
8414
|
+
if (typeof x === 'undefined' || x === null) {
|
|
8324
8415
|
return null;
|
|
8325
8416
|
}
|
|
8326
8417
|
|
|
8327
|
-
|
|
8328
|
-
output = Math.max(1, groupedBarWidth);
|
|
8329
|
-
} else {
|
|
8330
|
-
output = Math.max(1, barWidth);
|
|
8331
|
-
}
|
|
8418
|
+
output = Math.max(1, this.options.data[xAxis.replace('Brush', '')].bandWidth);
|
|
8332
8419
|
}
|
|
8333
8420
|
|
|
8334
8421
|
if (isNaN(output)) {
|
|
@@ -8339,23 +8426,59 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8339
8426
|
}
|
|
8340
8427
|
|
|
8341
8428
|
function getBarX(d, i, xAxis) {
|
|
8342
|
-
|
|
8343
|
-
|
|
8429
|
+
// let barWidth = this.plotWidth / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8430
|
+
// if (this.options.data[xAxis.replace('Brush', '')].padding) {
|
|
8431
|
+
// barWidth = barWidth - (barWidth * this.options.data[xAxis.replace('Brush', '')].padding)
|
|
8432
|
+
// }
|
|
8433
|
+
// let groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data[xAxis.replace('Brush', '')].totalValueCount
|
|
8344
8434
|
var output;
|
|
8345
8435
|
|
|
8346
8436
|
if (this.options.orientation === 'horizontal') {
|
|
8347
8437
|
if (this.options.grouping === 'stacked') {
|
|
8348
|
-
|
|
8438
|
+
var h = getBarWidth.call(this, d, i, xAxis);
|
|
8439
|
+
var adjustment = 0;
|
|
8440
|
+
|
|
8441
|
+
if (d.y.accumulative && d.y.accumulative !== 0) {
|
|
8442
|
+
adjustment = this["".concat(yAxis, "Axis")](d.y.accumulative || 0);
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8445
|
+
output = this["".concat(yAxis, "Axis")](0) + adjustment * (d.y.value < 0 ? 1 : 0) + h * (d.y.value < 0 ? 1 : 0);
|
|
8349
8446
|
} else {
|
|
8350
|
-
|
|
8447
|
+
var _h = getBarWidth.call(this, d, i, xAxis);
|
|
8448
|
+
|
|
8449
|
+
output = this["".concat(yAxis, "Axis")](0) + _h * (d.y.value < 0 ? 1 : 0);
|
|
8351
8450
|
}
|
|
8352
8451
|
} else {
|
|
8353
|
-
|
|
8452
|
+
// let adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this.options.data[xAxis.replace('Brush', '')].bandWidth / 2
|
|
8453
|
+
var _adjustment = this.customBottomRange[i] + i * this.options.data[xAxis.replace('Brush', '')].bandWidth;
|
|
8354
8454
|
|
|
8355
8455
|
if (this.options.grouping === 'grouped') {
|
|
8356
|
-
var
|
|
8456
|
+
var xIndex = 0;
|
|
8457
|
+
|
|
8458
|
+
if (this.processedX[d.x.value]) {
|
|
8459
|
+
xIndex = Math.max(0, this.processedX[d.x.value].indexOf(d.y.tooltipLabel));
|
|
8460
|
+
}
|
|
8461
|
+
|
|
8462
|
+
var barAdjustment = this.options.data[xAxis.replace('Brush', '')].bandWidth * xIndex + xIndex * this.options.groupPadding * 2 + this.options.groupPadding + (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1); // let barAdjustment =
|
|
8463
|
+
// (this.options.data[xAxis.replace('Brush', '')].step * xIndex) +
|
|
8464
|
+
// this.options.groupPadding
|
|
8465
|
+
// // (xAxis.indexOf('Brush') === -1 ? this.bandPadding : 1)
|
|
8466
|
+
|
|
8467
|
+
if (this.customBottomRange.length > 0) {
|
|
8468
|
+
output = this.customBottomRange[this[xAxis.replace('Brush', '') + 'Axis'].domain().indexOf(d.x.value)] + barAdjustment;
|
|
8469
|
+
} else {
|
|
8470
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
|
|
8471
|
+
}
|
|
8472
|
+
|
|
8473
|
+
if (!this.processedX[d.x.value]) {
|
|
8474
|
+
this.processedX[d.x.value] = [];
|
|
8475
|
+
}
|
|
8357
8476
|
|
|
8358
|
-
|
|
8477
|
+
if (this.processedX[d.x.value].indexOf(d.y.tooltipLabel) === -1) {
|
|
8478
|
+
this.processedX[d.x.value].push(d.y.tooltipLabel);
|
|
8479
|
+
}
|
|
8480
|
+
|
|
8481
|
+
console.log(d.x.value, d.y.tooltipLabel, xIndex, i, barAdjustment, output);
|
|
8359
8482
|
} else {
|
|
8360
8483
|
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
8361
8484
|
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
|
|
@@ -8370,15 +8493,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8370
8493
|
}
|
|
8371
8494
|
|
|
8372
8495
|
function getBarY(d, i, heightBounds, yAxis, xAxis) {
|
|
8373
|
-
|
|
8374
|
-
|
|
8496
|
+
// let barWidth = this[`${xAxis}Axis`].bandwidth()
|
|
8497
|
+
// let groupedBarWidth = (barWidth - 10) / this.options.data.series.length
|
|
8375
8498
|
var output;
|
|
8376
8499
|
|
|
8377
8500
|
if (this.options.orientation === 'horizontal') {
|
|
8378
8501
|
if (this.options.grouping !== 'grouped') {
|
|
8379
8502
|
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
|
|
8380
8503
|
} else {
|
|
8381
|
-
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
|
|
8504
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * this.options.data[xAxis.replace('Brush', '')].barWidth;
|
|
8382
8505
|
}
|
|
8383
8506
|
} else {
|
|
8384
8507
|
if (this.options.grouping === 'stacked') {
|
|
@@ -8398,7 +8521,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8398
8521
|
|
|
8399
8522
|
bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8400
8523
|
bars.attr('width', function (d, i) {
|
|
8401
|
-
return getBarWidth.call(_this47, d, i, xAxis);
|
|
8524
|
+
return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
|
|
8402
8525
|
}).attr('height', function (d, i) {
|
|
8403
8526
|
return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8404
8527
|
}).attr('x', function (d, i) {
|
|
@@ -8410,7 +8533,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8410
8533
|
return d.y.color || d.color || series.color;
|
|
8411
8534
|
});
|
|
8412
8535
|
bars.enter().append('rect').attr('width', function (d, i) {
|
|
8413
|
-
return getBarWidth.call(_this47, d, i, xAxis);
|
|
8536
|
+
return Math.abs(getBarWidth.call(_this47, d, i, xAxis));
|
|
8414
8537
|
}).attr('height', function (d, i) {
|
|
8415
8538
|
return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8416
8539
|
}).attr('x', function (d, i) {
|
|
@@ -8428,7 +8551,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8428
8551
|
this.brushBarsInitialized[series.key] = true;
|
|
8429
8552
|
brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8430
8553
|
brushBars.attr('width', function (d, i) {
|
|
8431
|
-
return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8554
|
+
return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
|
|
8432
8555
|
}).attr('height', function (d, i) {
|
|
8433
8556
|
return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8434
8557
|
}).attr('x', function (d, i) {
|
|
@@ -8440,7 +8563,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8440
8563
|
return d.y.color || d.color || series.color;
|
|
8441
8564
|
});
|
|
8442
8565
|
brushBars.enter().append('rect').attr('width', function (d, i) {
|
|
8443
|
-
return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8566
|
+
return Math.abs(getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush")));
|
|
8444
8567
|
}).attr('height', function (d, i) {
|
|
8445
8568
|
return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8446
8569
|
}).attr('x', function (d, i) {
|
|
@@ -8560,7 +8683,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8560
8683
|
return this[yAxis](isNaN(d.y.value) ? 0 : d.y.value) + 4;
|
|
8561
8684
|
}
|
|
8562
8685
|
} else {
|
|
8563
|
-
return this[xAxis](this.parseX(d.x.value)) + this[xAxis
|
|
8686
|
+
return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
|
|
8564
8687
|
}
|
|
8565
8688
|
}
|
|
8566
8689
|
|
|
@@ -8568,7 +8691,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8568
8691
|
var labelPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inside';
|
|
8569
8692
|
|
|
8570
8693
|
if (this.options.orientation === 'horizontal') {
|
|
8571
|
-
return this[xAxis](this.parseX(d.x.value)) + this[xAxis
|
|
8694
|
+
return this[xAxis](this.parseX(d.x.value)) + this.options.data[xAxis.replace('Axis', '')].bandWidth / 2;
|
|
8572
8695
|
} else {
|
|
8573
8696
|
if (this.options.grouping === 'stacked') {
|
|
8574
8697
|
return this[yAxis](d.y.accumulative) + this[yAxis](d.y.value) / (labelPosition === 'inside' ? 2 : 1);
|
|
@@ -8586,17 +8709,26 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8586
8709
|
/* global series index d3 */
|
|
8587
8710
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
8588
8711
|
return d3.line().x(function (d) {
|
|
8589
|
-
|
|
8590
|
-
|
|
8712
|
+
if (_this49.options.orientation === 'horizontal') {
|
|
8713
|
+
return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8714
|
+
} else {
|
|
8715
|
+
var adjustment = _this49.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8716
|
+
return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
|
|
8717
|
+
}
|
|
8591
8718
|
}).y(function (d) {
|
|
8592
|
-
|
|
8719
|
+
if (_this49.options.orientation === 'horizontal') {
|
|
8720
|
+
var adjustment = _this49.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8721
|
+
return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
|
|
8722
|
+
} else {
|
|
8723
|
+
return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8724
|
+
}
|
|
8593
8725
|
}).curve(d3[curveStyle || _this49.options.curveStyle]);
|
|
8594
8726
|
};
|
|
8595
8727
|
|
|
8596
8728
|
var xAxis = 'bottom';
|
|
8597
8729
|
var yAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8598
8730
|
|
|
8599
|
-
if (this.options.
|
|
8731
|
+
if (this.options.orientation === 'horizontal') {
|
|
8600
8732
|
xAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8601
8733
|
yAxis = 'bottom';
|
|
8602
8734
|
}
|
|
@@ -8604,7 +8736,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8604
8736
|
var xBrushAxis = 'bottomBrush';
|
|
8605
8737
|
var yBrushAxis = 'leftBrush';
|
|
8606
8738
|
|
|
8607
|
-
if (this.options.
|
|
8739
|
+
if (this.options.orientation === 'horizontal') {
|
|
8608
8740
|
xBrushAxis = 'leftBrush';
|
|
8609
8741
|
yBrushAxis = 'bottomBrush';
|
|
8610
8742
|
}
|
|
@@ -8671,8 +8803,6 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8671
8803
|
length = this.plotHeight;
|
|
8672
8804
|
}
|
|
8673
8805
|
|
|
8674
|
-
this.refLineLayer.selectAll('.reference-line').remove();
|
|
8675
|
-
this.refLineLayer.selectAll('.reference-line-label').remove();
|
|
8676
8806
|
this.refLineLayer.append('line').attr("".concat(yAttr, "1"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(yAttr, "2"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(xAttr, "2"), length).attr('class', "reference-line").style('stroke', data.color).style('stroke-width', "".concat(data.lineWidth, "px")).style('stroke-dasharray', data.lineStyle);
|
|
8677
8807
|
|
|
8678
8808
|
if (data.label && data.label !== '') {
|
|
@@ -8702,7 +8832,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8702
8832
|
var xAxis = 'bottom';
|
|
8703
8833
|
var yAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8704
8834
|
|
|
8705
|
-
if (this.options.
|
|
8835
|
+
if (this.options.orientation === 'horizontal') {
|
|
8706
8836
|
xAxis = series.axis === 'secondary' ? 'right' : 'left';
|
|
8707
8837
|
yAxis = 'bottom';
|
|
8708
8838
|
}
|
|
@@ -8714,8 +8844,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8714
8844
|
symbols.attr('d', function (d) {
|
|
8715
8845
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
8716
8846
|
}).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
8717
|
-
var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8718
|
-
|
|
8847
|
+
var adjustment = _this50.options.data[xAxis].scale === 'Time' || _this50.options.data[xAxis].scale === 'Linear' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8848
|
+
|
|
8849
|
+
if (_this50.options.orientation === 'horizontal') {
|
|
8850
|
+
return "translate(".concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ")");
|
|
8851
|
+
} else {
|
|
8852
|
+
return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8853
|
+
}
|
|
8719
8854
|
}); // Enter
|
|
8720
8855
|
|
|
8721
8856
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -8724,8 +8859,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8724
8859
|
.attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
8725
8860
|
return "symbol symbol_".concat(series.key);
|
|
8726
8861
|
}).attr('transform', function (d) {
|
|
8727
|
-
var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8728
|
-
|
|
8862
|
+
var adjustment = _this50.options.data[xAxis].scale === 'Time' || _this50.options.data[xAxis].scale === 'Linear' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8863
|
+
|
|
8864
|
+
if (_this50.options.orientation === 'horizontal') {
|
|
8865
|
+
return "translate(".concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ", ").concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ")");
|
|
8866
|
+
} else {
|
|
8867
|
+
return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8868
|
+
}
|
|
8729
8869
|
});
|
|
8730
8870
|
}
|
|
8731
8871
|
}, {
|
|
@@ -8820,17 +8960,23 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8820
8960
|
|
|
8821
8961
|
if (el) {
|
|
8822
8962
|
el.classList.remove('has-error');
|
|
8823
|
-
}
|
|
8824
|
-
// chartEl.classList.remove('hidden')
|
|
8963
|
+
}
|
|
8825
8964
|
|
|
8965
|
+
if (this.svg) {
|
|
8966
|
+
this.svg.classed('hidden', false);
|
|
8967
|
+
}
|
|
8826
8968
|
|
|
8827
|
-
this.svg.classed('hidden', false);
|
|
8828
8969
|
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
8829
8970
|
|
|
8830
8971
|
if (containerEl) {
|
|
8831
8972
|
containerEl.classList.remove('active');
|
|
8832
8973
|
}
|
|
8833
8974
|
}
|
|
8975
|
+
}, {
|
|
8976
|
+
key: "hideLoading",
|
|
8977
|
+
value: function hideLoading() {
|
|
8978
|
+
this.loadingDialog.hide();
|
|
8979
|
+
}
|
|
8834
8980
|
}, {
|
|
8835
8981
|
key: "showError",
|
|
8836
8982
|
value: function showError(options) {
|
|
@@ -8839,10 +8985,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8839
8985
|
if (el) {
|
|
8840
8986
|
el.classList.add('has-error');
|
|
8841
8987
|
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
8842
|
-
// chartEl.classList.add('hidden')
|
|
8988
|
+
// chartEl.classList.add('hidden')
|
|
8843
8989
|
|
|
8844
8990
|
|
|
8845
|
-
this.svg
|
|
8991
|
+
if (this.svg) {
|
|
8992
|
+
this.svg.classed('hidden', true);
|
|
8993
|
+
}
|
|
8994
|
+
|
|
8846
8995
|
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
8847
8996
|
|
|
8848
8997
|
if (containerEl) {
|
|
@@ -8865,6 +9014,11 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8865
9014
|
}
|
|
8866
9015
|
}
|
|
8867
9016
|
}
|
|
9017
|
+
}, {
|
|
9018
|
+
key: "showLoading",
|
|
9019
|
+
value: function showLoading(options) {
|
|
9020
|
+
this.loadingDialog.show(options);
|
|
9021
|
+
}
|
|
8868
9022
|
}, {
|
|
8869
9023
|
key: "data",
|
|
8870
9024
|
set: function set(d) {
|