@websy/websy-designs 1.4.33 → 1.4.35
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 +460 -83
- package/dist/websy-designs-es6.js +487 -114
- package/dist/websy-designs-es6.min.js +1 -1
- package/dist/websy-designs.debug.js +460 -83
- package/dist/websy-designs.js +487 -114
- 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,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7656
7670
|
this.topAxis = null;
|
|
7657
7671
|
this.bottomAxis = null;
|
|
7658
7672
|
this.renderedKeys = {};
|
|
7673
|
+
this.brushedDomain = [];
|
|
7674
|
+
this.brushBarsInitialized = {};
|
|
7675
|
+
this.brushLinesInitialized = {};
|
|
7659
7676
|
|
|
7660
7677
|
if (!elementId) {
|
|
7661
7678
|
console.log('No element Id provided for Websy Chart');
|
|
@@ -7663,12 +7680,19 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7663
7680
|
}
|
|
7664
7681
|
|
|
7665
7682
|
this.invertOverride = function (input, input2) {
|
|
7666
|
-
var
|
|
7683
|
+
var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
7684
|
+
var xAxis = 'bottom';
|
|
7667
7685
|
|
|
7668
7686
|
if (_this45.options.orientation === 'horizontal') {
|
|
7669
|
-
xAxis = '
|
|
7687
|
+
xAxis = 'left';
|
|
7670
7688
|
}
|
|
7671
7689
|
|
|
7690
|
+
if (forBrush === true) {
|
|
7691
|
+
xAxis += 'Brush';
|
|
7692
|
+
}
|
|
7693
|
+
|
|
7694
|
+
xAxis += 'Axis';
|
|
7695
|
+
|
|
7672
7696
|
var width = _this45[xAxis].step();
|
|
7673
7697
|
|
|
7674
7698
|
var output;
|
|
@@ -7692,6 +7716,66 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7692
7716
|
return output;
|
|
7693
7717
|
};
|
|
7694
7718
|
|
|
7719
|
+
var that = this;
|
|
7720
|
+
|
|
7721
|
+
this.brushed = function (event) {
|
|
7722
|
+
console.log('brushing', event);
|
|
7723
|
+
that.brushedDomain = [];
|
|
7724
|
+
var xAxis = 'bottom';
|
|
7725
|
+
var xAxisCaps = 'Bottom';
|
|
7726
|
+
|
|
7727
|
+
if (that.options.orientation === 'horizontal') {
|
|
7728
|
+
xAxis = 'left';
|
|
7729
|
+
xAxisCaps = 'Left';
|
|
7730
|
+
}
|
|
7731
|
+
|
|
7732
|
+
if (!that["".concat(xAxis, "Axis")].invert) {
|
|
7733
|
+
that["".concat(xAxis, "Axis")].invert = that.invertOverride;
|
|
7734
|
+
}
|
|
7735
|
+
|
|
7736
|
+
var s = event.selection || that["".concat(xAxis, "Axis")].range();
|
|
7737
|
+
|
|
7738
|
+
if (!event.selection || event.selection.length === 0) {
|
|
7739
|
+
that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
|
|
7740
|
+
return;
|
|
7741
|
+
}
|
|
7742
|
+
|
|
7743
|
+
if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
7744
|
+
that.brushedDomain = s.map(that["".concat(xAxis, "BrushAxis")].invert, that[["".concat(xAxis, "Axis")]]);
|
|
7745
|
+
} else {
|
|
7746
|
+
var startEndOrdinal = s.map(function (a, b) {
|
|
7747
|
+
return that.bottomAxis.invert(a, b, true);
|
|
7748
|
+
}, that.bottomBrushAxis);
|
|
7749
|
+
|
|
7750
|
+
if (startEndOrdinal && startEndOrdinal.length === 2 && typeof startEndOrdinal[0] !== 'undefined' && typeof startEndOrdinal[1] !== 'undefined') {
|
|
7751
|
+
var domain = [];
|
|
7752
|
+
|
|
7753
|
+
var domainValues = _toConsumableArray(that["".concat(xAxis, "BrushAxis")].domain());
|
|
7754
|
+
|
|
7755
|
+
for (var i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7756
|
+
// domain.push(that.xRange[i])
|
|
7757
|
+
that.brushedDomain.push(domainValues[i]);
|
|
7758
|
+
}
|
|
7759
|
+
}
|
|
7760
|
+
}
|
|
7761
|
+
|
|
7762
|
+
if (that.brushedDomain.length > 0) {
|
|
7763
|
+
that["".concat(xAxis, "Axis")].domain(that.brushedDomain);
|
|
7764
|
+
that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
|
|
7765
|
+
}
|
|
7766
|
+
|
|
7767
|
+
if (that.leftAxis && that.bottomAxis) {
|
|
7768
|
+
that.renderComponents();
|
|
7769
|
+
|
|
7770
|
+
if (that.options.orientation === 'vertical') {
|
|
7771
|
+
// that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7772
|
+
if (that.options.data.bottom.rotate) {
|
|
7773
|
+
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"));
|
|
7774
|
+
}
|
|
7775
|
+
}
|
|
7776
|
+
}
|
|
7777
|
+
};
|
|
7778
|
+
|
|
7695
7779
|
var el = document.getElementById(this.elementId);
|
|
7696
7780
|
|
|
7697
7781
|
if (el) {
|
|
@@ -7701,10 +7785,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7701
7785
|
console.error('d3 library has not been loaded');
|
|
7702
7786
|
} else {
|
|
7703
7787
|
el.innerHTML = '';
|
|
7704
|
-
this.svg = d3.select(el).append('svg');
|
|
7788
|
+
this.svg = d3.select(el).append('svg'); // .attr('id', `${this.elementId}_chartContainer`)
|
|
7789
|
+
|
|
7705
7790
|
this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
|
|
7706
7791
|
this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
|
|
7707
|
-
this.prep();
|
|
7792
|
+
this.prep(); // el.innerHTML += `
|
|
7793
|
+
// <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
7794
|
+
// <div>
|
|
7795
|
+
// <div id="${this.elementId}_errorTitle"></div>
|
|
7796
|
+
// <div id="${this.elementId}_errorMessage"></div>
|
|
7797
|
+
// </div>
|
|
7798
|
+
// </div>
|
|
7799
|
+
// `
|
|
7708
7800
|
}
|
|
7709
7801
|
} else {
|
|
7710
7802
|
console.error("No element found with ID ".concat(this.elementId));
|
|
@@ -7730,30 +7822,43 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7730
7822
|
}, {
|
|
7731
7823
|
key: "createDomain",
|
|
7732
7824
|
value: function createDomain(side) {
|
|
7825
|
+
var forBrush = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
7733
7826
|
var domain = [];
|
|
7734
|
-
/* global d3 side domain:writable */
|
|
7827
|
+
/* global d3 side domain:writable forBrush */
|
|
7828
|
+
// if we have a brushed domain we use that
|
|
7735
7829
|
|
|
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];
|
|
7830
|
+
var xAxis = 'bottom';
|
|
7739
7831
|
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
}
|
|
7832
|
+
if (this.options.orientation === 'horizontal') {
|
|
7833
|
+
xAxis = 'left';
|
|
7743
7834
|
}
|
|
7744
7835
|
|
|
7745
|
-
if (this.
|
|
7746
|
-
domain = this.
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7836
|
+
if (this.brushedDomain.length > 0 && side === xAxis && forBrush === false) {
|
|
7837
|
+
domain = _toConsumableArray(this.brushedDomain);
|
|
7838
|
+
} else {
|
|
7839
|
+
// otherwise we create the domain
|
|
7840
|
+
if (typeof this.options.data[side].min !== 'undefined' && typeof this.options.data[side].max !== 'undefined') {
|
|
7841
|
+
// domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
|
|
7842
|
+
domain = [this.options.data[side].min, this.options.data[side].max];
|
|
7750
7843
|
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7844
|
+
if (this.options.forceZero === true) {
|
|
7845
|
+
domain = [Math.min(0, this.options.data[side].min), this.options.data[side].max];
|
|
7846
|
+
}
|
|
7847
|
+
}
|
|
7848
|
+
|
|
7849
|
+
if (this.options.data[side].data) {
|
|
7850
|
+
domain = this.options.data[side].data.map(function (d) {
|
|
7851
|
+
return d.value;
|
|
7852
|
+
});
|
|
7853
|
+
}
|
|
7854
|
+
|
|
7855
|
+
if (this.options.data[side].scale === 'Time') {
|
|
7856
|
+
var min = this.options.data[side].data[0].value;
|
|
7857
|
+
var max = this.options.data[side].data[this.options.data[side].data.length - 1].value;
|
|
7858
|
+
min = this.parseX(min);
|
|
7859
|
+
max = this.parseX(max);
|
|
7860
|
+
domain = [min, max];
|
|
7861
|
+
}
|
|
7757
7862
|
}
|
|
7758
7863
|
|
|
7759
7864
|
return domain;
|
|
@@ -7916,7 +8021,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7916
8021
|
});
|
|
7917
8022
|
tooltipHTML = " \n <ul>\n ";
|
|
7918
8023
|
tooltipHTML += tooltipData.map(function (d) {
|
|
7919
|
-
return "\n <li>\n <i style='background-color: ".concat(d.color, ";'></i>\n ").concat(d.tooltipLabel || '', "<span
|
|
8024
|
+
return "\n <li>\n <i style='background-color: ".concat(d.color, ";'></i>\n ").concat(d.tooltipLabel || '', "<span>: ").concat(d.tooltipValue || d.value, "</span>\n </li>\n ");
|
|
7920
8025
|
}).join('');
|
|
7921
8026
|
tooltipHTML += "</ul>";
|
|
7922
8027
|
var posOptions = {
|
|
@@ -7994,6 +8099,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7994
8099
|
key: "prep",
|
|
7995
8100
|
value: function prep() {
|
|
7996
8101
|
/* global d3 WebsyDesigns */
|
|
8102
|
+
this.defs = this.svg.append('defs');
|
|
8103
|
+
this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
|
|
8104
|
+
this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
|
|
7997
8105
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
|
|
7998
8106
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
|
|
7999
8107
|
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
|
|
@@ -8010,6 +8118,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8010
8118
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
|
|
8011
8119
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line');
|
|
8012
8120
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
|
|
8121
|
+
this.brushLayer = this.svg.append('g'); // .attr(
|
|
8122
|
+
// 'clip-path',
|
|
8123
|
+
// `url(#${this.elementId.replace(/\s/g, '_')}_brushclip)`
|
|
8124
|
+
// )
|
|
8125
|
+
|
|
8126
|
+
this.brushArea = this.brushLayer.append('g').attr('class', 'brush-area');
|
|
8127
|
+
this.brushLayer.append('g').attr('class', 'brush');
|
|
8013
8128
|
this.eventLayer = this.svg.append('g').attr('class', 'event-line').append('rect');
|
|
8014
8129
|
this.eventLayer.on('mouseout', this.handleEventMouseOut.bind(this)).on('mousemove', this.handleEventMouseMove.bind(this));
|
|
8015
8130
|
this.render();
|
|
@@ -8149,7 +8264,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8149
8264
|
|
|
8150
8265
|
if (this.options.data.bottom.formatter) {
|
|
8151
8266
|
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
|
|
8152
|
-
firstBottom = this.
|
|
8267
|
+
firstBottom = this.options.data.bottom.formatter(this.options.data.bottom.data[0].value).toString();
|
|
8153
8268
|
} else {
|
|
8154
8269
|
if (this.options.data.bottom.scale === 'Time') {
|
|
8155
8270
|
this.longestBottom = '01/01/2000';
|
|
@@ -8157,7 +8272,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8157
8272
|
} else {
|
|
8158
8273
|
this.longestBottom = this.options.data.bottom.data.reduce(function (a, b) {
|
|
8159
8274
|
return a.length > b.value.length ? a : b.value;
|
|
8160
|
-
}, '');
|
|
8275
|
+
}, ''); // firstBottom = (this.options.data.bottom.data[0] || [{value: ''}]).value
|
|
8276
|
+
|
|
8161
8277
|
firstBottom = this.options.data.bottom.data[0].value;
|
|
8162
8278
|
}
|
|
8163
8279
|
}
|
|
@@ -8249,7 +8365,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8249
8365
|
if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 && this.options.axis.hideBottom !== true) {
|
|
8250
8366
|
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2);
|
|
8251
8367
|
} 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,
|
|
8368
|
+
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, firstBottomWidth / 2);
|
|
8253
8369
|
} else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) > 0 && this.options.axis.hideBottom !== true) {
|
|
8254
8370
|
this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width);
|
|
8255
8371
|
} // if (this.options.data.bottom.rotate) {
|
|
@@ -8282,7 +8398,27 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8282
8398
|
|
|
8283
8399
|
|
|
8284
8400
|
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;
|
|
8401
|
+
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;
|
|
8402
|
+
this.brushNeeded = false;
|
|
8403
|
+
|
|
8404
|
+
if (this.options.orientation === 'vertical') {
|
|
8405
|
+
if (this.options.maxBandWidth) {
|
|
8406
|
+
this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth);
|
|
8407
|
+
} // some if to check if brushing is needed
|
|
8408
|
+
|
|
8409
|
+
|
|
8410
|
+
if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
|
|
8411
|
+
this.brushNeeded = true;
|
|
8412
|
+
this.plotHeight -= this.options.brushHeight;
|
|
8413
|
+
}
|
|
8414
|
+
} else {
|
|
8415
|
+
// some if to check if brushing is needed
|
|
8416
|
+
if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
|
|
8417
|
+
this.brushNeeded = true;
|
|
8418
|
+
this.plotWidth -= this.options.brushHeight;
|
|
8419
|
+
}
|
|
8420
|
+
} // Translate the layers
|
|
8421
|
+
|
|
8286
8422
|
|
|
8287
8423
|
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
8424
|
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 +8434,71 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8298
8434
|
this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8299
8435
|
this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8300
8436
|
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8437
|
+
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, ")"));
|
|
8438
|
+
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
8439
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8302
8440
|
var that = this;
|
|
8303
8441
|
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
8442
|
// Configure the bottom axis
|
|
8305
8443
|
|
|
8306
8444
|
var bottomDomain = this.createDomain('bottom');
|
|
8445
|
+
var bottomBrushDomain = this.createDomain('bottom', true);
|
|
8307
8446
|
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range([0, this.plotWidth]);
|
|
8308
8447
|
|
|
8448
|
+
if (!this.brushInitialized) {
|
|
8449
|
+
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range([0, this.plotWidth]);
|
|
8450
|
+
}
|
|
8451
|
+
|
|
8309
8452
|
if (this.bottomAxis.nice) {// this.bottomAxis.nice()
|
|
8310
8453
|
}
|
|
8311
8454
|
|
|
8312
8455
|
if (this.bottomAxis.padding && this.options.data.bottom.padding) {
|
|
8313
8456
|
this.bottomAxis.padding(this.options.data.bottom.padding || 0);
|
|
8457
|
+
} // BRUSH
|
|
8458
|
+
|
|
8459
|
+
|
|
8460
|
+
var brushMethod = "brushX";
|
|
8461
|
+
var brushLength = this.plotWidth;
|
|
8462
|
+
var brushEnd = this.plotWidth;
|
|
8463
|
+
var brushThickness = this.options.brushHeight;
|
|
8464
|
+
|
|
8465
|
+
if (this.options.orientation === 'horizontal') {
|
|
8466
|
+
brushMethod = 'brushY';
|
|
8467
|
+
brushLength = this.options.brushHeight;
|
|
8468
|
+
brushThickness = this.plotHeight;
|
|
8469
|
+
} else {
|
|
8470
|
+
if (brushLength / bottomDomain.length < this.options.minBandWidth) {
|
|
8471
|
+
brushEnd = this.plotWidth * (this.plotWidth / this.options.minBandWidth / bottomDomain.length);
|
|
8472
|
+
}
|
|
8473
|
+
}
|
|
8474
|
+
|
|
8475
|
+
this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
|
|
8476
|
+
|
|
8477
|
+
var brushResizePath = function brushResizePath(d) {
|
|
8478
|
+
var e = +(d.type === 'e');
|
|
8479
|
+
var x = e ? 1 : -1;
|
|
8480
|
+
var y = _this47.options.brushHeight;
|
|
8481
|
+
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);
|
|
8482
|
+
};
|
|
8483
|
+
|
|
8484
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').remove();
|
|
8485
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').data([{
|
|
8486
|
+
type: 'w'
|
|
8487
|
+
}, {
|
|
8488
|
+
type: 'e'
|
|
8489
|
+
}]).enter().append('path').attr('class', 'handle--custom').attr('stroke', 'transparent').attr('fill', 'transparent').attr('cursor', 'ew-resize').attr('d', brushResizePath); // BRUSH END
|
|
8490
|
+
// this.brushArea.selectAll('*').remove()
|
|
8491
|
+
|
|
8492
|
+
if (this.brushNeeded) {
|
|
8493
|
+
if (!this.brushInitialized) {
|
|
8494
|
+
this.brushLayer.style('visibility', 'visible');
|
|
8495
|
+
this.brushInitialized = true;
|
|
8496
|
+
this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
|
|
8497
|
+
}
|
|
8498
|
+
} else {
|
|
8499
|
+
this.brushLayer.style('visibility', 'hidden'); // this.brushLayer.selectAll().remove()
|
|
8500
|
+
|
|
8501
|
+
this.brushArea.selectAll('*').remove();
|
|
8314
8502
|
}
|
|
8315
8503
|
|
|
8316
8504
|
if (this.options.margin.axisBottom > 0) {
|
|
@@ -8364,17 +8552,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8364
8552
|
}
|
|
8365
8553
|
|
|
8366
8554
|
this.options.calculatedTimeFormatPattern = timeFormatPattern;
|
|
8367
|
-
|
|
8368
|
-
.ticks(tickDefinition); // console.log('tickDefinition', tickDefinition)
|
|
8369
|
-
// console.log(bAxisFunc)
|
|
8555
|
+
this.bAxisFunc = d3.axisBottom(this.bottomAxis).ticks(tickDefinition);
|
|
8370
8556
|
|
|
8371
8557
|
if (this.options.data.bottom.formatter) {
|
|
8372
|
-
bAxisFunc.tickFormat(function (d) {
|
|
8558
|
+
this.bAxisFunc.tickFormat(function (d) {
|
|
8373
8559
|
return _this47.options.data.bottom.formatter(d);
|
|
8374
8560
|
});
|
|
8375
8561
|
}
|
|
8376
8562
|
|
|
8377
|
-
this.bottomAxisLayer.call(bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
8563
|
+
this.bottomAxisLayer.call(this.bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
8378
8564
|
|
|
8379
8565
|
if (this.options.data.bottom.rotate) {
|
|
8380
8566
|
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 +8569,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8383
8569
|
|
|
8384
8570
|
|
|
8385
8571
|
var leftDomain = this.createDomain('left');
|
|
8572
|
+
var leftBrushDomain = this.createDomain('left', true);
|
|
8386
8573
|
var rightDomain = this.createDomain('right');
|
|
8387
8574
|
this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range([this.plotHeight, 0]);
|
|
8575
|
+
this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range([this.options.brushHeight, 0]);
|
|
8388
8576
|
|
|
8389
8577
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
8390
8578
|
this.leftAxis.padding(this.options.data.left.padding || 0);
|
|
@@ -8431,7 +8619,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8431
8619
|
}
|
|
8432
8620
|
|
|
8433
8621
|
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.
|
|
8622
|
+
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
|
|
8435
8623
|
if (_this47.options.data.right.formatter) {
|
|
8436
8624
|
d = _this47.options.data.right.formatter(d);
|
|
8437
8625
|
}
|
|
@@ -8466,48 +8654,55 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8466
8654
|
// remove the components
|
|
8467
8655
|
this["remove".concat(this.renderedKeys[key])](key);
|
|
8468
8656
|
}
|
|
8469
|
-
}
|
|
8657
|
+
}
|
|
8470
8658
|
|
|
8659
|
+
this.renderComponents();
|
|
8660
|
+
}
|
|
8661
|
+
}
|
|
8662
|
+
}
|
|
8663
|
+
}, {
|
|
8664
|
+
key: "renderComponents",
|
|
8665
|
+
value: function renderComponents() {
|
|
8666
|
+
var _this48 = this;
|
|
8471
8667
|
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8668
|
+
// Draw the series data
|
|
8669
|
+
this.renderedKeys = {};
|
|
8670
|
+
this.options.data.series.forEach(function (series, index) {
|
|
8671
|
+
if (!series.key) {
|
|
8672
|
+
series.key = _this48.createIdentity();
|
|
8673
|
+
}
|
|
8477
8674
|
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8675
|
+
if (!series.color) {
|
|
8676
|
+
series.color = _this48.options.colors[index % _this48.options.colors.length];
|
|
8677
|
+
}
|
|
8481
8678
|
|
|
8482
|
-
|
|
8679
|
+
_this48["render".concat(series.type || 'bar')](series, index);
|
|
8483
8680
|
|
|
8484
|
-
|
|
8681
|
+
_this48.renderLabels(series, index);
|
|
8485
8682
|
|
|
8486
|
-
|
|
8487
|
-
|
|
8683
|
+
_this48.renderedKeys[series.key] = series.type;
|
|
8684
|
+
});
|
|
8488
8685
|
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
|
|
8493
|
-
}
|
|
8494
|
-
}
|
|
8686
|
+
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8687
|
+
this.options.refLines.forEach(function (l) {
|
|
8688
|
+
return _this48.renderRefLine(l);
|
|
8689
|
+
});
|
|
8495
8690
|
}
|
|
8496
8691
|
}
|
|
8497
8692
|
}, {
|
|
8498
8693
|
key: "renderarea",
|
|
8499
8694
|
value: function renderarea(series, index) {
|
|
8500
|
-
var
|
|
8695
|
+
var _this49 = this;
|
|
8501
8696
|
|
|
8502
8697
|
/* global d3 series index */
|
|
8503
8698
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
8504
8699
|
return d3.area().x(function (d) {
|
|
8505
|
-
return
|
|
8700
|
+
return _this49[xAxis](_this49.parseX(d.x.value));
|
|
8506
8701
|
}).y0(function (d) {
|
|
8507
|
-
return
|
|
8702
|
+
return _this49[yAxis](0);
|
|
8508
8703
|
}).y1(function (d) {
|
|
8509
|
-
return
|
|
8510
|
-
}).curve(d3[curveStyle ||
|
|
8704
|
+
return _this49[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8705
|
+
}).curve(d3[curveStyle || _this49.options.curveStyle]);
|
|
8511
8706
|
};
|
|
8512
8707
|
|
|
8513
8708
|
var xAxis = 'bottomAxis';
|
|
@@ -8542,90 +8737,189 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8542
8737
|
}, {
|
|
8543
8738
|
key: "renderbar",
|
|
8544
8739
|
value: function renderbar(series, index) {
|
|
8740
|
+
var _this50 = this;
|
|
8741
|
+
|
|
8545
8742
|
/* global series index d3 */
|
|
8546
8743
|
var xAxis = 'bottom';
|
|
8547
8744
|
var yAxis = 'left';
|
|
8548
8745
|
var bars = this.barLayer.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8746
|
+
var brushBars = this.brushArea.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8549
8747
|
var acummulativeY = new Array(this.options.data.series.length).fill(0);
|
|
8550
8748
|
|
|
8551
8749
|
if (this.options.orientation === 'horizontal') {
|
|
8552
8750
|
xAxis = 'left';
|
|
8553
8751
|
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') {
|
|
8752
|
+
} // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8558
8753
|
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8559
8754
|
// }
|
|
8560
8755
|
|
|
8561
|
-
|
|
8756
|
+
|
|
8757
|
+
function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
|
|
8758
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8759
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8760
|
+
var output;
|
|
8761
|
+
|
|
8562
8762
|
if (this.options.orientation === 'horizontal') {
|
|
8563
|
-
|
|
8763
|
+
output = barWidth;
|
|
8564
8764
|
} else {
|
|
8565
|
-
|
|
8765
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8766
|
+
return null;
|
|
8767
|
+
}
|
|
8768
|
+
|
|
8769
|
+
output = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
8770
|
+
}
|
|
8771
|
+
|
|
8772
|
+
if (isNaN(output)) {
|
|
8773
|
+
return null;
|
|
8566
8774
|
}
|
|
8775
|
+
|
|
8776
|
+
return output;
|
|
8567
8777
|
}
|
|
8568
8778
|
|
|
8569
|
-
function getBarWidth(d, i) {
|
|
8779
|
+
function getBarWidth(d, i, xAxis) {
|
|
8780
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8781
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8782
|
+
var output;
|
|
8783
|
+
|
|
8570
8784
|
if (this.options.orientation === 'horizontal') {
|
|
8571
8785
|
var width = this["".concat(yAxis, "Axis")](d.y.value);
|
|
8572
8786
|
acummulativeY[d.y.index] += width;
|
|
8573
|
-
|
|
8787
|
+
output = Math.max(1, width);
|
|
8574
8788
|
} else {
|
|
8789
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8790
|
+
return null;
|
|
8791
|
+
}
|
|
8792
|
+
|
|
8575
8793
|
if (this.options.grouping === 'grouped') {
|
|
8576
|
-
|
|
8794
|
+
output = Math.max(1, groupedBarWidth);
|
|
8795
|
+
} else {
|
|
8796
|
+
output = Math.max(1, barWidth);
|
|
8577
8797
|
}
|
|
8798
|
+
}
|
|
8578
8799
|
|
|
8579
|
-
|
|
8800
|
+
if (isNaN(output)) {
|
|
8801
|
+
return 0;
|
|
8580
8802
|
}
|
|
8803
|
+
|
|
8804
|
+
return output;
|
|
8581
8805
|
}
|
|
8582
8806
|
|
|
8583
|
-
function getBarX(d, i) {
|
|
8807
|
+
function getBarX(d, i, xAxis) {
|
|
8808
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8809
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8810
|
+
var output;
|
|
8811
|
+
|
|
8584
8812
|
if (this.options.orientation === 'horizontal') {
|
|
8585
8813
|
if (this.options.grouping === 'stacked') {
|
|
8586
|
-
|
|
8814
|
+
output = this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8587
8815
|
} else {
|
|
8588
|
-
|
|
8816
|
+
output = 0;
|
|
8589
8817
|
}
|
|
8590
8818
|
} else {
|
|
8591
|
-
var adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8819
|
+
var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8592
8820
|
|
|
8593
8821
|
if (this.options.grouping === 'grouped') {
|
|
8594
|
-
var barAdjustment = groupedBarWidth * index + 5; // + (index > 0 ? 4 : 0)
|
|
8822
|
+
var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
|
|
8595
8823
|
|
|
8596
|
-
|
|
8824
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
|
|
8597
8825
|
} else {
|
|
8598
|
-
|
|
8826
|
+
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
8827
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
|
|
8599
8828
|
}
|
|
8600
8829
|
}
|
|
8830
|
+
|
|
8831
|
+
if (isNaN(output)) {
|
|
8832
|
+
return null;
|
|
8833
|
+
}
|
|
8834
|
+
|
|
8835
|
+
return output;
|
|
8601
8836
|
}
|
|
8602
8837
|
|
|
8603
|
-
function getBarY(d, i) {
|
|
8838
|
+
function getBarY(d, i, heightBounds, yAxis, xAxis) {
|
|
8839
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8840
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8841
|
+
var output;
|
|
8842
|
+
|
|
8604
8843
|
if (this.options.orientation === 'horizontal') {
|
|
8605
8844
|
if (this.options.grouping !== 'grouped') {
|
|
8606
|
-
|
|
8845
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
|
|
8607
8846
|
} else {
|
|
8608
|
-
|
|
8847
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
|
|
8609
8848
|
}
|
|
8610
8849
|
} else {
|
|
8611
8850
|
if (this.options.grouping === 'stacked') {
|
|
8612
|
-
|
|
8851
|
+
output = heightBounds - this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8613
8852
|
} else {
|
|
8614
|
-
|
|
8853
|
+
var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
|
|
8854
|
+
output = this["".concat(yAxis, "Axis")](0) - h * (d.y.value < 0 ? 0 : 1);
|
|
8615
8855
|
}
|
|
8616
8856
|
}
|
|
8857
|
+
|
|
8858
|
+
if (isNaN(output)) {
|
|
8859
|
+
return null;
|
|
8860
|
+
}
|
|
8861
|
+
|
|
8862
|
+
return output;
|
|
8617
8863
|
}
|
|
8618
8864
|
|
|
8619
8865
|
bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8620
|
-
bars.attr('width',
|
|
8866
|
+
bars.attr('width', function (d, i) {
|
|
8867
|
+
return getBarWidth.call(_this50, d, i, xAxis);
|
|
8868
|
+
}).attr('height', function (d, i) {
|
|
8869
|
+
return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8870
|
+
}).attr('x', function (d, i) {
|
|
8871
|
+
return getBarX.call(_this50, d, i, xAxis);
|
|
8872
|
+
}).attr('y', function (d, i) {
|
|
8873
|
+
return getBarY.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8874
|
+
}) // .transition(this.transition)
|
|
8875
|
+
.attr('fill', function (d) {
|
|
8621
8876
|
return d.y.color || d.color || series.color;
|
|
8622
8877
|
});
|
|
8623
|
-
bars.enter().append('rect').attr('width',
|
|
8878
|
+
bars.enter().append('rect').attr('width', function (d, i) {
|
|
8879
|
+
return getBarWidth.call(_this50, d, i, xAxis);
|
|
8880
|
+
}).attr('height', function (d, i) {
|
|
8881
|
+
return getBarHeight.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8882
|
+
}).attr('x', function (d, i) {
|
|
8883
|
+
return getBarX.call(_this50, d, i, xAxis);
|
|
8884
|
+
}).attr('y', function (d, i) {
|
|
8885
|
+
return getBarY.call(_this50, d, i, _this50.plotHeight, yAxis, xAxis);
|
|
8886
|
+
}) // .transition(this.transition)
|
|
8624
8887
|
.attr('fill', function (d) {
|
|
8625
8888
|
return d.y.color || d.color || series.color;
|
|
8626
8889
|
}).attr('class', function (d) {
|
|
8627
8890
|
return "bar bar_".concat(series.key);
|
|
8628
8891
|
});
|
|
8892
|
+
|
|
8893
|
+
if (!this.brushBarsInitialized[series.key]) {
|
|
8894
|
+
this.brushBarsInitialized[series.key] = true;
|
|
8895
|
+
brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8896
|
+
brushBars.attr('width', function (d, i) {
|
|
8897
|
+
return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8898
|
+
}).attr('height', function (d, i) {
|
|
8899
|
+
return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8900
|
+
}).attr('x', function (d, i) {
|
|
8901
|
+
return getBarX.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8902
|
+
}).attr('y', function (d, i) {
|
|
8903
|
+
return getBarY.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8904
|
+
}) // .transition(this.transition)
|
|
8905
|
+
.attr('fill', function (d) {
|
|
8906
|
+
return d.y.color || d.color || series.color;
|
|
8907
|
+
});
|
|
8908
|
+
brushBars.enter().append('rect').attr('width', function (d, i) {
|
|
8909
|
+
return getBarWidth.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8910
|
+
}).attr('height', function (d, i) {
|
|
8911
|
+
return getBarHeight.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8912
|
+
}).attr('x', function (d, i) {
|
|
8913
|
+
return getBarX.call(_this50, d, i, "".concat(xAxis, "Brush"));
|
|
8914
|
+
}).attr('y', function (d, i) {
|
|
8915
|
+
return getBarY.call(_this50, d, i, _this50.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8916
|
+
}) // .transition(this.transition)
|
|
8917
|
+
.attr('fill', function (d) {
|
|
8918
|
+
return d.y.color || d.color || series.color;
|
|
8919
|
+
}).attr('class', function (d) {
|
|
8920
|
+
return "bar bar_".concat(series.key);
|
|
8921
|
+
});
|
|
8922
|
+
}
|
|
8629
8923
|
}
|
|
8630
8924
|
}, {
|
|
8631
8925
|
key: "removebar",
|
|
@@ -8636,7 +8930,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8636
8930
|
}, {
|
|
8637
8931
|
key: "renderLabels",
|
|
8638
8932
|
value: function renderLabels(series, index) {
|
|
8639
|
-
var
|
|
8933
|
+
var _this51 = this;
|
|
8640
8934
|
|
|
8641
8935
|
/* global series index d3 WebsyDesigns */
|
|
8642
8936
|
var xAxis = 'bottomAxis';
|
|
@@ -8655,15 +8949,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8655
8949
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
8656
8950
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
8657
8951
|
labels.attr('x', function (d) {
|
|
8658
|
-
return getLabelX.call(
|
|
8952
|
+
return getLabelX.call(_this51, d, series.labelPosition);
|
|
8659
8953
|
}).attr('y', function (d) {
|
|
8660
|
-
return getLabelY.call(
|
|
8954
|
+
return getLabelY.call(_this51, d, series.labelPosition);
|
|
8661
8955
|
}).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
|
|
8662
|
-
if (
|
|
8956
|
+
if (_this51.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8663
8957
|
return 'transparent';
|
|
8664
8958
|
}
|
|
8665
8959
|
|
|
8666
|
-
return
|
|
8960
|
+
return _this51.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8667
8961
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
8668
8962
|
return d.y.label || d.y.value;
|
|
8669
8963
|
}).each(function (d, i) {
|
|
@@ -8688,15 +8982,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8688
8982
|
}
|
|
8689
8983
|
});
|
|
8690
8984
|
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
|
|
8691
|
-
return getLabelX.call(
|
|
8985
|
+
return getLabelX.call(_this51, d, series.labelPosition);
|
|
8692
8986
|
}).attr('y', function (d) {
|
|
8693
|
-
return getLabelY.call(
|
|
8987
|
+
return getLabelY.call(_this51, d, series.labelPosition);
|
|
8694
8988
|
}).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
|
|
8695
|
-
if (
|
|
8989
|
+
if (_this51.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8696
8990
|
return 'transparent';
|
|
8697
8991
|
}
|
|
8698
8992
|
|
|
8699
|
-
return
|
|
8993
|
+
return _this51.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8700
8994
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
8701
8995
|
return d.y.label || d.y.value;
|
|
8702
8996
|
}).each(function (d, i) {
|
|
@@ -8753,16 +9047,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8753
9047
|
}, {
|
|
8754
9048
|
key: "renderline",
|
|
8755
9049
|
value: function renderline(series, index) {
|
|
8756
|
-
var
|
|
9050
|
+
var _this52 = this;
|
|
8757
9051
|
|
|
8758
9052
|
/* global series index d3 */
|
|
8759
9053
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
8760
9054
|
return d3.line().x(function (d) {
|
|
8761
|
-
var adjustment =
|
|
8762
|
-
return
|
|
9055
|
+
var adjustment = _this52.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : _this52["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9056
|
+
return _this52["".concat(xAxis, "Axis")](_this52.parseX(d.x.value)) + adjustment;
|
|
8763
9057
|
}).y(function (d) {
|
|
8764
|
-
return
|
|
8765
|
-
}).curve(d3[curveStyle ||
|
|
9058
|
+
return _this52["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
9059
|
+
}).curve(d3[curveStyle || _this52.options.curveStyle]);
|
|
8766
9060
|
};
|
|
8767
9061
|
|
|
8768
9062
|
var xAxis = 'bottom';
|
|
@@ -8773,7 +9067,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8773
9067
|
yAxis = 'bottom';
|
|
8774
9068
|
}
|
|
8775
9069
|
|
|
8776
|
-
var
|
|
9070
|
+
var xBrushAxis = 'bottomBrush';
|
|
9071
|
+
var yBrushAxis = 'leftBrush';
|
|
9072
|
+
|
|
9073
|
+
if (this.options.orienation === 'horizontal') {
|
|
9074
|
+
xBrushAxis = 'leftBrush';
|
|
9075
|
+
yBrushAxis = 'bottomBrush';
|
|
9076
|
+
}
|
|
9077
|
+
|
|
9078
|
+
var lines = this.lineLayer.selectAll(".line_".concat(series.key)).data([series.data]);
|
|
9079
|
+
var brushLines = this.brushArea.selectAll(".line_".concat(series.key)).data([series.data]); // Exit
|
|
8777
9080
|
|
|
8778
9081
|
lines.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove(); // Update
|
|
8779
9082
|
|
|
@@ -8789,6 +9092,24 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8789
9092
|
.style('stroke-width', series.lineWidth || this.options.lineWidth).attr('stroke', series.color).attr('fill', 'transparent') // .transition(this.transition)
|
|
8790
9093
|
.style('stroke-opacity', 1);
|
|
8791
9094
|
|
|
9095
|
+
if (!this.brushLinesInitialized[series.key]) {
|
|
9096
|
+
this.brushLinesInitialized[series.key] = true; // Exit
|
|
9097
|
+
|
|
9098
|
+
brushLines.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove(); // Update
|
|
9099
|
+
|
|
9100
|
+
brushLines.style('stroke-width', 1) // .attr('id', `line_${series.key}`)
|
|
9101
|
+
// .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
9102
|
+
.attr('stroke', series.color).attr('fill', 'transparent').transition(this.transition).attr('d', function (d) {
|
|
9103
|
+
return drawLine(xBrushAxis, yBrushAxis, series.curveStyle)(d);
|
|
9104
|
+
}); // Enter
|
|
9105
|
+
|
|
9106
|
+
brushLines.enter().append('path').attr('d', function (d) {
|
|
9107
|
+
return drawLine(xBrushAxis, yBrushAxis, series.curveStyle)(d);
|
|
9108
|
+
}).attr('class', "line_".concat(series.key)).attr('id', "line_".concat(series.key)) // .attr('transform', 'translate('+ (that.bandWidth/2) +',0)')
|
|
9109
|
+
.style('stroke-width', 1).attr('stroke', series.color).attr('fill', 'transparent') // .transition(this.transition)
|
|
9110
|
+
.style('stroke-opacity', 1);
|
|
9111
|
+
}
|
|
9112
|
+
|
|
8792
9113
|
if (series.showArea === true) {
|
|
8793
9114
|
this.renderarea(series, index);
|
|
8794
9115
|
}
|
|
@@ -8834,14 +9155,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8834
9155
|
}, {
|
|
8835
9156
|
key: "rendersymbol",
|
|
8836
9157
|
value: function rendersymbol(series, index) {
|
|
8837
|
-
var
|
|
9158
|
+
var _this53 = this;
|
|
8838
9159
|
|
|
8839
9160
|
/* global d3 series index series.key */
|
|
8840
9161
|
var drawSymbol = function drawSymbol(size) {
|
|
8841
9162
|
return d3.symbol() // .type(d => {
|
|
8842
9163
|
// return d3.symbols[0]
|
|
8843
9164
|
// })
|
|
8844
|
-
.size(size ||
|
|
9165
|
+
.size(size || _this53.options.symbolSize);
|
|
8845
9166
|
};
|
|
8846
9167
|
|
|
8847
9168
|
var xAxis = 'bottom';
|
|
@@ -8859,8 +9180,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8859
9180
|
symbols.attr('d', function (d) {
|
|
8860
9181
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
8861
9182
|
}).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(
|
|
9183
|
+
var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9184
|
+
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
9185
|
}); // Enter
|
|
8865
9186
|
|
|
8866
9187
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -8869,8 +9190,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8869
9190
|
.attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
8870
9191
|
return "symbol symbol_".concat(series.key);
|
|
8871
9192
|
}).attr('transform', function (d) {
|
|
8872
|
-
var adjustment =
|
|
8873
|
-
return "translate(".concat(
|
|
9193
|
+
var adjustment = _this53.options.data[xAxis].scale === 'Time' ? 0 : _this53["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
9194
|
+
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
9195
|
});
|
|
8875
9196
|
}
|
|
8876
9197
|
}, {
|
|
@@ -8958,6 +9279,58 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8958
9279
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8959
9280
|
}
|
|
8960
9281
|
}
|
|
9282
|
+
}, {
|
|
9283
|
+
key: "hideError",
|
|
9284
|
+
value: function hideError() {
|
|
9285
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
9286
|
+
|
|
9287
|
+
if (el) {
|
|
9288
|
+
el.classList.remove('has-error');
|
|
9289
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
9290
|
+
// chartEl.classList.remove('hidden')
|
|
9291
|
+
|
|
9292
|
+
|
|
9293
|
+
this.svg.classed('hidden', false);
|
|
9294
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
9295
|
+
|
|
9296
|
+
if (containerEl) {
|
|
9297
|
+
containerEl.classList.remove('active');
|
|
9298
|
+
}
|
|
9299
|
+
}
|
|
9300
|
+
}, {
|
|
9301
|
+
key: "showError",
|
|
9302
|
+
value: function showError(options) {
|
|
9303
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
9304
|
+
|
|
9305
|
+
if (el) {
|
|
9306
|
+
el.classList.add('has-error');
|
|
9307
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
9308
|
+
// chartEl.classList.add('hidden')
|
|
9309
|
+
|
|
9310
|
+
|
|
9311
|
+
this.svg.classed('hidden', true);
|
|
9312
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
9313
|
+
|
|
9314
|
+
if (containerEl) {
|
|
9315
|
+
containerEl.classList.add('active');
|
|
9316
|
+
}
|
|
9317
|
+
|
|
9318
|
+
if (options.title) {
|
|
9319
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
9320
|
+
|
|
9321
|
+
if (titleEl) {
|
|
9322
|
+
titleEl.innerHTML = options.title;
|
|
9323
|
+
}
|
|
9324
|
+
}
|
|
9325
|
+
|
|
9326
|
+
if (options.message) {
|
|
9327
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
9328
|
+
|
|
9329
|
+
if (messageEl) {
|
|
9330
|
+
messageEl.innerHTML = options.message;
|
|
9331
|
+
}
|
|
9332
|
+
}
|
|
9333
|
+
}
|
|
8961
9334
|
}, {
|
|
8962
9335
|
key: "data",
|
|
8963
9336
|
set: function set(d) {
|
|
@@ -9025,7 +9398,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9025
9398
|
}, {
|
|
9026
9399
|
key: "resize",
|
|
9027
9400
|
value: function resize() {
|
|
9028
|
-
var
|
|
9401
|
+
var _this54 = this;
|
|
9029
9402
|
|
|
9030
9403
|
var el = document.getElementById(this.elementId);
|
|
9031
9404
|
|
|
@@ -9038,7 +9411,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
9038
9411
|
// }
|
|
9039
9412
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
9040
9413
|
html += this._data.map(function (d, i) {
|
|
9041
|
-
return
|
|
9414
|
+
return _this54.getLegendItemHTML(d);
|
|
9042
9415
|
}).join('');
|
|
9043
9416
|
html += "\n <div>\n ";
|
|
9044
9417
|
el.innerHTML = html;
|
|
@@ -9210,7 +9583,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9210
9583
|
}, {
|
|
9211
9584
|
key: "render",
|
|
9212
9585
|
value: function render() {
|
|
9213
|
-
var
|
|
9586
|
+
var _this55 = this;
|
|
9214
9587
|
|
|
9215
9588
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
9216
9589
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -9219,7 +9592,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9219
9592
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
9220
9593
|
return {
|
|
9221
9594
|
value: s.label || s.key,
|
|
9222
|
-
color: s.color ||
|
|
9595
|
+
color: s.color || _this55.options.colors[i % _this55.options.colors.length]
|
|
9223
9596
|
};
|
|
9224
9597
|
});
|
|
9225
9598
|
var longestValue = legendData.map(function (s) {
|
|
@@ -9283,7 +9656,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9283
9656
|
|
|
9284
9657
|
if (this.polygons) {
|
|
9285
9658
|
this.polygons.forEach(function (p) {
|
|
9286
|
-
return
|
|
9659
|
+
return _this55.map.removeLayer(p);
|
|
9287
9660
|
});
|
|
9288
9661
|
}
|
|
9289
9662
|
|
|
@@ -9341,18 +9714,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
9341
9714
|
}
|
|
9342
9715
|
|
|
9343
9716
|
if (!p.options.color) {
|
|
9344
|
-
p.options.color =
|
|
9717
|
+
p.options.color = _this55.options.colors[i % _this55.options.colors.length];
|
|
9345
9718
|
}
|
|
9346
9719
|
|
|
9347
9720
|
var pol = L.polygon(p.data.map(function (c) {
|
|
9348
9721
|
return c.map(function (d) {
|
|
9349
9722
|
return [d.Latitude, d.Longitude];
|
|
9350
9723
|
});
|
|
9351
|
-
}), p.options).addTo(
|
|
9724
|
+
}), p.options).addTo(_this55.map);
|
|
9352
9725
|
|
|
9353
|
-
|
|
9726
|
+
_this55.polygons.push(pol);
|
|
9354
9727
|
|
|
9355
|
-
|
|
9728
|
+
_this55.map.fitBounds(pol.getBounds());
|
|
9356
9729
|
});
|
|
9357
9730
|
} // if (this.data.markers.length > 0) {
|
|
9358
9731
|
// el.classList.remove('hidden')
|