mdt-charts 1.18.0 → 1.18.1
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.
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { axisTop, axisBottom, axisLeft, axisRight } from 'd3-axis';
|
|
2
2
|
import { format } from 'd3-format';
|
|
3
3
|
import { AxisLabelHelper } from './axisLabelDomHelper';
|
|
4
|
+
import { max, min } from 'd3-array';
|
|
4
5
|
export class AxisHelper {
|
|
5
6
|
static getAxisByOrient(orient, scale) {
|
|
6
7
|
if (orient === 'top')
|
|
@@ -19,7 +20,7 @@ export class AxisHelper {
|
|
|
19
20
|
axisGenerator.ticks(Math.floor(axisLength / minimalStepSize));
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
|
-
axisGenerator.
|
|
23
|
+
axisGenerator.tickValues([min(scaleOptions.domain), max(scaleOptions.domain)]);
|
|
23
24
|
}
|
|
24
25
|
if (scaleOptions.type === 'linear') {
|
|
25
26
|
this.setNumTickFormat(axisGenerator, scaleOptions.formatter);
|
|
@@ -75,7 +75,7 @@ export class AxisLabelHelper {
|
|
|
75
75
|
static alignHorizontalAxisLastLabel(block, maxLabelSize, axisOptions, blockSize, crop) {
|
|
76
76
|
const lastTick = block.getSvg().select(`.${axisOptions.cssClass}`).select('.tick:last-of-type');
|
|
77
77
|
const lastLabel = lastTick.select('text');
|
|
78
|
-
if (lastTick.size() === 0 || lastLabel.size() === 0)
|
|
78
|
+
if (lastTick.empty() || lastTick.size() === 0 || lastLabel.size() === 0)
|
|
79
79
|
return;
|
|
80
80
|
const tickTranslateX = Helper.getTranslateNumbers(lastTick.attr('transform'))[0];
|
|
81
81
|
const marginRight = blockSize.width - axisOptions.translate.translateX - tickTranslateX;
|
|
@@ -92,6 +92,8 @@ export class AxisLabelHelper {
|
|
|
92
92
|
.select(`.${axisOptions.cssClass}`)
|
|
93
93
|
.select('.tick:first-of-type')
|
|
94
94
|
.select('text');
|
|
95
|
+
if (firstLabel.empty())
|
|
96
|
+
return;
|
|
95
97
|
const axisElementTranslate = Helper.getTranslateNumbers(block.getSvg().select(`.${axisOptions.cssClass}`).attr('transform'))[0];
|
|
96
98
|
if (axisOptions.translate.translateX - firstLabel.node().getBBox().width / 2 < 0) {
|
|
97
99
|
firstLabel.attr('text-anchor', 'start');
|