@websy/websy-designs 1.4.25 → 1.4.26
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.
|
@@ -6967,7 +6967,7 @@ else {
|
|
|
6967
6967
|
firstBottom = Math.max(0, firstBottomWidth)
|
|
6968
6968
|
}
|
|
6969
6969
|
}
|
|
6970
|
-
this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth)
|
|
6970
|
+
this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5 // + 5 to accommodate for space between text and axis line
|
|
6971
6971
|
this.options.margin.axisRight = longestRightBounds.width
|
|
6972
6972
|
this.options.margin.axisBottom = longestBottomBounds.height + 10
|
|
6973
6973
|
this.options.margin.axisTop = 0
|
|
@@ -7479,7 +7479,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
7479
7479
|
.attr('x', d => getLabelX.call(this, d, series.labelPosition))
|
|
7480
7480
|
.attr('y', d => getLabelY.call(this, d, series.labelPosition))
|
|
7481
7481
|
.attr('class', `label_${series.key}`)
|
|
7482
|
-
.attr('fill', d =>
|
|
7482
|
+
.attr('fill', d => {
|
|
7483
|
+
if (this.options.grouping === 'stacked' && d.y.value === 0) {
|
|
7484
|
+
return 'transparent'
|
|
7485
|
+
}
|
|
7486
|
+
return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
|
|
7487
|
+
})
|
|
7483
7488
|
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7484
7489
|
.transition(this.transition)
|
|
7485
7490
|
.text(d => d.y.label || d.y.value)
|
|
@@ -7517,7 +7522,12 @@ if (this.options.showLabels === true || series.showLabels === true) {
|
|
|
7517
7522
|
.attr('y', d => getLabelY.call(this, d, series.labelPosition))
|
|
7518
7523
|
.attr('alignment-baseline', 'central')
|
|
7519
7524
|
.attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle')
|
|
7520
|
-
.attr('fill', d =>
|
|
7525
|
+
.attr('fill', d => {
|
|
7526
|
+
if (this.options.grouping === 'stacked' && d.y.value === 0) {
|
|
7527
|
+
return 'transparent'
|
|
7528
|
+
}
|
|
7529
|
+
return this.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color)
|
|
7530
|
+
})
|
|
7521
7531
|
.style('font-size', `${this.options.labelSize || this.options.fontSize}px`)
|
|
7522
7532
|
.text(d => d.y.label || d.y.value)
|
|
7523
7533
|
.each(function (d, i) {
|
|
@@ -7635,18 +7645,24 @@ if (series.showSymbols === true) {
|
|
|
7635
7645
|
/* global d3 data */
|
|
7636
7646
|
let xAxis = 'bottom'
|
|
7637
7647
|
let yAxis = 'left'
|
|
7648
|
+
let yAttr = 'y'
|
|
7649
|
+
let xAttr = 'x'
|
|
7638
7650
|
let that = this
|
|
7651
|
+
let length = this.plotWidth
|
|
7639
7652
|
if (this.options.orientation === 'horizontal') {
|
|
7640
7653
|
xAxis = 'left'
|
|
7641
7654
|
yAxis = 'bottom'
|
|
7655
|
+
yAttr = 'x'
|
|
7656
|
+
xAttr = 'y'
|
|
7657
|
+
length = this.plotHeight
|
|
7642
7658
|
}
|
|
7643
7659
|
this.refLineLayer.selectAll('.reference-line').remove()
|
|
7644
7660
|
this.refLineLayer.selectAll('.reference-line-label').remove()
|
|
7645
7661
|
this.refLineLayer
|
|
7646
7662
|
.append('line')
|
|
7647
|
-
.attr(
|
|
7648
|
-
.attr(
|
|
7649
|
-
.attr(
|
|
7663
|
+
.attr(`${yAttr}1`, this[`${yAxis}Axis`](data.value))
|
|
7664
|
+
.attr(`${yAttr}2`, this[`${yAxis}Axis`](data.value))
|
|
7665
|
+
.attr(`${xAttr}2`, length)
|
|
7650
7666
|
.attr('class', `reference-line`)
|
|
7651
7667
|
.style('stroke', data.color)
|
|
7652
7668
|
.style('stroke-width', `${data.lineWidth}px`)
|
|
@@ -7656,7 +7672,7 @@ if (data.label && data.label !== '') {
|
|
|
7656
7672
|
this.refLineLayer
|
|
7657
7673
|
.append('text')
|
|
7658
7674
|
.attr('class', `reference-line-label`)
|
|
7659
|
-
.attr('x',
|
|
7675
|
+
.attr('x', length)
|
|
7660
7676
|
.attr('y', this[`${yAxis}Axis`](data.value))
|
|
7661
7677
|
.attr('font-size', this.options.fontSize)
|
|
7662
7678
|
.attr('fill', data.color)
|
|
@@ -7704,7 +7704,8 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
7704
7704
|
}
|
|
7705
7705
|
}
|
|
7706
7706
|
|
|
7707
|
-
this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth);
|
|
7707
|
+
this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth) + 5; // + 5 to accommodate for space between text and axis line
|
|
7708
|
+
|
|
7708
7709
|
this.options.margin.axisRight = longestRightBounds.width;
|
|
7709
7710
|
this.options.margin.axisBottom = longestBottomBounds.height + 10;
|
|
7710
7711
|
this.options.margin.axisTop = 0; // adjust axis margins based on title options
|
|
@@ -8140,6 +8141,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8140
8141
|
}).attr('y', function (d) {
|
|
8141
8142
|
return getLabelY.call(_this46, d, series.labelPosition);
|
|
8142
8143
|
}).attr('class', "label_".concat(series.key)).attr('fill', function (d) {
|
|
8144
|
+
if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8145
|
+
return 'transparent';
|
|
8146
|
+
}
|
|
8147
|
+
|
|
8143
8148
|
return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8144
8149
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).transition(this.transition).text(function (d) {
|
|
8145
8150
|
return d.y.label || d.y.value;
|
|
@@ -8169,6 +8174,10 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8169
8174
|
}).attr('y', function (d) {
|
|
8170
8175
|
return getLabelY.call(_this46, d, series.labelPosition);
|
|
8171
8176
|
}).attr('alignment-baseline', 'central').attr('text-anchor', this.options.orientation === 'horizontal' ? 'left' : 'middle').attr('fill', function (d) {
|
|
8177
|
+
if (_this46.options.grouping === 'stacked' && d.y.value === 0) {
|
|
8178
|
+
return 'transparent';
|
|
8179
|
+
}
|
|
8180
|
+
|
|
8172
8181
|
return _this46.options.labelColor || WebsyDesigns.WebsyUtils.getLightDark(d.y.color || d.color || series.color);
|
|
8173
8182
|
}).style('font-size', "".concat(this.options.labelSize || this.options.fontSize, "px")).text(function (d) {
|
|
8174
8183
|
return d.y.label || d.y.value;
|
|
@@ -8276,20 +8285,26 @@ var WebsyChart = /*#__PURE__*/function () {
|
|
|
8276
8285
|
/* global d3 data */
|
|
8277
8286
|
var xAxis = 'bottom';
|
|
8278
8287
|
var yAxis = 'left';
|
|
8288
|
+
var yAttr = 'y';
|
|
8289
|
+
var xAttr = 'x';
|
|
8279
8290
|
var that = this;
|
|
8291
|
+
var length = this.plotWidth;
|
|
8280
8292
|
|
|
8281
8293
|
if (this.options.orientation === 'horizontal') {
|
|
8282
8294
|
xAxis = 'left';
|
|
8283
8295
|
yAxis = 'bottom';
|
|
8296
|
+
yAttr = 'x';
|
|
8297
|
+
xAttr = 'y';
|
|
8298
|
+
length = this.plotHeight;
|
|
8284
8299
|
}
|
|
8285
8300
|
|
|
8286
8301
|
this.refLineLayer.selectAll('.reference-line').remove();
|
|
8287
8302
|
this.refLineLayer.selectAll('.reference-line-label').remove();
|
|
8288
|
-
this.refLineLayer.append('line').attr(
|
|
8303
|
+
this.refLineLayer.append('line').attr("".concat(yAttr, "1"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(yAttr, "2"), this["".concat(yAxis, "Axis")](data.value)).attr("".concat(xAttr, "2"), length).attr('class', "reference-line").style('stroke', data.color).style('stroke-width', "".concat(data.lineWidth, "px")).style('stroke-dasharray', data.lineStyle);
|
|
8289
8304
|
|
|
8290
8305
|
if (data.label && data.label !== '') {
|
|
8291
8306
|
// show the text on the line
|
|
8292
|
-
this.refLineLayer.append('text').attr('class', "reference-line-label").attr('x',
|
|
8307
|
+
this.refLineLayer.append('text').attr('class', "reference-line-label").attr('x', length).attr('y', this["".concat(yAxis, "Axis")](data.value)).attr('font-size', this.options.fontSize).attr('fill', data.color).text(data.label).attr('text-anchor', 'end').attr('alignment-baseline', 'text-after-edge');
|
|
8293
8308
|
}
|
|
8294
8309
|
}
|
|
8295
8310
|
}, {
|