@websy/websy-designs 1.4.33 → 1.4.34
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 +415 -80
- package/dist/websy-designs-es6.js +452 -112
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +415 -80
- package/dist/websy-designs.js +452 -112
- package/dist/websy-designs.min.css +1 -1
- package/dist/websy-designs.min.js +1 -1
- package/package.json +1 -1
package/dist/websy-designs.js
CHANGED
|
@@ -7162,6 +7162,12 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7162
7162
|
headEl.style.width = 'initial';
|
|
7163
7163
|
bodyEl.style.width = 'initial';
|
|
7164
7164
|
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
7165
|
+
|
|
7166
|
+
if (this.options.maxHeight) {
|
|
7167
|
+
var requiredHeight = ((this.totalRowCount || 9) + 1) * this.sizes.cellHeight;
|
|
7168
|
+
this.sizes.bodyHeight = Math.min(requiredHeight, this.options.maxHeight - (this.sizes.header.height + this.sizes.total.height));
|
|
7169
|
+
}
|
|
7170
|
+
|
|
7165
7171
|
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
7166
7172
|
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
7167
7173
|
this.startRow = 0;
|
|
@@ -7382,8 +7388,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
7382
7388
|
}
|
|
7383
7389
|
|
|
7384
7390
|
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
7391
|
+
// if (this.options.maxHeight) {
|
|
7392
|
+
// bodyEl.style.height = `${this.options.maxHeight - this.sizes.header.height - this.sizes.total.height}px`
|
|
7393
|
+
// }
|
|
7394
|
+
// else {
|
|
7395
|
+
// bodyEl.style.height = `calc(100% - ${this.sizes.header.height}px - ${this.sizes.total.height}px)`
|
|
7396
|
+
// }
|
|
7385
7397
|
|
|
7386
|
-
bodyEl.style.height = "
|
|
7398
|
+
bodyEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
7387
7399
|
|
|
7388
7400
|
if (this.options.virtualScroll === true) {
|
|
7389
7401
|
// set the scroll element positions
|
|
@@ -7647,7 +7659,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7647
7659
|
showTooltip: true,
|
|
7648
7660
|
showLegend: false,
|
|
7649
7661
|
legendPosition: 'bottom',
|
|
7650
|
-
tooltipWidth: 200
|
|
7662
|
+
tooltipWidth: 200,
|
|
7663
|
+
brushHeight: 50,
|
|
7664
|
+
minBandWidth: 30
|
|
7651
7665
|
};
|
|
7652
7666
|
this.elementId = elementId;
|
|
7653
7667
|
this.options = _extends({}, DEFAULTS, options);
|
|
@@ -7656,6 +7670,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7656
7670
|
this.topAxis = null;
|
|
7657
7671
|
this.bottomAxis = null;
|
|
7658
7672
|
this.renderedKeys = {};
|
|
7673
|
+
this.brushedDomain = [];
|
|
7674
|
+
this.brushBarsInitialized = {};
|
|
7659
7675
|
|
|
7660
7676
|
if (!elementId) {
|
|
7661
7677
|
console.log('No element Id provided for Websy Chart');
|
|
@@ -7663,12 +7679,19 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7663
7679
|
}
|
|
7664
7680
|
|
|
7665
7681
|
this.invertOverride = function (input, input2) {
|
|
7666
|
-
var
|
|
7682
|
+
var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
7683
|
+
var xAxis = 'bottom';
|
|
7667
7684
|
|
|
7668
7685
|
if (_this45.options.orientation === 'horizontal') {
|
|
7669
|
-
xAxis = '
|
|
7686
|
+
xAxis = 'left';
|
|
7670
7687
|
}
|
|
7671
7688
|
|
|
7689
|
+
if (forBrush === true) {
|
|
7690
|
+
xAxis += 'Brush';
|
|
7691
|
+
}
|
|
7692
|
+
|
|
7693
|
+
xAxis += 'Axis';
|
|
7694
|
+
|
|
7672
7695
|
var width = _this45[xAxis].step();
|
|
7673
7696
|
|
|
7674
7697
|
var output;
|
|
@@ -7692,6 +7715,66 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7692
7715
|
return output;
|
|
7693
7716
|
};
|
|
7694
7717
|
|
|
7718
|
+
var that = this;
|
|
7719
|
+
|
|
7720
|
+
this.brushed = function (event) {
|
|
7721
|
+
console.log('brushing', event);
|
|
7722
|
+
that.brushedDomain = [];
|
|
7723
|
+
var xAxis = 'bottom';
|
|
7724
|
+
var xAxisCaps = 'Bottom';
|
|
7725
|
+
|
|
7726
|
+
if (that.options.orientation === 'horizontal') {
|
|
7727
|
+
xAxis = 'left';
|
|
7728
|
+
xAxisCaps = 'Left';
|
|
7729
|
+
}
|
|
7730
|
+
|
|
7731
|
+
if (!that["".concat(xAxis, "Axis")].invert) {
|
|
7732
|
+
that["".concat(xAxis, "Axis")].invert = that.invertOverride;
|
|
7733
|
+
}
|
|
7734
|
+
|
|
7735
|
+
var s = event.selection || that["".concat(xAxis, "Axis")].range();
|
|
7736
|
+
|
|
7737
|
+
if (!event.selection || event.selection.length === 0) {
|
|
7738
|
+
that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
|
|
7739
|
+
return;
|
|
7740
|
+
}
|
|
7741
|
+
|
|
7742
|
+
if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
7743
|
+
that.brushedDomain = s.map(that["".concat(xAxis, "BrushAxis")].invert, that[["".concat(xAxis, "Axis")]]);
|
|
7744
|
+
} else {
|
|
7745
|
+
var startEndOrdinal = s.map(function (a, b) {
|
|
7746
|
+
return that.bottomAxis.invert(a, b, true);
|
|
7747
|
+
}, that.bottomBrushAxis);
|
|
7748
|
+
|
|
7749
|
+
if (startEndOrdinal && startEndOrdinal.length === 2 && typeof startEndOrdinal[0] !== 'undefined' && typeof startEndOrdinal[1] !== 'undefined') {
|
|
7750
|
+
var domain = [];
|
|
7751
|
+
|
|
7752
|
+
var domainValues = _toConsumableArray(that["".concat(xAxis, "BrushAxis")].domain());
|
|
7753
|
+
|
|
7754
|
+
for (var i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7755
|
+
// domain.push(that.xRange[i])
|
|
7756
|
+
that.brushedDomain.push(domainValues[i]);
|
|
7757
|
+
}
|
|
7758
|
+
}
|
|
7759
|
+
}
|
|
7760
|
+
|
|
7761
|
+
if (that.brushedDomain.length > 0) {
|
|
7762
|
+
that["".concat(xAxis, "Axis")].domain(that.brushedDomain);
|
|
7763
|
+
that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
|
|
7764
|
+
}
|
|
7765
|
+
|
|
7766
|
+
if (that.leftAxis && that.bottomAxis) {
|
|
7767
|
+
that.renderComponents();
|
|
7768
|
+
|
|
7769
|
+
if (that.options.orientation === 'vertical') {
|
|
7770
|
+
// that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7771
|
+
if (that.options.data.bottom.rotate) {
|
|
7772
|
+
that.bottomAxisLayer.selectAll('text').attr('transform', "rotate(".concat(that.options.data.bottom && that.options.data.bottom.rotate || 0, ")")).style('text-anchor', "".concat((that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? 'middle' : 'end')).style('transform-origin', (that.options.data.bottom && that.options.data.bottom.rotate || 0) === 0 ? '0 0' : "0 ".concat(that.options.data.bottom && that.options.data.bottom.fontSize || that.options.fontSize, "px"));
|
|
7773
|
+
}
|
|
7774
|
+
}
|
|
7775
|
+
}
|
|
7776
|
+
};
|
|
7777
|
+
|
|
7695
7778
|
var el = document.getElementById(this.elementId);
|
|
7696
7779
|
|
|
7697
7780
|
if (el) {
|
|
@@ -7701,10 +7784,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7701
7784
|
console.error('d3 library has not been loaded');
|
|
7702
7785
|
} else {
|
|
7703
7786
|
el.innerHTML = '';
|
|
7704
|
-
this.svg = d3.select(el).append('svg');
|
|
7787
|
+
this.svg = d3.select(el).append('svg'); // .attr('id', `${this.elementId}_chartContainer`)
|
|
7788
|
+
|
|
7705
7789
|
this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
|
|
7706
7790
|
this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
|
|
7707
|
-
this.prep();
|
|
7791
|
+
this.prep(); // el.innerHTML += `
|
|
7792
|
+
// <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
7793
|
+
// <div>
|
|
7794
|
+
// <div id="${this.elementId}_errorTitle"></div>
|
|
7795
|
+
// <div id="${this.elementId}_errorMessage"></div>
|
|
7796
|
+
// </div>
|
|
7797
|
+
// </div>
|
|
7798
|
+
// `
|
|
7708
7799
|
}
|
|
7709
7800
|
} else {
|
|
7710
7801
|
console.error("No element found with ID ".concat(this.elementId));
|
|
@@ -7731,29 +7822,41 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7731
7822
|
key: "createDomain",
|
|
7732
7823
|
value: function createDomain(side) {
|
|
7733
7824
|
var domain = [];
|
|
7734
|
-
/* global d3 side domain:writable */
|
|
7825
|
+
/* global d3 side domain:writable forBrush */
|
|
7826
|
+
// if we have a brushed domain we use that
|
|
7735
7827
|
|
|
7736
|
-
|
|
7737
|
-
// domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
|
|
7738
|
-
domain = [this.options.data[side].min, this.options.data[side].max];
|
|
7828
|
+
var xAxis = 'bottom';
|
|
7739
7829
|
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
}
|
|
7830
|
+
if (this.options.orientation === 'horizontal') {
|
|
7831
|
+
xAxis = 'left';
|
|
7743
7832
|
}
|
|
7744
7833
|
|
|
7745
|
-
if (this.
|
|
7746
|
-
domain = this.
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7834
|
+
if (this.brushedDomain.length > 0 && side === xAxis && forBrush === false) {
|
|
7835
|
+
domain = _toConsumableArray(this.brushedDomain);
|
|
7836
|
+
} else {
|
|
7837
|
+
// otherwise we create the domain
|
|
7838
|
+
if (typeof this.options.data[side].min !== 'undefined' && typeof this.options.data[side].max !== 'undefined') {
|
|
7839
|
+
// domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
|
|
7840
|
+
domain = [this.options.data[side].min, this.options.data[side].max];
|
|
7841
|
+
|
|
7842
|
+
if (this.options.forceZero === true) {
|
|
7843
|
+
domain = [Math.min(0, this.options.data[side].min), this.options.data[side].max];
|
|
7844
|
+
}
|
|
7845
|
+
}
|
|
7846
|
+
|
|
7847
|
+
if (this.options.data[side].data) {
|
|
7848
|
+
domain = this.options.data[side].data.map(function (d) {
|
|
7849
|
+
return d.value;
|
|
7850
|
+
});
|
|
7851
|
+
}
|
|
7750
7852
|
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7853
|
+
if (this.options.data[side].scale === 'Time') {
|
|
7854
|
+
var min = this.options.data[side].data[0].value;
|
|
7855
|
+
var max = this.options.data[side].data[this.options.data[side].data.length - 1].value;
|
|
7856
|
+
min = this.parseX(min);
|
|
7857
|
+
max = this.parseX(max);
|
|
7858
|
+
domain = [min, max];
|
|
7859
|
+
}
|
|
7757
7860
|
}
|
|
7758
7861
|
|
|
7759
7862
|
return domain;
|
|
@@ -7994,6 +8097,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7994
8097
|
key: "prep",
|
|
7995
8098
|
value: function prep() {
|
|
7996
8099
|
/* global d3 WebsyDesigns */
|
|
8100
|
+
this.defs = this.svg.append('defs');
|
|
8101
|
+
this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
|
|
8102
|
+
this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
|
|
7997
8103
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
|
|
7998
8104
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
|
|
7999
8105
|
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
|
|
@@ -8010,6 +8116,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8010
8116
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
|
|
8011
8117
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line');
|
|
8012
8118
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
|
|
8119
|
+
this.brushLayer = this.svg.append('g'); // .attr(
|
|
8120
|
+
// 'clip-path',
|
|
8121
|
+
// `url(#${this.elementId.replace(/\s/g, '_')}_brushclip)`
|
|
8122
|
+
// )
|
|
8123
|
+
|
|
8124
|
+
this.brushArea = this.brushLayer.append('g').attr('class', 'brush-area');
|
|
8125
|
+
this.brushLayer.append('g').attr('class', 'brush');
|
|
8013
8126
|
this.eventLayer = this.svg.append('g').attr('class', 'event-line').append('rect');
|
|
8014
8127
|
this.eventLayer.on('mouseout', this.handleEventMouseOut.bind(this)).on('mousemove', this.handleEventMouseMove.bind(this));
|
|
8015
8128
|
this.render();
|
|
@@ -8149,7 +8262,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8149
8262
|
|
|
8150
8263
|
if (this.options.data.bottom.formatter) {
|
|
8151
8264
|
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
|
|
8152
|
-
firstBottom = this.
|
|
8265
|
+
firstBottom = this.options.data.bottom.formatter(this.options.data.bottom.data[0].value).toString();
|
|
8153
8266
|
} else {
|
|
8154
8267
|
if (this.options.data.bottom.scale === 'Time') {
|
|
8155
8268
|
this.longestBottom = '01/01/2000';
|
|
@@ -8157,7 +8270,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8157
8270
|
} else {
|
|
8158
8271
|
this.longestBottom = this.options.data.bottom.data.reduce(function (a, b) {
|
|
8159
8272
|
return a.length > b.value.length ? a : b.value;
|
|
8160
|
-
}, '');
|
|
8273
|
+
}, ''); // firstBottom = (this.options.data.bottom.data[0] || [{value: ''}]).value
|
|
8274
|
+
|
|
8161
8275
|
firstBottom = this.options.data.bottom.data[0].value;
|
|
8162
8276
|
}
|
|
8163
8277
|
}
|
|
@@ -8249,7 +8363,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8249
8363
|
if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 && this.options.axis.hideBottom !== true) {
|
|
8250
8364
|
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2);
|
|
8251
8365
|
} else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) < 0 && this.options.axis.hideBottom !== true) {
|
|
8252
|
-
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft,
|
|
8366
|
+
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, firstBottomWidth / 2);
|
|
8253
8367
|
} else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) > 0 && this.options.axis.hideBottom !== true) {
|
|
8254
8368
|
this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width);
|
|
8255
8369
|
} // if (this.options.data.bottom.rotate) {
|
|
@@ -8282,7 +8396,26 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8282
8396
|
|
|
8283
8397
|
|
|
8284
8398
|
this.plotWidth = this.width - this.options.margin.legendLeft - this.options.margin.legendRight - this.options.margin.left - this.options.margin.right - this.options.margin.axisLeft - this.options.margin.axisRight;
|
|
8285
|
-
this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop;
|
|
8399
|
+
this.plotHeight = this.height - this.options.margin.legendTop - this.options.margin.legendBottom - this.options.margin.top - this.options.margin.bottom - this.options.margin.axisBottom - this.options.margin.axisTop;
|
|
8400
|
+
|
|
8401
|
+
if (this.options.orientation === 'vertical') {
|
|
8402
|
+
if (this.options.maxBandWidth) {
|
|
8403
|
+
this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth);
|
|
8404
|
+
} // some if to check if brushing is needed
|
|
8405
|
+
|
|
8406
|
+
|
|
8407
|
+
if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
|
|
8408
|
+
this.brushNeeded = true;
|
|
8409
|
+
this.plotHeight -= this.options.brushHeight;
|
|
8410
|
+
}
|
|
8411
|
+
} else {
|
|
8412
|
+
// some if to check if brushing is needed
|
|
8413
|
+
if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
|
|
8414
|
+
this.brushNeeded = true;
|
|
8415
|
+
this.plotWidth -= this.options.brushHeight;
|
|
8416
|
+
}
|
|
8417
|
+
} // Translate the layers
|
|
8418
|
+
|
|
8286
8419
|
|
|
8287
8420
|
this.leftAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).style('font-size', this.options.data.left && this.options.data.left.fontSize || this.options.fontSize);
|
|
8288
8421
|
this.rightAxisLayer.attr('transform', "translate(".concat(this.options.margin.left + this.plotWidth + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")")).style('font-size', this.options.data.right && this.options.data.right.fontSize || this.options.fontSize);
|
|
@@ -8298,19 +8431,68 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8298
8431
|
this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8299
8432
|
this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8300
8433
|
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8434
|
+
this.brushLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")"));
|
|
8435
|
+
this.brushClip.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop + this.plotHeight + longestBottomBounds.height, ")")).attr('width', this.plotWidth).attr('height', this.options.brushHeight);
|
|
8301
8436
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8302
8437
|
var that = this;
|
|
8303
8438
|
this.eventLayer.attr('x', 0).attr('y', 0).attr('width', this.plotWidth).attr('height', this.plotHeight).attr('fill-opacity', '0'); // this.tooltip.transform(this.options.margin.left + this.options.margin.axisLeft, this.options.margin.top + this.options.margin.axisTop)
|
|
8304
8439
|
// Configure the bottom axis
|
|
8305
8440
|
|
|
8306
8441
|
var bottomDomain = this.createDomain('bottom');
|
|
8442
|
+
var bottomBrushDomain = this.createDomain('bottom', true);
|
|
8307
8443
|
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range([0, this.plotWidth]);
|
|
8308
8444
|
|
|
8445
|
+
if (!this.brushInitialized) {
|
|
8446
|
+
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range([0, this.plotWidth]);
|
|
8447
|
+
}
|
|
8448
|
+
|
|
8309
8449
|
if (this.bottomAxis.nice) {// this.bottomAxis.nice()
|
|
8310
8450
|
}
|
|
8311
8451
|
|
|
8312
8452
|
if (this.bottomAxis.padding && this.options.data.bottom.padding) {
|
|
8313
8453
|
this.bottomAxis.padding(this.options.data.bottom.padding || 0);
|
|
8454
|
+
} // BRUSH
|
|
8455
|
+
|
|
8456
|
+
|
|
8457
|
+
var brushMethod = "brushX";
|
|
8458
|
+
var brushLength = this.plotWidth;
|
|
8459
|
+
var brushEnd = this.plotWidth;
|
|
8460
|
+
var brushThickness = this.options.brushHeight;
|
|
8461
|
+
|
|
8462
|
+
if (this.options.orientation === 'horizontal') {
|
|
8463
|
+
brushMethod = 'brushY';
|
|
8464
|
+
brushLength = this.options.brushHeight;
|
|
8465
|
+
brushThickness = this.plotHeight;
|
|
8466
|
+
} else {
|
|
8467
|
+
if (brushLength / bottomDomain.length < this.options.minBandWidth) {
|
|
8468
|
+
brushEnd = this.plotWidth * (this.plotWidth / this.options.minBandWidth / bottomDomain.length);
|
|
8469
|
+
}
|
|
8470
|
+
}
|
|
8471
|
+
|
|
8472
|
+
this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
|
|
8473
|
+
|
|
8474
|
+
var brushResizePath = function brushResizePath(d) {
|
|
8475
|
+
var e = +(d.type === 'e');
|
|
8476
|
+
var x = e ? 1 : -1;
|
|
8477
|
+
var y = _this47.options.brushHeight;
|
|
8478
|
+
return 'M' + 0.5 * x + ',' + y + 'A6,6 0 0 ' + e + ' ' + 6.5 * x + ',' + (y + 6) + 'V' + (2 * y - 6) + 'A6,6 0 0 ' + e + ' ' + 0.5 * x + ',' + 2 * y + 'Z' + 'M' + 2.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8) + 'M' + 4.5 * x + ',' + (y + 8) + 'V' + (2 * y - 8);
|
|
8479
|
+
};
|
|
8480
|
+
|
|
8481
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').remove();
|
|
8482
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').data([{
|
|
8483
|
+
type: 'w'
|
|
8484
|
+
}, {
|
|
8485
|
+
type: 'e'
|
|
8486
|
+
}]).enter().append('path').attr('class', 'handle--custom').attr('stroke', 'transparent').attr('fill', 'transparent').attr('cursor', 'ew-resize').attr('d', brushResizePath); // BRUSH END
|
|
8487
|
+
// this.brushArea.selectAll('*').remove()
|
|
8488
|
+
|
|
8489
|
+
if (this.brushNeeded) {
|
|
8490
|
+
if (!this.brushInitialized) {
|
|
8491
|
+
this.brushInitialized = true;
|
|
8492
|
+
this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
|
|
8493
|
+
}
|
|
8494
|
+
} else {
|
|
8495
|
+
this.brushLayer.selectAll().remove();
|
|
8314
8496
|
}
|
|
8315
8497
|
|
|
8316
8498
|
if (this.options.margin.axisBottom > 0) {
|
|
@@ -8364,17 +8546,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8364
8546
|
}
|
|
8365
8547
|
|
|
8366
8548
|
this.options.calculatedTimeFormatPattern = timeFormatPattern;
|
|
8367
|
-
|
|
8368
|
-
.ticks(tickDefinition); // console.log('tickDefinition', tickDefinition)
|
|
8369
|
-
// console.log(bAxisFunc)
|
|
8549
|
+
this.bAxisFunc = d3.axisBottom(this.bottomAxis).ticks(tickDefinition);
|
|
8370
8550
|
|
|
8371
8551
|
if (this.options.data.bottom.formatter) {
|
|
8372
|
-
bAxisFunc.tickFormat(function (d) {
|
|
8552
|
+
this.bAxisFunc.tickFormat(function (d) {
|
|
8373
8553
|
return _this47.options.data.bottom.formatter(d);
|
|
8374
8554
|
});
|
|
8375
8555
|
}
|
|
8376
8556
|
|
|
8377
|
-
this.bottomAxisLayer.call(bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
8557
|
+
this.bottomAxisLayer.call(this.bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
8378
8558
|
|
|
8379
8559
|
if (this.options.data.bottom.rotate) {
|
|
8380
8560
|
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"));
|
|
@@ -8383,8 +8563,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8383
8563
|
|
|
8384
8564
|
|
|
8385
8565
|
var leftDomain = this.createDomain('left');
|
|
8566
|
+
var leftBrushDomain = this.createDomain('left', true);
|
|
8386
8567
|
var rightDomain = this.createDomain('right');
|
|
8387
8568
|
this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range([this.plotHeight, 0]);
|
|
8569
|
+
this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range([this.options.brushHeight, 0]);
|
|
8388
8570
|
|
|
8389
8571
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
8390
8572
|
this.leftAxis.padding(this.options.data.left.padding || 0);
|
|
@@ -8431,7 +8613,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8431
8613
|
}
|
|
8432
8614
|
|
|
8433
8615
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
8434
|
-
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.
|
|
8616
|
+
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
|
|
8435
8617
|
if (_this47.options.data.right.formatter) {
|
|
8436
8618
|
d = _this47.options.data.right.formatter(d);
|
|
8437
8619
|
}
|
|
@@ -8466,48 +8648,55 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8466
8648
|
// remove the components
|
|
8467
8649
|
this["remove".concat(this.renderedKeys[key])](key);
|
|
8468
8650
|
}
|
|
8469
|
-
}
|
|
8651
|
+
}
|
|
8470
8652
|
|
|
8653
|
+
this.renderComponents();
|
|
8654
|
+
}
|
|
8655
|
+
}
|
|
8656
|
+
}
|
|
8657
|
+
}, {
|
|
8658
|
+
key: "renderComponents",
|
|
8659
|
+
value: function renderComponents() {
|
|
8660
|
+
var _this48 = this;
|
|
8471
8661
|
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8662
|
+
// Draw the series data
|
|
8663
|
+
this.renderedKeys = {};
|
|
8664
|
+
this.options.data.series.forEach(function (series, index) {
|
|
8665
|
+
if (!series.key) {
|
|
8666
|
+
series.key = _this48.createIdentity();
|
|
8667
|
+
}
|
|
8477
8668
|
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8669
|
+
if (!series.color) {
|
|
8670
|
+
series.color = _this48.options.colors[index % _this48.options.colors.length];
|
|
8671
|
+
}
|
|
8481
8672
|
|
|
8482
|
-
|
|
8673
|
+
_this48["render".concat(series.type || 'bar')](series, index);
|
|
8483
8674
|
|
|
8484
|
-
|
|
8675
|
+
_this48.renderLabels(series, index);
|
|
8485
8676
|
|
|
8486
|
-
|
|
8487
|
-
|
|
8677
|
+
_this48.renderedKeys[series.key] = series.type;
|
|
8678
|
+
});
|
|
8488
8679
|
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
}
|
|
8494
|
-
}
|
|
8680
|
+
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8681
|
+
this.options.refLines.forEach(function (l) {
|
|
8682
|
+
return _this48.renderRefLine(l);
|
|
8683
|
+
});
|
|
8495
8684
|
}
|
|
8496
8685
|
}
|
|
8497
8686
|
}, {
|
|
8498
8687
|
key: "renderarea",
|
|
8499
8688
|
value: function renderarea(series, index) {
|
|
8500
|
-
var
|
|
8689
|
+
var _this49 = this;
|
|
8501
8690
|
|
|
8502
8691
|
/* global d3 series index */
|
|
8503
8692
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
8504
8693
|
return d3.area().x(function (d) {
|
|
8505
|
-
return
|
|
8694
|
+
return _this49[xAxis](_this49.parseX(d.x.value));
|
|
8506
8695
|
}).y0(function (d) {
|
|
8507
|
-
return
|
|
8696
|
+
return _this49[yAxis](0);
|
|
8508
8697
|
}).y1(function (d) {
|
|
8509
|
-
return
|
|
8510
|
-
}).curve(d3[curveStyle ||
|
|
8698
|
+
return _this49[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8699
|
+
}).curve(d3[curveStyle || _this49.options.curveStyle]);
|
|
8511
8700
|
};
|
|
8512
8701
|
|
|
8513
8702
|
var xAxis = 'bottomAxis';
|
|
@@ -8542,90 +8731,189 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8542
8731
|
}, {
|
|
8543
8732
|
key: "renderbar",
|
|
8544
8733
|
value: function renderbar(series, index) {
|
|
8734
|
+
var _this50 = this;
|
|
8735
|
+
|
|
8545
8736
|
/* global series index d3 */
|
|
8546
8737
|
var xAxis = 'bottom';
|
|
8547
8738
|
var yAxis = 'left';
|
|
8548
8739
|
var bars = this.barLayer.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8740
|
+
var brushBars = this.brushArea.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8549
8741
|
var acummulativeY = new Array(this.options.data.series.length).fill(0);
|
|
8550
8742
|
|
|
8551
8743
|
if (this.options.orientation === 'horizontal') {
|
|
8552
8744
|
xAxis = 'left';
|
|
8553
8745
|
yAxis = 'bottom';
|
|
8554
|
-
}
|
|
8555
|
-
|
|
8556
|
-
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8557
|
-
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length; // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8746
|
+
} // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8558
8747
|
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8559
8748
|
// }
|
|
8560
8749
|
|
|
8561
|
-
|
|
8750
|
+
|
|
8751
|
+
function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
|
|
8752
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8753
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8754
|
+
var output;
|
|
8755
|
+
|
|
8562
8756
|
if (this.options.orientation === 'horizontal') {
|
|
8563
|
-
|
|
8757
|
+
output = barWidth;
|
|
8564
8758
|
} else {
|
|
8565
|
-
|
|
8759
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8760
|
+
return null;
|
|
8761
|
+
}
|
|
8762
|
+
|
|
8763
|
+
output = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
8764
|
+
}
|
|
8765
|
+
|
|
8766
|
+
if (isNaN(output)) {
|
|
8767
|
+
return null;
|
|
8566
8768
|
}
|
|
8769
|
+
|
|
8770
|
+
return output;
|
|
8567
8771
|
}
|
|
8568
8772
|
|
|
8569
|
-
function getBarWidth(d, i) {
|
|
8773
|
+
function getBarWidth(d, i, xAxis) {
|
|
8774
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8775
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8776
|
+
var output;
|
|
8777
|
+
|
|
8570
8778
|
if (this.options.orientation === 'horizontal') {
|
|
8571
8779
|
var width = this["".concat(yAxis, "Axis")](d.y.value);
|
|
8572
8780
|
acummulativeY[d.y.index] += width;
|
|
8573
|
-
|
|
8781
|
+
output = Math.max(1, width);
|
|
8574
8782
|
} else {
|
|
8783
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8784
|
+
return null;
|
|
8785
|
+
}
|
|
8786
|
+
|
|
8575
8787
|
if (this.options.grouping === 'grouped') {
|
|
8576
|
-
|
|
8788
|
+
output = Math.max(1, groupedBarWidth);
|
|
8789
|
+
} else {
|
|
8790
|
+
output = Math.max(1, barWidth);
|
|
8577
8791
|
}
|
|
8792
|
+
}
|
|
8578
8793
|
|
|
8579
|
-
|
|
8794
|
+
if (isNaN(output)) {
|
|
8795
|
+
return 0;
|
|
8580
8796
|
}
|
|
8797
|
+
|
|
8798
|
+
return output;
|
|
8581
8799
|
}
|
|
8582
8800
|
|
|
8583
|
-
function getBarX(d, i) {
|
|
8801
|
+
function getBarX(d, i, xAxis) {
|
|
8802
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8803
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8804
|
+
var output;
|
|
8805
|
+
|
|
8584
8806
|
if (this.options.orientation === 'horizontal') {
|
|
8585
8807
|
if (this.options.grouping === 'stacked') {
|
|
8586
|
-
|
|
8808
|
+
output = this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8587
8809
|
} else {
|
|
8588
|
-
|
|
8810
|
+
output = 0;
|
|
8589
8811
|
}
|
|
8590
8812
|
} else {
|
|
8591
|
-
var adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8813
|
+
var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8592
8814
|
|
|
8593
8815
|
if (this.options.grouping === 'grouped') {
|
|
8594
|
-
var barAdjustment = groupedBarWidth * index + 5; // + (index > 0 ? 4 : 0)
|
|
8816
|
+
var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
|
|
8595
8817
|
|
|
8596
|
-
|
|
8818
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
|
|
8597
8819
|
} else {
|
|
8598
|
-
|
|
8820
|
+
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
8821
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
|
|
8599
8822
|
}
|
|
8600
8823
|
}
|
|
8824
|
+
|
|
8825
|
+
if (isNaN(output)) {
|
|
8826
|
+
return null;
|
|
8827
|
+
}
|
|
8828
|
+
|
|
8829
|
+
return output;
|
|
8601
8830
|
}
|
|
8602
8831
|
|
|
8603
|
-
function getBarY(d, i) {
|
|
8832
|
+
function getBarY(d, i, heightBounds, yAxis, xAxis) {
|
|
8833
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8834
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8835
|
+
var output;
|
|
8836
|
+
|
|
8604
8837
|
if (this.options.orientation === 'horizontal') {
|
|
8605
8838
|
if (this.options.grouping !== 'grouped') {
|
|
8606
|
-
|
|
8839
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
|
|
8607
8840
|
} else {
|
|
8608
|
-
|
|
8841
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
|
|
8609
8842
|
}
|
|
8610
8843
|
} else {
|
|
8611
8844
|
if (this.options.grouping === 'stacked') {
|
|
8612
|
-
|
|
8845
|
+
output = heightBounds - this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8613
8846
|
} else {
|
|
8614
|
-
|
|
8847
|
+
var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
|
|
8848
|
+
output = this["".concat(yAxis, "Axis")](0) - h * (d.y.value < 0 ? 0 : 1);
|
|
8615
8849
|
}
|
|
8616
8850
|
}
|
|
8851
|
+
|
|
8852
|
+
if (isNaN(output)) {
|
|
8853
|
+
return null;
|
|
8854
|
+
}
|
|
8855
|
+
|
|
8856
|
+
return output;
|
|
8617
8857
|
}
|
|
8618
8858
|
|
|
8619
8859
|
bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8620
|
-
bars.attr('width',
|
|
8860
|
+
bars.attr('width', function (d, i) {
|
|
8861
|
+
return getBarWidth.call(_this50, d, i, xAxis);
|
|
8862
|
+
}).attr('height', function (d, i) {
|
|
8863
|
+
return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8864
|
+
}).attr('x', function (d, i) {
|
|
8865
|
+
return getBarX.call(_this50, d, i, xAxis);
|
|
8866
|
+
}).attr('y', function (d, i) {
|
|
8867
|
+
return getBarY.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8868
|
+
}) // .transition(this.transition)
|
|
8869
|
+
.attr('fill', function (d) {
|
|
8621
8870
|
return d.y.color || d.color || series.color;
|
|
8622
8871
|
});
|
|
8623
|
-
bars.enter().append('rect').attr('width',
|
|
8872
|
+
bars.enter().append('rect').attr('width', function (d, i) {
|
|
8873
|
+
return getBarWidth.call(_this50, d, i, xAxis);
|
|
8874
|
+
}).attr('height', function (d, i) {
|
|
8875
|
+
return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8876
|
+
}).attr('x', function (d, i) {
|
|
8877
|
+
return getBarX.call(_this50, d, i, xAxis);
|
|
8878
|
+
}).attr('y', function (d, i) {
|
|
8879
|
+
return getBarY.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8880
|
+
}) // .transition(this.transition)
|
|
8624
8881
|
.attr('fill', function (d) {
|
|
8625
8882
|
return d.y.color || d.color || series.color;
|
|
8626
8883
|
}).attr('class', function (d) {
|
|
8627
8884
|
return "bar bar_".concat(series.key);
|
|
8628
8885
|
});
|
|
8886
|
+
|
|
8887
|
+
if (!this.brushBarsInitialized[series.key]) {
|
|
8888
|
+
this.brushBarsInitialized[series.key] = true;
|
|
8889
|
+
brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8890
|
+
brushBars.attr('width', function (d, i) {
|
|
8891
|
+
return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8892
|
+
}).attr('height', function (d, i) {
|
|
8893
|
+
return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8894
|
+
}).attr('x', function (d, i) {
|
|
8895
|
+
return getBarX.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8896
|
+
}).attr('y', function (d, i) {
|
|
8897
|
+
return getBarY.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8898
|
+
}) // .transition(this.transition)
|
|
8899
|
+
.attr('fill', function (d) {
|
|
8900
|
+
return d.y.color || d.color || series.color;
|
|
8901
|
+
});
|
|
8902
|
+
brushBars.enter().append('rect').attr('width', function (d, i) {
|
|
8903
|
+
return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8904
|
+
}).attr('height', function (d, i) {
|
|
8905
|
+
return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8906
|
+
}).attr('x', function (d, i) {
|
|
8907
|
+
return getBarX.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8908
|
+
}).attr('y', function (d, i) {
|
|
8909
|
+
return getBarY.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8910
|
+
}) // .transition(this.transition)
|
|
8911
|
+
.attr('fill', function (d) {
|
|
8912
|
+
return d.y.color || d.color || series.color;
|
|
8913
|
+
}).attr('class', function (d) {
|
|
8914
|
+
return "bar bar_".concat(series.key);
|
|
8915
|
+
});
|
|
8916
|
+
}
|
|
8629
8917
|
}
|
|
8630
8918
|
}, {
|
|
8631
8919
|
key: "removebar",
|
|
@@ -8636,7 +8924,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8636
8924
|
}, {
|
|
8637
8925
|
key: "renderLabels",
|
|
8638
8926
|
value: function renderLabels(series, index) {
|
|
8639
|
-
var
|
|
8927
|
+
var _this51 = this;
|
|
8640
8928
|
|
|
8641
8929
|
/* global series index d3 WebsyDesigns */
|
|
8642
8930
|
var xAxis = 'bottomAxis';
|
|
@@ -8655,15 +8943,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8655
8943
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
8656
8944
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
8657
8945
|
labels.attr('x', function (d) {
|
|
8658
|
-
return getLabelX.call(
|
|
8946
|
+
return getLabelX.call(_this51, d, series.labelPosition);
|
|
8659
8947
|
}).attr('y', function (d) {
|
|
8660
|
-
return getLabelY.call(
|
|
8948
|
+
return getLabelY.call(_this51, d, series.labelPosition);
|
|
8661
8949
|
}).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
|
|
8662
|
-
if (
|
|
8950
|
+
if (_this51.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8663
8951
|
return 'transparent';
|
|
8664
8952
|
}
|
|
8665
8953
|
|
|
8666
|
-
return
|
|
8954
|
+
return _this51.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8667
8955
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
8668
8956
|
return d.y.label || d.y.value;
|
|
8669
8957
|
}).each(function (d, i) {
|
|
@@ -8688,15 +8976,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8688
8976
|
}
|
|
8689
8977
|
});
|
|
8690
8978
|
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
|
|
8691
|
-
return getLabelX.call(
|
|
8979
|
+
return getLabelX.call(_this51, d, series.labelPosition);
|
|
8692
8980
|
}).attr('y', function (d) {
|
|
8693
|
-
return getLabelY.call(
|
|
8981
|
+
return getLabelY.call(_this51, d, series.labelPosition);
|
|
8694
8982
|
}).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
|
|
8695
|
-
if (
|
|
8983
|
+
if (_this51.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8696
8984
|
return 'transparent';
|
|
8697
8985
|
}
|
|
8698
8986
|
|
|
8699
|
-
return
|
|
8987
|
+
return _this51.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8700
8988
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
8701
8989
|
return d.y.label || d.y.value;
|
|
8702
8990
|
}).each(function (d, i) {
|
|
@@ -8753,16 +9041,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8753
9041
|
}, {
|
|
8754
9042
|
key: "renderline",
|
|
8755
9043
|
value: function renderline(series, index) {
|
|
8756
|
-
var
|
|
9044
|
+
var _this52 = this;
|
|
8757
9045
|
|
|
8758
9046
|
/* global series index d3 */
|
|
8759
9047
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
8760
9048
|
return d3.line().x(function (d) {
|
|
8761
|
-
var adjustment =
|
|
8762
|
-
return
|
|
9049
|
+
var adjustment = _this52.options.data[xAxis].scale === 'Time' ? 0 : _this52["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9050
|
+
return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value)) + adjustment;
|
|
8763
9051
|
}).y(function (d) {
|
|
8764
|
-
return
|
|
8765
|
-
}).curve(d3[curveStyle ||
|
|
9052
|
+
return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
9053
|
+
}).curve(d3[curveStyle || _this52.options.curveStyle]);
|
|
8766
9054
|
};
|
|
8767
9055
|
|
|
8768
9056
|
var xAxis = 'bottom';
|
|
@@ -8834,14 +9122,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8834
9122
|
}, {
|
|
8835
9123
|
key: "rendersymbol",
|
|
8836
9124
|
value: function rendersymbol(series, index) {
|
|
8837
|
-
var
|
|
9125
|
+
var _this53 = this;
|
|
8838
9126
|
|
|
8839
9127
|
/* global d3 series index series.key */
|
|
8840
9128
|
var drawSymbol = function drawSymbol(size) {
|
|
8841
9129
|
return d3.symbol() // .type(d => {
|
|
8842
9130
|
// return d3.symbols[0]
|
|
8843
9131
|
// })
|
|
8844
|
-
.size(size ||
|
|
9132
|
+
.size(size || _this53.options.symbolSize);
|
|
8845
9133
|
};
|
|
8846
9134
|
|
|
8847
9135
|
var xAxis = 'bottom';
|
|
@@ -8859,8 +9147,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8859
9147
|
symbols.attr('d', function (d) {
|
|
8860
9148
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
8861
9149
|
}).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
8862
|
-
var adjustment =
|
|
8863
|
-
return "translate(".concat(
|
|
9150
|
+
var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9151
|
+
return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8864
9152
|
}); // Enter
|
|
8865
9153
|
|
|
8866
9154
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -8869,8 +9157,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8869
9157
|
.attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
8870
9158
|
return "symbol symbol_".concat(series.key);
|
|
8871
9159
|
}).attr('transform', function (d) {
|
|
8872
|
-
var adjustment =
|
|
8873
|
-
return "translate(".concat(
|
|
9160
|
+
var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9161
|
+
return "translate(".concat(_this53["".concat(xAxis, "Axis")](_this53.parseX(d.x.value)) + adjustment, ", ").concat(_this53["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8874
9162
|
});
|
|
8875
9163
|
}
|
|
8876
9164
|
}, {
|
|
@@ -8958,6 +9246,58 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8958
9246
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8959
9247
|
}
|
|
8960
9248
|
}
|
|
9249
|
+
}, {
|
|
9250
|
+
key: "hideError",
|
|
9251
|
+
value: function hideError() {
|
|
9252
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
9253
|
+
|
|
9254
|
+
if (el) {
|
|
9255
|
+
el.classList.remove('has-error');
|
|
9256
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
9257
|
+
// chartEl.classList.remove('hidden')
|
|
9258
|
+
|
|
9259
|
+
|
|
9260
|
+
this.svg.classed('hidden', false);
|
|
9261
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
9262
|
+
|
|
9263
|
+
if (containerEl) {
|
|
9264
|
+
containerEl.classList.remove('active');
|
|
9265
|
+
}
|
|
9266
|
+
}
|
|
9267
|
+
}, {
|
|
9268
|
+
key: "showError",
|
|
9269
|
+
value: function showError(options) {
|
|
9270
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
9271
|
+
|
|
9272
|
+
if (el) {
|
|
9273
|
+
el.classList.add('has-error');
|
|
9274
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
9275
|
+
// chartEl.classList.add('hidden')
|
|
9276
|
+
|
|
9277
|
+
|
|
9278
|
+
this.svg.classed('hidden', true);
|
|
9279
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
9280
|
+
|
|
9281
|
+
if (containerEl) {
|
|
9282
|
+
containerEl.classList.add('active');
|
|
9283
|
+
}
|
|
9284
|
+
|
|
9285
|
+
if (options.title) {
|
|
9286
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
9287
|
+
|
|
9288
|
+
if (titleEl) {
|
|
9289
|
+
titleEl.innerHTML = options.title;
|
|
9290
|
+
}
|
|
9291
|
+
}
|
|
9292
|
+
|
|
9293
|
+
if (options.message) {
|
|
9294
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
9295
|
+
|
|
9296
|
+
if (messageEl) {
|
|
9297
|
+
messageEl.innerHTML = options.message;
|
|
9298
|
+
}
|
|
9299
|
+
}
|
|
9300
|
+
}
|
|
8961
9301
|
}, {
|
|
8962
9302
|
key: "data",
|
|
8963
9303
|
set: function set(d) {
|
|
@@ -9025,7 +9365,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9025
9365
|
}, {
|
|
9026
9366
|
key: "resize",
|
|
9027
9367
|
value: function resize() {
|
|
9028
|
-
var
|
|
9368
|
+
var _this54 = this;
|
|
9029
9369
|
|
|
9030
9370
|
var el = document.getElementById(this.elementId);
|
|
9031
9371
|
|
|
@@ -9038,7 +9378,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9038
9378
|
// }
|
|
9039
9379
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
9040
9380
|
html += this._data.map(function (d, i) {
|
|
9041
|
-
return
|
|
9381
|
+
return _this54.getLegendItemHTML(d);
|
|
9042
9382
|
}).join('');
|
|
9043
9383
|
html += "\n <div>\n ";
|
|
9044
9384
|
el.innerHTML = html;
|
|
@@ -9210,7 +9550,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9210
9550
|
}, {
|
|
9211
9551
|
key: "render",
|
|
9212
9552
|
value: function render() {
|
|
9213
|
-
var
|
|
9553
|
+
var _this55 = this;
|
|
9214
9554
|
|
|
9215
9555
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
9216
9556
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -9219,7 +9559,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9219
9559
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
9220
9560
|
return {
|
|
9221
9561
|
value: s.label || s.key,
|
|
9222
|
-
color: s.color ||
|
|
9562
|
+
color: s.color || _this55.options.colors[i % _this55.options.colors.length]
|
|
9223
9563
|
};
|
|
9224
9564
|
});
|
|
9225
9565
|
var longestValue = legendData.map(function (s) {
|
|
@@ -9283,7 +9623,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9283
9623
|
|
|
9284
9624
|
if (this.polygons) {
|
|
9285
9625
|
this.polygons.forEach(function (p) {
|
|
9286
|
-
return
|
|
9626
|
+
return _this55.map.removeLayer(p);
|
|
9287
9627
|
});
|
|
9288
9628
|
}
|
|
9289
9629
|
|
|
@@ -9341,18 +9681,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9341
9681
|
}
|
|
9342
9682
|
|
|
9343
9683
|
if (!p.options.color) {
|
|
9344
|
-
p.options.color =
|
|
9684
|
+
p.options.color = _this55.options.colors[i % _this55.options.colors.length];
|
|
9345
9685
|
}
|
|
9346
9686
|
|
|
9347
9687
|
var pol = L.polygon(p.data.map(function (c) {
|
|
9348
9688
|
return c.map(function (d) {
|
|
9349
9689
|
return [d.Latitude, d.Longitude];
|
|
9350
9690
|
});
|
|
9351
|
-
}), p.options).addTo(
|
|
9691
|
+
}), p.options).addTo(_this55.map);
|
|
9352
9692
|
|
|
9353
|
-
|
|
9693
|
+
_this55.polygons.push(pol);
|
|
9354
9694
|
|
|
9355
|
-
|
|
9695
|
+
_this55.map.fitBounds(pol.getBounds());
|
|
9356
9696
|
});
|
|
9357
9697
|
} // if (this.data.markers.length > 0) {
|
|
9358
9698
|
// el.classList.remove('hidden')
|