@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
|
@@ -6686,6 +6686,12 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6686
6686
|
headEl.style.width = 'initial';
|
|
6687
6687
|
bodyEl.style.width = 'initial';
|
|
6688
6688
|
this.sizes.bodyHeight = this.sizes.table.height - (this.sizes.header.height + this.sizes.total.height);
|
|
6689
|
+
|
|
6690
|
+
if (this.options.maxHeight) {
|
|
6691
|
+
var requiredHeight = ((this.totalRowCount || 9) + 1) * this.sizes.cellHeight;
|
|
6692
|
+
this.sizes.bodyHeight = Math.min(requiredHeight, this.options.maxHeight - (this.sizes.header.height + this.sizes.total.height));
|
|
6693
|
+
}
|
|
6694
|
+
|
|
6689
6695
|
this.sizes.rowsToRender = Math.ceil(this.sizes.bodyHeight / this.sizes.cellHeight);
|
|
6690
6696
|
this.sizes.rowsToRenderPrecise = this.sizes.bodyHeight / this.sizes.cellHeight;
|
|
6691
6697
|
this.startRow = 0;
|
|
@@ -6906,8 +6912,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
|
|
|
6906
6912
|
}
|
|
6907
6913
|
|
|
6908
6914
|
var bodyEl = document.getElementById("".concat(this.elementId, "_tableBody")); // bodyEl.innerHTML = this.buildBodyHtml(data, true)
|
|
6915
|
+
// if (this.options.maxHeight) {
|
|
6916
|
+
// bodyEl.style.height = `${this.options.maxHeight - this.sizes.header.height - this.sizes.total.height}px`
|
|
6917
|
+
// }
|
|
6918
|
+
// else {
|
|
6919
|
+
// bodyEl.style.height = `calc(100% - ${this.sizes.header.height}px - ${this.sizes.total.height}px)`
|
|
6920
|
+
// }
|
|
6909
6921
|
|
|
6910
|
-
bodyEl.style.height = "
|
|
6922
|
+
bodyEl.style.height = "".concat(this.sizes.bodyHeight, "px");
|
|
6911
6923
|
|
|
6912
6924
|
if (this.options.virtualScroll === true) {
|
|
6913
6925
|
// set the scroll element positions
|
|
@@ -7171,7 +7183,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7171
7183
|
showTooltip: true,
|
|
7172
7184
|
showLegend: false,
|
|
7173
7185
|
legendPosition: 'bottom',
|
|
7174
|
-
tooltipWidth: 200
|
|
7186
|
+
tooltipWidth: 200,
|
|
7187
|
+
brushHeight: 50,
|
|
7188
|
+
minBandWidth: 30
|
|
7175
7189
|
};
|
|
7176
7190
|
this.elementId = elementId;
|
|
7177
7191
|
this.options = _extends({}, DEFAULTS, options);
|
|
@@ -7180,6 +7194,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7180
7194
|
this.topAxis = null;
|
|
7181
7195
|
this.bottomAxis = null;
|
|
7182
7196
|
this.renderedKeys = {};
|
|
7197
|
+
this.brushedDomain = [];
|
|
7198
|
+
this.brushBarsInitialized = {};
|
|
7183
7199
|
|
|
7184
7200
|
if (!elementId) {
|
|
7185
7201
|
console.log('No element Id provided for Websy Chart');
|
|
@@ -7187,12 +7203,19 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7187
7203
|
}
|
|
7188
7204
|
|
|
7189
7205
|
this.invertOverride = function (input, input2) {
|
|
7190
|
-
var
|
|
7206
|
+
var forBrush = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
7207
|
+
var xAxis = 'bottom';
|
|
7191
7208
|
|
|
7192
7209
|
if (_this42.options.orientation === 'horizontal') {
|
|
7193
|
-
xAxis = '
|
|
7210
|
+
xAxis = 'left';
|
|
7194
7211
|
}
|
|
7195
7212
|
|
|
7213
|
+
if (forBrush === true) {
|
|
7214
|
+
xAxis += 'Brush';
|
|
7215
|
+
}
|
|
7216
|
+
|
|
7217
|
+
xAxis += 'Axis';
|
|
7218
|
+
|
|
7196
7219
|
var width = _this42[xAxis].step();
|
|
7197
7220
|
|
|
7198
7221
|
var output;
|
|
@@ -7216,6 +7239,66 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7216
7239
|
return output;
|
|
7217
7240
|
};
|
|
7218
7241
|
|
|
7242
|
+
var that = this;
|
|
7243
|
+
|
|
7244
|
+
this.brushed = function (event) {
|
|
7245
|
+
console.log('brushing', event);
|
|
7246
|
+
that.brushedDomain = [];
|
|
7247
|
+
var xAxis = 'bottom';
|
|
7248
|
+
var xAxisCaps = 'Bottom';
|
|
7249
|
+
|
|
7250
|
+
if (that.options.orientation === 'horizontal') {
|
|
7251
|
+
xAxis = 'left';
|
|
7252
|
+
xAxisCaps = 'Left';
|
|
7253
|
+
}
|
|
7254
|
+
|
|
7255
|
+
if (!that["".concat(xAxis, "Axis")].invert) {
|
|
7256
|
+
that["".concat(xAxis, "Axis")].invert = that.invertOverride;
|
|
7257
|
+
}
|
|
7258
|
+
|
|
7259
|
+
var s = event.selection || that["".concat(xAxis, "Axis")].range();
|
|
7260
|
+
|
|
7261
|
+
if (!event.selection || event.selection.length === 0) {
|
|
7262
|
+
that.brushLayer.select('.brush').call(that.brush).call(that.brush.move, s);
|
|
7263
|
+
return;
|
|
7264
|
+
}
|
|
7265
|
+
|
|
7266
|
+
if (that.options.data[xAxis].scale && that.options.data[xAxis].scale === 'Time') {
|
|
7267
|
+
that.brushedDomain = s.map(that["".concat(xAxis, "BrushAxis")].invert, that[["".concat(xAxis, "Axis")]]);
|
|
7268
|
+
} else {
|
|
7269
|
+
var startEndOrdinal = s.map(function (a, b) {
|
|
7270
|
+
return that.bottomAxis.invert(a, b, true);
|
|
7271
|
+
}, that.bottomBrushAxis);
|
|
7272
|
+
|
|
7273
|
+
if (startEndOrdinal && startEndOrdinal.length === 2 && typeof startEndOrdinal[0] !== 'undefined' && typeof startEndOrdinal[1] !== 'undefined') {
|
|
7274
|
+
var domain = [];
|
|
7275
|
+
|
|
7276
|
+
var domainValues = _toConsumableArray(that["".concat(xAxis, "BrushAxis")].domain());
|
|
7277
|
+
|
|
7278
|
+
for (var i = startEndOrdinal[0]; i < startEndOrdinal[1] + 1; i++) {
|
|
7279
|
+
// domain.push(that.xRange[i])
|
|
7280
|
+
that.brushedDomain.push(domainValues[i]);
|
|
7281
|
+
}
|
|
7282
|
+
}
|
|
7283
|
+
}
|
|
7284
|
+
|
|
7285
|
+
if (that.brushedDomain.length > 0) {
|
|
7286
|
+
that["".concat(xAxis, "Axis")].domain(that.brushedDomain);
|
|
7287
|
+
that["".concat(xAxis, "AxisLayer")].call(d3["axis".concat(xAxisCaps)](that["".concat(xAxis, "Axis")]));
|
|
7288
|
+
}
|
|
7289
|
+
|
|
7290
|
+
if (that.leftAxis && that.bottomAxis) {
|
|
7291
|
+
that.renderComponents();
|
|
7292
|
+
|
|
7293
|
+
if (that.options.orientation === 'vertical') {
|
|
7294
|
+
// that.bottomAxisLayer.call(that.bAxisFunc)
|
|
7295
|
+
if (that.options.data.bottom.rotate) {
|
|
7296
|
+
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"));
|
|
7297
|
+
}
|
|
7298
|
+
}
|
|
7299
|
+
}
|
|
7300
|
+
};
|
|
7301
|
+
|
|
7219
7302
|
var el = document.getElementById(this.elementId);
|
|
7220
7303
|
|
|
7221
7304
|
if (el) {
|
|
@@ -7225,10 +7308,18 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7225
7308
|
console.error('d3 library has not been loaded');
|
|
7226
7309
|
} else {
|
|
7227
7310
|
el.innerHTML = '';
|
|
7228
|
-
this.svg = d3.select(el).append('svg');
|
|
7311
|
+
this.svg = d3.select(el).append('svg'); // .attr('id', `${this.elementId}_chartContainer`)
|
|
7312
|
+
|
|
7229
7313
|
this.legendArea = d3.select(el).append('div').attr('id', "".concat(this.elementId, "_legend")).attr('class', 'websy-chart-legend');
|
|
7230
7314
|
this.legend = new WebsyDesigns.Legend("".concat(this.elementId, "_legend"), {});
|
|
7231
|
-
this.prep();
|
|
7315
|
+
this.prep(); // el.innerHTML += `
|
|
7316
|
+
// <div id="${this.elementId}_errorContainer" class='websy-vis-error-container'>
|
|
7317
|
+
// <div>
|
|
7318
|
+
// <div id="${this.elementId}_errorTitle"></div>
|
|
7319
|
+
// <div id="${this.elementId}_errorMessage"></div>
|
|
7320
|
+
// </div>
|
|
7321
|
+
// </div>
|
|
7322
|
+
// `
|
|
7232
7323
|
}
|
|
7233
7324
|
} else {
|
|
7234
7325
|
console.error("No element found with ID ".concat(this.elementId));
|
|
@@ -7255,29 +7346,41 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7255
7346
|
key: "createDomain",
|
|
7256
7347
|
value: function createDomain(side) {
|
|
7257
7348
|
var domain = [];
|
|
7258
|
-
/* global d3 side domain:writable */
|
|
7349
|
+
/* global d3 side domain:writable forBrush */
|
|
7350
|
+
// if we have a brushed domain we use that
|
|
7259
7351
|
|
|
7260
|
-
|
|
7261
|
-
// domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
|
|
7262
|
-
domain = [this.options.data[side].min, this.options.data[side].max];
|
|
7352
|
+
var xAxis = 'bottom';
|
|
7263
7353
|
|
|
7264
|
-
|
|
7265
|
-
|
|
7266
|
-
}
|
|
7354
|
+
if (this.options.orientation === 'horizontal') {
|
|
7355
|
+
xAxis = 'left';
|
|
7267
7356
|
}
|
|
7268
7357
|
|
|
7269
|
-
if (this.
|
|
7270
|
-
domain = this.
|
|
7271
|
-
|
|
7272
|
-
|
|
7273
|
-
|
|
7358
|
+
if (this.brushedDomain.length > 0 && side === xAxis && forBrush === false) {
|
|
7359
|
+
domain = _toConsumableArray(this.brushedDomain);
|
|
7360
|
+
} else {
|
|
7361
|
+
// otherwise we create the domain
|
|
7362
|
+
if (typeof this.options.data[side].min !== 'undefined' && typeof this.options.data[side].max !== 'undefined') {
|
|
7363
|
+
// domain = [this.options.data[side].min - (this.options.data[side].min * 0.1), this.options.data[side].max * 1.1]
|
|
7364
|
+
domain = [this.options.data[side].min, this.options.data[side].max];
|
|
7365
|
+
|
|
7366
|
+
if (this.options.forceZero === true) {
|
|
7367
|
+
domain = [Math.min(0, this.options.data[side].min), this.options.data[side].max];
|
|
7368
|
+
}
|
|
7369
|
+
}
|
|
7370
|
+
|
|
7371
|
+
if (this.options.data[side].data) {
|
|
7372
|
+
domain = this.options.data[side].data.map(function (d) {
|
|
7373
|
+
return d.value;
|
|
7374
|
+
});
|
|
7375
|
+
}
|
|
7274
7376
|
|
|
7275
|
-
|
|
7276
|
-
|
|
7277
|
-
|
|
7278
|
-
|
|
7279
|
-
|
|
7280
|
-
|
|
7377
|
+
if (this.options.data[side].scale === 'Time') {
|
|
7378
|
+
var min = this.options.data[side].data[0].value;
|
|
7379
|
+
var max = this.options.data[side].data[this.options.data[side].data.length - 1].value;
|
|
7380
|
+
min = this.parseX(min);
|
|
7381
|
+
max = this.parseX(max);
|
|
7382
|
+
domain = [min, max];
|
|
7383
|
+
}
|
|
7281
7384
|
}
|
|
7282
7385
|
|
|
7283
7386
|
return domain;
|
|
@@ -7518,6 +7621,9 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7518
7621
|
key: "prep",
|
|
7519
7622
|
value: function prep() {
|
|
7520
7623
|
/* global d3 WebsyDesigns */
|
|
7624
|
+
this.defs = this.svg.append('defs');
|
|
7625
|
+
this.clip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_clip")).append('rect');
|
|
7626
|
+
this.brushClip = this.defs.append('clipPath').attr('id', "".concat(this.elementId, "_brushclip")).append('rect');
|
|
7521
7627
|
this.leftAxisLayer = this.svg.append('g').attr('class', 'left-axis-layer');
|
|
7522
7628
|
this.rightAxisLayer = this.svg.append('g').attr('class', 'right-axis-layer');
|
|
7523
7629
|
this.bottomAxisLayer = this.svg.append('g').attr('class', 'bottom-axis-layer');
|
|
@@ -7534,6 +7640,13 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7534
7640
|
this.trackingLineLayer = this.svg.append('g').attr('class', 'tracking-line-layer');
|
|
7535
7641
|
this.trackingLineLayer.append('line').attr('class', 'tracking-line');
|
|
7536
7642
|
this.tooltip = new WebsyDesigns.WebsyChartTooltip(this.svg);
|
|
7643
|
+
this.brushLayer = this.svg.append('g'); // .attr(
|
|
7644
|
+
// 'clip-path',
|
|
7645
|
+
// `url(#${this.elementId.replace(/\s/g, '_')}_brushclip)`
|
|
7646
|
+
// )
|
|
7647
|
+
|
|
7648
|
+
this.brushArea = this.brushLayer.append('g').attr('class', 'brush-area');
|
|
7649
|
+
this.brushLayer.append('g').attr('class', 'brush');
|
|
7537
7650
|
this.eventLayer = this.svg.append('g').attr('class', 'event-line').append('rect');
|
|
7538
7651
|
this.eventLayer.on('mouseout', this.handleEventMouseOut.bind(this)).on('mousemove', this.handleEventMouseMove.bind(this));
|
|
7539
7652
|
this.render();
|
|
@@ -7673,7 +7786,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7673
7786
|
|
|
7674
7787
|
if (this.options.data.bottom.formatter) {
|
|
7675
7788
|
this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
|
|
7676
|
-
firstBottom = this.
|
|
7789
|
+
firstBottom = this.options.data.bottom.formatter(this.options.data.bottom.data[0].value).toString();
|
|
7677
7790
|
} else {
|
|
7678
7791
|
if (this.options.data.bottom.scale === 'Time') {
|
|
7679
7792
|
this.longestBottom = '01/01/2000';
|
|
@@ -7681,7 +7794,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7681
7794
|
} else {
|
|
7682
7795
|
this.longestBottom = this.options.data.bottom.data.reduce(function (a, b) {
|
|
7683
7796
|
return a.length > b.value.length ? a : b.value;
|
|
7684
|
-
}, '');
|
|
7797
|
+
}, ''); // firstBottom = (this.options.data.bottom.data[0] || [{value: ''}]).value
|
|
7798
|
+
|
|
7685
7799
|
firstBottom = this.options.data.bottom.data[0].value;
|
|
7686
7800
|
}
|
|
7687
7801
|
}
|
|
@@ -7773,7 +7887,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7773
7887
|
if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) === 0 && this.options.axis.hideBottom !== true) {
|
|
7774
7888
|
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, longestBottomBounds.width / 2);
|
|
7775
7889
|
} else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) < 0 && this.options.axis.hideBottom !== true) {
|
|
7776
|
-
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft,
|
|
7890
|
+
this.options.margin.axisLeft = Math.max(this.options.margin.axisLeft, firstBottomWidth / 2);
|
|
7777
7891
|
} else if ((this.options.data.bottom && this.options.data.bottom.rotate || 0) > 0 && this.options.axis.hideBottom !== true) {
|
|
7778
7892
|
this.options.margin.axisRight = Math.max(this.options.margin.axisRight, longestBottomBounds.width);
|
|
7779
7893
|
} // if (this.options.data.bottom.rotate) {
|
|
@@ -7806,7 +7920,26 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7806
7920
|
|
|
7807
7921
|
|
|
7808
7922
|
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;
|
|
7809
|
-
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;
|
|
7923
|
+
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;
|
|
7924
|
+
|
|
7925
|
+
if (this.options.orientation === 'vertical') {
|
|
7926
|
+
if (this.options.maxBandWidth) {
|
|
7927
|
+
this.plotWidth = Math.min(this.plotWidth, (this.options.data.bottom.data || []).length * this.options.maxBandWidth);
|
|
7928
|
+
} // some if to check if brushing is needed
|
|
7929
|
+
|
|
7930
|
+
|
|
7931
|
+
if (this.plotWidth / this.options.data.bottom.data.length < this.options.minBandWidth) {
|
|
7932
|
+
this.brushNeeded = true;
|
|
7933
|
+
this.plotHeight -= this.options.brushHeight;
|
|
7934
|
+
}
|
|
7935
|
+
} else {
|
|
7936
|
+
// some if to check if brushing is needed
|
|
7937
|
+
if (this.plotHeight / this.options.data.left.data.length < this.options.minBandWidth) {
|
|
7938
|
+
this.brushNeeded = true;
|
|
7939
|
+
this.plotWidth -= this.options.brushHeight;
|
|
7940
|
+
}
|
|
7941
|
+
} // Translate the layers
|
|
7942
|
+
|
|
7810
7943
|
|
|
7811
7944
|
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);
|
|
7812
7945
|
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);
|
|
@@ -7822,19 +7955,68 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7822
7955
|
this.symbolLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
7823
7956
|
this.refLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
7824
7957
|
this.trackingLineLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
7958
|
+
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, ")"));
|
|
7959
|
+
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);
|
|
7825
7960
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
7826
7961
|
var that = this;
|
|
7827
7962
|
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)
|
|
7828
7963
|
// Configure the bottom axis
|
|
7829
7964
|
|
|
7830
7965
|
var bottomDomain = this.createDomain('bottom');
|
|
7966
|
+
var bottomBrushDomain = this.createDomain('bottom', true);
|
|
7831
7967
|
this.bottomAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomDomain).range([0, this.plotWidth]);
|
|
7832
7968
|
|
|
7969
|
+
if (!this.brushInitialized) {
|
|
7970
|
+
this.bottomBrushAxis = d3["scale".concat(this.options.data.bottom.scale || 'Band')]().domain(bottomBrushDomain).range([0, this.plotWidth]);
|
|
7971
|
+
}
|
|
7972
|
+
|
|
7833
7973
|
if (this.bottomAxis.nice) {// this.bottomAxis.nice()
|
|
7834
7974
|
}
|
|
7835
7975
|
|
|
7836
7976
|
if (this.bottomAxis.padding && this.options.data.bottom.padding) {
|
|
7837
7977
|
this.bottomAxis.padding(this.options.data.bottom.padding || 0);
|
|
7978
|
+
} // BRUSH
|
|
7979
|
+
|
|
7980
|
+
|
|
7981
|
+
var brushMethod = "brushX";
|
|
7982
|
+
var brushLength = this.plotWidth;
|
|
7983
|
+
var brushEnd = this.plotWidth;
|
|
7984
|
+
var brushThickness = this.options.brushHeight;
|
|
7985
|
+
|
|
7986
|
+
if (this.options.orientation === 'horizontal') {
|
|
7987
|
+
brushMethod = 'brushY';
|
|
7988
|
+
brushLength = this.options.brushHeight;
|
|
7989
|
+
brushThickness = this.plotHeight;
|
|
7990
|
+
} else {
|
|
7991
|
+
if (brushLength / bottomDomain.length < this.options.minBandWidth) {
|
|
7992
|
+
brushEnd = this.plotWidth * (this.plotWidth / this.options.minBandWidth / bottomDomain.length);
|
|
7993
|
+
}
|
|
7994
|
+
}
|
|
7995
|
+
|
|
7996
|
+
this.brush = d3[brushMethod]().extent([[0, 0], [brushLength, brushThickness]]).on('brush end', this.brushed);
|
|
7997
|
+
|
|
7998
|
+
var brushResizePath = function brushResizePath(d) {
|
|
7999
|
+
var e = +(d.type === 'e');
|
|
8000
|
+
var x = e ? 1 : -1;
|
|
8001
|
+
var y = _this44.options.brushHeight;
|
|
8002
|
+
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);
|
|
8003
|
+
};
|
|
8004
|
+
|
|
8005
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').remove();
|
|
8006
|
+
this.brushHandle = this.brushLayer.select('.brush').selectAll('.handle--custom').data([{
|
|
8007
|
+
type: 'w'
|
|
8008
|
+
}, {
|
|
8009
|
+
type: 'e'
|
|
8010
|
+
}]).enter().append('path').attr('class', 'handle--custom').attr('stroke', 'transparent').attr('fill', 'transparent').attr('cursor', 'ew-resize').attr('d', brushResizePath); // BRUSH END
|
|
8011
|
+
// this.brushArea.selectAll('*').remove()
|
|
8012
|
+
|
|
8013
|
+
if (this.brushNeeded) {
|
|
8014
|
+
if (!this.brushInitialized) {
|
|
8015
|
+
this.brushInitialized = true;
|
|
8016
|
+
this.brushLayer.select('.brush').call(this.brush).call(this.brush.move, [0, brushEnd]);
|
|
8017
|
+
}
|
|
8018
|
+
} else {
|
|
8019
|
+
this.brushLayer.selectAll().remove();
|
|
7838
8020
|
}
|
|
7839
8021
|
|
|
7840
8022
|
if (this.options.margin.axisBottom > 0) {
|
|
@@ -7888,17 +8070,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7888
8070
|
}
|
|
7889
8071
|
|
|
7890
8072
|
this.options.calculatedTimeFormatPattern = timeFormatPattern;
|
|
7891
|
-
|
|
7892
|
-
.ticks(tickDefinition); // console.log('tickDefinition', tickDefinition)
|
|
7893
|
-
// console.log(bAxisFunc)
|
|
8073
|
+
this.bAxisFunc = d3.axisBottom(this.bottomAxis).ticks(tickDefinition);
|
|
7894
8074
|
|
|
7895
8075
|
if (this.options.data.bottom.formatter) {
|
|
7896
|
-
bAxisFunc.tickFormat(function (d) {
|
|
8076
|
+
this.bAxisFunc.tickFormat(function (d) {
|
|
7897
8077
|
return _this44.options.data.bottom.formatter(d);
|
|
7898
8078
|
});
|
|
7899
8079
|
}
|
|
7900
8080
|
|
|
7901
|
-
this.bottomAxisLayer.call(bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
8081
|
+
this.bottomAxisLayer.call(this.bAxisFunc); // console.log(this.bottomAxisLayer.ticks)
|
|
7902
8082
|
|
|
7903
8083
|
if (this.options.data.bottom.rotate) {
|
|
7904
8084
|
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"));
|
|
@@ -7907,8 +8087,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7907
8087
|
|
|
7908
8088
|
|
|
7909
8089
|
var leftDomain = this.createDomain('left');
|
|
8090
|
+
var leftBrushDomain = this.createDomain('left', true);
|
|
7910
8091
|
var rightDomain = this.createDomain('right');
|
|
7911
8092
|
this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range([this.plotHeight, 0]);
|
|
8093
|
+
this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range([this.options.brushHeight, 0]);
|
|
7912
8094
|
|
|
7913
8095
|
if (this.leftAxis.padding && this.options.data.left.padding) {
|
|
7914
8096
|
this.leftAxis.padding(this.options.data.left.padding || 0);
|
|
@@ -7955,7 +8137,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7955
8137
|
}
|
|
7956
8138
|
|
|
7957
8139
|
if (this.options.margin.axisRight > 0 && (this.options.data.right.min !== 0 || this.options.data.right.max !== 0)) {
|
|
7958
|
-
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.
|
|
8140
|
+
this.rightAxisLayer.call(d3.axisRight(this.rightAxis).ticks(this.options.data.right.ticks || 5).tickFormat(function (d) {
|
|
7959
8141
|
if (_this44.options.data.right.formatter) {
|
|
7960
8142
|
d = _this44.options.data.right.formatter(d);
|
|
7961
8143
|
}
|
|
@@ -7990,48 +8172,55 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7990
8172
|
// remove the components
|
|
7991
8173
|
this["remove".concat(this.renderedKeys[key])](key);
|
|
7992
8174
|
}
|
|
7993
|
-
}
|
|
8175
|
+
}
|
|
7994
8176
|
|
|
8177
|
+
this.renderComponents();
|
|
8178
|
+
}
|
|
8179
|
+
}
|
|
8180
|
+
}
|
|
8181
|
+
}, {
|
|
8182
|
+
key: "renderComponents",
|
|
8183
|
+
value: function renderComponents() {
|
|
8184
|
+
var _this45 = this;
|
|
7995
8185
|
|
|
7996
|
-
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8186
|
+
// Draw the series data
|
|
8187
|
+
this.renderedKeys = {};
|
|
8188
|
+
this.options.data.series.forEach(function (series, index) {
|
|
8189
|
+
if (!series.key) {
|
|
8190
|
+
series.key = _this45.createIdentity();
|
|
8191
|
+
}
|
|
8001
8192
|
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
|
|
8193
|
+
if (!series.color) {
|
|
8194
|
+
series.color = _this45.options.colors[index % _this45.options.colors.length];
|
|
8195
|
+
}
|
|
8005
8196
|
|
|
8006
|
-
|
|
8197
|
+
_this45["render".concat(series.type || 'bar')](series, index);
|
|
8007
8198
|
|
|
8008
|
-
|
|
8199
|
+
_this45.renderLabels(series, index);
|
|
8009
8200
|
|
|
8010
|
-
|
|
8011
|
-
|
|
8201
|
+
_this45.renderedKeys[series.key] = series.type;
|
|
8202
|
+
});
|
|
8012
8203
|
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8017
|
-
}
|
|
8018
|
-
}
|
|
8204
|
+
if (this.options.refLines && this.options.refLines.length > 0) {
|
|
8205
|
+
this.options.refLines.forEach(function (l) {
|
|
8206
|
+
return _this45.renderRefLine(l);
|
|
8207
|
+
});
|
|
8019
8208
|
}
|
|
8020
8209
|
}
|
|
8021
8210
|
}, {
|
|
8022
8211
|
key: "renderarea",
|
|
8023
8212
|
value: function renderarea(series, index) {
|
|
8024
|
-
var
|
|
8213
|
+
var _this46 = this;
|
|
8025
8214
|
|
|
8026
8215
|
/* global d3 series index */
|
|
8027
8216
|
var drawArea = function drawArea(xAxis, yAxis, curveStyle) {
|
|
8028
8217
|
return d3.area().x(function (d) {
|
|
8029
|
-
return
|
|
8218
|
+
return _this46[xAxis](_this46.parseX(d.x.value));
|
|
8030
8219
|
}).y0(function (d) {
|
|
8031
|
-
return
|
|
8220
|
+
return _this46[yAxis](0);
|
|
8032
8221
|
}).y1(function (d) {
|
|
8033
|
-
return
|
|
8034
|
-
}).curve(d3[curveStyle ||
|
|
8222
|
+
return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8223
|
+
}).curve(d3[curveStyle || _this46.options.curveStyle]);
|
|
8035
8224
|
};
|
|
8036
8225
|
|
|
8037
8226
|
var xAxis = 'bottomAxis';
|
|
@@ -8066,90 +8255,189 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8066
8255
|
}, {
|
|
8067
8256
|
key: "renderbar",
|
|
8068
8257
|
value: function renderbar(series, index) {
|
|
8258
|
+
var _this47 = this;
|
|
8259
|
+
|
|
8069
8260
|
/* global series index d3 */
|
|
8070
8261
|
var xAxis = 'bottom';
|
|
8071
8262
|
var yAxis = 'left';
|
|
8072
8263
|
var bars = this.barLayer.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8264
|
+
var brushBars = this.brushArea.selectAll(".bar_".concat(series.key)).data(series.data);
|
|
8073
8265
|
var acummulativeY = new Array(this.options.data.series.length).fill(0);
|
|
8074
8266
|
|
|
8075
8267
|
if (this.options.orientation === 'horizontal') {
|
|
8076
8268
|
xAxis = 'left';
|
|
8077
8269
|
yAxis = 'bottom';
|
|
8078
|
-
}
|
|
8079
|
-
|
|
8080
|
-
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8081
|
-
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length; // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8270
|
+
} // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
|
|
8082
8271
|
// barWidth = barWidth / this.options.data.series.length - 4
|
|
8083
8272
|
// }
|
|
8084
8273
|
|
|
8085
|
-
|
|
8274
|
+
|
|
8275
|
+
function getBarHeight(d, i, heightBounds, yAxis, xAxis) {
|
|
8276
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8277
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8278
|
+
var output;
|
|
8279
|
+
|
|
8086
8280
|
if (this.options.orientation === 'horizontal') {
|
|
8087
|
-
|
|
8281
|
+
output = barWidth;
|
|
8088
8282
|
} else {
|
|
8089
|
-
|
|
8283
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8284
|
+
return null;
|
|
8285
|
+
}
|
|
8286
|
+
|
|
8287
|
+
output = this["".concat(yAxis, "Axis")](0) - this["".concat(yAxis, "Axis")](Math.abs(d.y.value));
|
|
8288
|
+
}
|
|
8289
|
+
|
|
8290
|
+
if (isNaN(output)) {
|
|
8291
|
+
return null;
|
|
8090
8292
|
}
|
|
8293
|
+
|
|
8294
|
+
return output;
|
|
8091
8295
|
}
|
|
8092
8296
|
|
|
8093
|
-
function getBarWidth(d, i) {
|
|
8297
|
+
function getBarWidth(d, i, xAxis) {
|
|
8298
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8299
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8300
|
+
var output;
|
|
8301
|
+
|
|
8094
8302
|
if (this.options.orientation === 'horizontal') {
|
|
8095
8303
|
var width = this["".concat(yAxis, "Axis")](d.y.value);
|
|
8096
8304
|
acummulativeY[d.y.index] += width;
|
|
8097
|
-
|
|
8305
|
+
output = Math.max(1, width);
|
|
8098
8306
|
} else {
|
|
8307
|
+
if (!getBarX.call(this, d, i, xAxis)) {
|
|
8308
|
+
return null;
|
|
8309
|
+
}
|
|
8310
|
+
|
|
8099
8311
|
if (this.options.grouping === 'grouped') {
|
|
8100
|
-
|
|
8312
|
+
output = Math.max(1, groupedBarWidth);
|
|
8313
|
+
} else {
|
|
8314
|
+
output = Math.max(1, barWidth);
|
|
8101
8315
|
}
|
|
8316
|
+
}
|
|
8102
8317
|
|
|
8103
|
-
|
|
8318
|
+
if (isNaN(output)) {
|
|
8319
|
+
return 0;
|
|
8104
8320
|
}
|
|
8321
|
+
|
|
8322
|
+
return output;
|
|
8105
8323
|
}
|
|
8106
8324
|
|
|
8107
|
-
function getBarX(d, i) {
|
|
8325
|
+
function getBarX(d, i, xAxis) {
|
|
8326
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8327
|
+
var groupedBarWidth = (barWidth - (xAxis.indexOf('Brush') === -1 ? 10 : 2)) / this.options.data.series.length;
|
|
8328
|
+
var output;
|
|
8329
|
+
|
|
8108
8330
|
if (this.options.orientation === 'horizontal') {
|
|
8109
8331
|
if (this.options.grouping === 'stacked') {
|
|
8110
|
-
|
|
8332
|
+
output = this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8111
8333
|
} else {
|
|
8112
|
-
|
|
8334
|
+
output = 0;
|
|
8113
8335
|
}
|
|
8114
8336
|
} else {
|
|
8115
|
-
var adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8337
|
+
var adjustment = this.options.data[xAxis.replace('Brush', '')].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8116
8338
|
|
|
8117
8339
|
if (this.options.grouping === 'grouped') {
|
|
8118
|
-
var barAdjustment = groupedBarWidth * index + 5; // + (index > 0 ? 4 : 0)
|
|
8340
|
+
var barAdjustment = groupedBarWidth * index + (xAxis.indexOf('Brush') === -1 ? 5 : 1); // + (index > 0 ? 4 : 0)
|
|
8119
8341
|
|
|
8120
|
-
|
|
8342
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
|
|
8121
8343
|
} else {
|
|
8122
|
-
|
|
8344
|
+
// output = this[`${xAxis}Axis`](this.parseX(d.x.value)) + (i * barWidth) + adjustment
|
|
8345
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)); // + (i * barWidth)
|
|
8123
8346
|
}
|
|
8124
8347
|
}
|
|
8348
|
+
|
|
8349
|
+
if (isNaN(output)) {
|
|
8350
|
+
return null;
|
|
8351
|
+
}
|
|
8352
|
+
|
|
8353
|
+
return output;
|
|
8125
8354
|
}
|
|
8126
8355
|
|
|
8127
|
-
function getBarY(d, i) {
|
|
8356
|
+
function getBarY(d, i, heightBounds, yAxis, xAxis) {
|
|
8357
|
+
var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
|
|
8358
|
+
var groupedBarWidth = (barWidth - 10) / this.options.data.series.length;
|
|
8359
|
+
var output;
|
|
8360
|
+
|
|
8128
8361
|
if (this.options.orientation === 'horizontal') {
|
|
8129
8362
|
if (this.options.grouping !== 'grouped') {
|
|
8130
|
-
|
|
8363
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
|
|
8131
8364
|
} else {
|
|
8132
|
-
|
|
8365
|
+
output = this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
|
|
8133
8366
|
}
|
|
8134
8367
|
} else {
|
|
8135
8368
|
if (this.options.grouping === 'stacked') {
|
|
8136
|
-
|
|
8369
|
+
output = heightBounds - this["".concat(yAxis, "Axis")](d.y.accumulative);
|
|
8137
8370
|
} else {
|
|
8138
|
-
|
|
8371
|
+
var h = getBarHeight.call(this, d, i, heightBounds, yAxis, xAxis);
|
|
8372
|
+
output = this["".concat(yAxis, "Axis")](0) - h * (d.y.value < 0 ? 0 : 1);
|
|
8139
8373
|
}
|
|
8140
8374
|
}
|
|
8375
|
+
|
|
8376
|
+
if (isNaN(output)) {
|
|
8377
|
+
return null;
|
|
8378
|
+
}
|
|
8379
|
+
|
|
8380
|
+
return output;
|
|
8141
8381
|
}
|
|
8142
8382
|
|
|
8143
8383
|
bars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8144
|
-
bars.attr('width',
|
|
8384
|
+
bars.attr('width', function (d, i) {
|
|
8385
|
+
return getBarWidth.call(_this47, d, i, xAxis);
|
|
8386
|
+
}).attr('height', function (d, i) {
|
|
8387
|
+
return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8388
|
+
}).attr('x', function (d, i) {
|
|
8389
|
+
return getBarX.call(_this47, d, i, xAxis);
|
|
8390
|
+
}).attr('y', function (d, i) {
|
|
8391
|
+
return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8392
|
+
}) // .transition(this.transition)
|
|
8393
|
+
.attr('fill', function (d) {
|
|
8145
8394
|
return d.y.color || d.color || series.color;
|
|
8146
8395
|
});
|
|
8147
|
-
bars.enter().append('rect').attr('width',
|
|
8396
|
+
bars.enter().append('rect').attr('width', function (d, i) {
|
|
8397
|
+
return getBarWidth.call(_this47, d, i, xAxis);
|
|
8398
|
+
}).attr('height', function (d, i) {
|
|
8399
|
+
return getBarHeight.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8400
|
+
}).attr('x', function (d, i) {
|
|
8401
|
+
return getBarX.call(_this47, d, i, xAxis);
|
|
8402
|
+
}).attr('y', function (d, i) {
|
|
8403
|
+
return getBarY.call(_this47, d, i, _this47.plotHeight, yAxis, xAxis);
|
|
8404
|
+
}) // .transition(this.transition)
|
|
8148
8405
|
.attr('fill', function (d) {
|
|
8149
8406
|
return d.y.color || d.color || series.color;
|
|
8150
8407
|
}).attr('class', function (d) {
|
|
8151
8408
|
return "bar bar_".concat(series.key);
|
|
8152
8409
|
});
|
|
8410
|
+
|
|
8411
|
+
if (!this.brushBarsInitialized[series.key]) {
|
|
8412
|
+
this.brushBarsInitialized[series.key] = true;
|
|
8413
|
+
brushBars.exit().transition(this.transition).style('fill-opacity', 1e-6).remove();
|
|
8414
|
+
brushBars.attr('width', function (d, i) {
|
|
8415
|
+
return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8416
|
+
}).attr('height', function (d, i) {
|
|
8417
|
+
return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8418
|
+
}).attr('x', function (d, i) {
|
|
8419
|
+
return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8420
|
+
}).attr('y', function (d, i) {
|
|
8421
|
+
return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8422
|
+
}) // .transition(this.transition)
|
|
8423
|
+
.attr('fill', function (d) {
|
|
8424
|
+
return d.y.color || d.color || series.color;
|
|
8425
|
+
});
|
|
8426
|
+
brushBars.enter().append('rect').attr('width', function (d, i) {
|
|
8427
|
+
return getBarWidth.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8428
|
+
}).attr('height', function (d, i) {
|
|
8429
|
+
return getBarHeight.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8430
|
+
}).attr('x', function (d, i) {
|
|
8431
|
+
return getBarX.call(_this47, d, i, "".concat(xAxis, "Brush"));
|
|
8432
|
+
}).attr('y', function (d, i) {
|
|
8433
|
+
return getBarY.call(_this47, d, i, _this47.options.brushHeight, "".concat(yAxis, "Brush"), "".concat(xAxis, "Brush"));
|
|
8434
|
+
}) // .transition(this.transition)
|
|
8435
|
+
.attr('fill', function (d) {
|
|
8436
|
+
return d.y.color || d.color || series.color;
|
|
8437
|
+
}).attr('class', function (d) {
|
|
8438
|
+
return "bar bar_".concat(series.key);
|
|
8439
|
+
});
|
|
8440
|
+
}
|
|
8153
8441
|
}
|
|
8154
8442
|
}, {
|
|
8155
8443
|
key: "removebar",
|
|
@@ -8160,7 +8448,7 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8160
8448
|
}, {
|
|
8161
8449
|
key: "renderLabels",
|
|
8162
8450
|
value: function renderLabels(series, index) {
|
|
8163
|
-
var
|
|
8451
|
+
var _this48 = this;
|
|
8164
8452
|
|
|
8165
8453
|
/* global series index d3 WebsyDesigns */
|
|
8166
8454
|
var xAxis = 'bottomAxis';
|
|
@@ -8179,15 +8467,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8179
8467
|
var labels = this.labelLayer.selectAll(".label_".concat(series.key)).data(series.data);
|
|
8180
8468
|
labels.exit().transition(this.transition).style('stroke-opacity', 1e-6).remove();
|
|
8181
8469
|
labels.attr('x', function (d) {
|
|
8182
|
-
return getLabelX.call(
|
|
8470
|
+
return getLabelX.call(_this48, d, series.labelPosition);
|
|
8183
8471
|
}).attr('y', function (d) {
|
|
8184
|
-
return getLabelY.call(
|
|
8472
|
+
return getLabelY.call(_this48, d, series.labelPosition);
|
|
8185
8473
|
}).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
|
|
8186
|
-
if (
|
|
8474
|
+
if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8187
8475
|
return 'transparent';
|
|
8188
8476
|
}
|
|
8189
8477
|
|
|
8190
|
-
return
|
|
8478
|
+
return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8191
8479
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
8192
8480
|
return d.y.label || d.y.value;
|
|
8193
8481
|
}).each(function (d, i) {
|
|
@@ -8212,15 +8500,15 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8212
8500
|
}
|
|
8213
8501
|
});
|
|
8214
8502
|
labels.enter().append('text').attr('class', "label_".concat(series.key)).attr('x', function (d) {
|
|
8215
|
-
return getLabelX.call(
|
|
8503
|
+
return getLabelX.call(_this48, d, series.labelPosition);
|
|
8216
8504
|
}).attr('y', function (d) {
|
|
8217
|
-
return getLabelY.call(
|
|
8505
|
+
return getLabelY.call(_this48, d, series.labelPosition);
|
|
8218
8506
|
}).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
|
|
8219
|
-
if (
|
|
8507
|
+
if (_this48.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8220
8508
|
return 'transparent';
|
|
8221
8509
|
}
|
|
8222
8510
|
|
|
8223
|
-
return
|
|
8511
|
+
return _this48.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8224
8512
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
8225
8513
|
return d.y.label || d.y.value;
|
|
8226
8514
|
}).each(function (d, i) {
|
|
@@ -8277,16 +8565,16 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8277
8565
|
}, {
|
|
8278
8566
|
key: "renderline",
|
|
8279
8567
|
value: function renderline(series, index) {
|
|
8280
|
-
var
|
|
8568
|
+
var _this49 = this;
|
|
8281
8569
|
|
|
8282
8570
|
/* global series index d3 */
|
|
8283
8571
|
var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
|
|
8284
8572
|
return d3.line().x(function (d) {
|
|
8285
|
-
var adjustment =
|
|
8286
|
-
return
|
|
8573
|
+
var adjustment = _this49.options.data[xAxis].scale === 'Time' ? 0 : _this49["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8574
|
+
return _this49["".concat(xAxis, "Axis")](_this49.parseX(d.x.value)) + adjustment;
|
|
8287
8575
|
}).y(function (d) {
|
|
8288
|
-
return
|
|
8289
|
-
}).curve(d3[curveStyle ||
|
|
8576
|
+
return _this49["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
|
|
8577
|
+
}).curve(d3[curveStyle || _this49.options.curveStyle]);
|
|
8290
8578
|
};
|
|
8291
8579
|
|
|
8292
8580
|
var xAxis = 'bottom';
|
|
@@ -8358,14 +8646,14 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8358
8646
|
}, {
|
|
8359
8647
|
key: "rendersymbol",
|
|
8360
8648
|
value: function rendersymbol(series, index) {
|
|
8361
|
-
var
|
|
8649
|
+
var _this50 = this;
|
|
8362
8650
|
|
|
8363
8651
|
/* global d3 series index series.key */
|
|
8364
8652
|
var drawSymbol = function drawSymbol(size) {
|
|
8365
8653
|
return d3.symbol() // .type(d => {
|
|
8366
8654
|
// return d3.symbols[0]
|
|
8367
8655
|
// })
|
|
8368
|
-
.size(size ||
|
|
8656
|
+
.size(size || _this50.options.symbolSize);
|
|
8369
8657
|
};
|
|
8370
8658
|
|
|
8371
8659
|
var xAxis = 'bottom';
|
|
@@ -8383,8 +8671,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8383
8671
|
symbols.attr('d', function (d) {
|
|
8384
8672
|
return drawSymbol(d.y.size || series.symbolSize)(d);
|
|
8385
8673
|
}).transition(this.transition).attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('transform', function (d) {
|
|
8386
|
-
var adjustment =
|
|
8387
|
-
return "translate(".concat(
|
|
8674
|
+
var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8675
|
+
return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8388
8676
|
}); // Enter
|
|
8389
8677
|
|
|
8390
8678
|
symbols.enter().append('path').attr('d', function (d) {
|
|
@@ -8393,8 +8681,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8393
8681
|
.attr('fill', series.fillSymbols ? series.color : 'white').attr('stroke', series.color).attr('class', function (d) {
|
|
8394
8682
|
return "symbol symbol_".concat(series.key);
|
|
8395
8683
|
}).attr('transform', function (d) {
|
|
8396
|
-
var adjustment =
|
|
8397
|
-
return "translate(".concat(
|
|
8684
|
+
var adjustment = _this50.options.data[xAxis].scale === 'Time' ? 0 : _this50["".concat(xAxis, "Axis")].bandwidth() / 2;
|
|
8685
|
+
return "translate(".concat(_this50["".concat(xAxis, "Axis")](_this50.parseX(d.x.value)) + adjustment, ", ").concat(_this50["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
|
|
8398
8686
|
});
|
|
8399
8687
|
}
|
|
8400
8688
|
}, {
|
|
@@ -8482,6 +8770,58 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8482
8770
|
this.eventLayer.attr('transform', "translate(".concat(this.options.margin.left + this.options.margin.axisLeft, ", ").concat(this.options.margin.top + this.options.margin.axisTop, ")"));
|
|
8483
8771
|
}
|
|
8484
8772
|
}
|
|
8773
|
+
}, {
|
|
8774
|
+
key: "hideError",
|
|
8775
|
+
value: function hideError() {
|
|
8776
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
8777
|
+
|
|
8778
|
+
if (el) {
|
|
8779
|
+
el.classList.remove('has-error');
|
|
8780
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
8781
|
+
// chartEl.classList.remove('hidden')
|
|
8782
|
+
|
|
8783
|
+
|
|
8784
|
+
this.svg.classed('hidden', false);
|
|
8785
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
8786
|
+
|
|
8787
|
+
if (containerEl) {
|
|
8788
|
+
containerEl.classList.remove('active');
|
|
8789
|
+
}
|
|
8790
|
+
}
|
|
8791
|
+
}, {
|
|
8792
|
+
key: "showError",
|
|
8793
|
+
value: function showError(options) {
|
|
8794
|
+
var el = document.getElementById("".concat(this.elementId));
|
|
8795
|
+
|
|
8796
|
+
if (el) {
|
|
8797
|
+
el.classList.add('has-error');
|
|
8798
|
+
} // const chartEl = document.getElementById(`${this.elementId}_chartContainer`)
|
|
8799
|
+
// chartEl.classList.add('hidden')
|
|
8800
|
+
|
|
8801
|
+
|
|
8802
|
+
this.svg.classed('hidden', true);
|
|
8803
|
+
var containerEl = document.getElementById("".concat(this.elementId, "_errorContainer"));
|
|
8804
|
+
|
|
8805
|
+
if (containerEl) {
|
|
8806
|
+
containerEl.classList.add('active');
|
|
8807
|
+
}
|
|
8808
|
+
|
|
8809
|
+
if (options.title) {
|
|
8810
|
+
var titleEl = document.getElementById("".concat(this.elementId, "_errorTitle"));
|
|
8811
|
+
|
|
8812
|
+
if (titleEl) {
|
|
8813
|
+
titleEl.innerHTML = options.title;
|
|
8814
|
+
}
|
|
8815
|
+
}
|
|
8816
|
+
|
|
8817
|
+
if (options.message) {
|
|
8818
|
+
var messageEl = document.getElementById("".concat(this.elementId, "_errorMessage"));
|
|
8819
|
+
|
|
8820
|
+
if (messageEl) {
|
|
8821
|
+
messageEl.innerHTML = options.message;
|
|
8822
|
+
}
|
|
8823
|
+
}
|
|
8824
|
+
}
|
|
8485
8825
|
}, {
|
|
8486
8826
|
key: "data",
|
|
8487
8827
|
set: function set(d) {
|
|
@@ -8549,7 +8889,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
8549
8889
|
}, {
|
|
8550
8890
|
key: "resize",
|
|
8551
8891
|
value: function resize() {
|
|
8552
|
-
var
|
|
8892
|
+
var _this51 = this;
|
|
8553
8893
|
|
|
8554
8894
|
var el = document.getElementById(this.elementId);
|
|
8555
8895
|
|
|
@@ -8562,7 +8902,7 @@ var WebsyLegend = /*#__PURE__*/function () {
|
|
|
8562
8902
|
// }
|
|
8563
8903
|
var html = "\n <div class='text-".concat(this.options.align, "'>\n ");
|
|
8564
8904
|
html += this._data.map(function (d, i) {
|
|
8565
|
-
return
|
|
8905
|
+
return _this51.getLegendItemHTML(d);
|
|
8566
8906
|
}).join('');
|
|
8567
8907
|
html += "\n <div>\n ";
|
|
8568
8908
|
el.innerHTML = html;
|
|
@@ -8734,7 +9074,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
8734
9074
|
}, {
|
|
8735
9075
|
key: "render",
|
|
8736
9076
|
value: function render() {
|
|
8737
|
-
var
|
|
9077
|
+
var _this52 = this;
|
|
8738
9078
|
|
|
8739
9079
|
var mapEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
8740
9080
|
var legendEl = document.getElementById("".concat(this.elementId, "_map"));
|
|
@@ -8743,7 +9083,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
8743
9083
|
var legendData = this.options.data.polygons.map(function (s, i) {
|
|
8744
9084
|
return {
|
|
8745
9085
|
value: s.label || s.key,
|
|
8746
|
-
color: s.color ||
|
|
9086
|
+
color: s.color || _this52.options.colors[i % _this52.options.colors.length]
|
|
8747
9087
|
};
|
|
8748
9088
|
});
|
|
8749
9089
|
var longestValue = legendData.map(function (s) {
|
|
@@ -8807,7 +9147,7 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
8807
9147
|
|
|
8808
9148
|
if (this.polygons) {
|
|
8809
9149
|
this.polygons.forEach(function (p) {
|
|
8810
|
-
return
|
|
9150
|
+
return _this52.map.removeLayer(p);
|
|
8811
9151
|
});
|
|
8812
9152
|
}
|
|
8813
9153
|
|
|
@@ -8865,18 +9205,18 @@ var WebsyMap = /*#__PURE__*/function () {
|
|
|
8865
9205
|
}
|
|
8866
9206
|
|
|
8867
9207
|
if (!p.options.color) {
|
|
8868
|
-
p.options.color =
|
|
9208
|
+
p.options.color = _this52.options.colors[i % _this52.options.colors.length];
|
|
8869
9209
|
}
|
|
8870
9210
|
|
|
8871
9211
|
var pol = L.polygon(p.data.map(function (c) {
|
|
8872
9212
|
return c.map(function (d) {
|
|
8873
9213
|
return [d.Latitude, d.Longitude];
|
|
8874
9214
|
});
|
|
8875
|
-
}), p.options).addTo(
|
|
9215
|
+
}), p.options).addTo(_this52.map);
|
|
8876
9216
|
|
|
8877
|
-
|
|
9217
|
+
_this52.polygons.push(pol);
|
|
8878
9218
|
|
|
8879
|
-
|
|
9219
|
+
_this52.map.fitBounds(pol.getBounds());
|
|
8880
9220
|
});
|
|
8881
9221
|
} // if (this.data.markers.length > 0) {
|
|
8882
9222
|
// el.classList.remove('hidden')
|