mdt-charts 1.15.4 → 1.15.5
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.
|
@@ -38,12 +38,13 @@ export class AxisLabelHelper {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
static cropLabels(block, scale, scaleOptions, axisOptions, blockSize) {
|
|
41
|
+
var _a, _b, _c;
|
|
41
42
|
const axisTextBlocks = block.getSvg().select(`.${axisOptions.cssClass}`).selectAll('text');
|
|
42
43
|
let maxLabelSize;
|
|
43
44
|
if ((axisOptions.orient === 'left' || axisOptions.orient === 'right') || (axisOptions.type === 'key' && axisOptions.labels.position === 'rotated'))
|
|
44
45
|
maxLabelSize = axisOptions.labels.maxSize;
|
|
45
46
|
else
|
|
46
|
-
maxLabelSize = scale.step() - 4;
|
|
47
|
+
maxLabelSize = ((_c = (_b = (_a = scale).step) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : Infinity) - 4;
|
|
47
48
|
DomHelper.cropSvgLabels(axisTextBlocks, maxLabelSize);
|
|
48
49
|
if (scaleOptions.type === 'point' && axisOptions.labels.position === 'straight' && (axisOptions.orient === 'top' || axisOptions.orient === 'bottom')) {
|
|
49
50
|
this.cropAndAlignExtremeLabels(block, maxLabelSize, axisOptions, blockSize);
|
|
@@ -82,7 +82,7 @@ export class AxisModel {
|
|
|
82
82
|
}
|
|
83
83
|
static getLabelSize(labelMaxWidth, labelTexts) {
|
|
84
84
|
const LABEL_ELEMENT_HEIGHT_PX = 17;
|
|
85
|
-
const ONE_UPPER_SYMBOL_WIDTH_PX = 8
|
|
85
|
+
const ONE_UPPER_SYMBOL_WIDTH_PX = 8;
|
|
86
86
|
const longestLabelLength = Math.max(...labelTexts.map(t => ModelHelper.getStringScore(t)));
|
|
87
87
|
const longestLabelWidth = ONE_UPPER_SYMBOL_WIDTH_PX * longestLabelLength;
|
|
88
88
|
return {
|
|
@@ -29,9 +29,10 @@ export class ModelHelper {
|
|
|
29
29
|
// Number width == lower case letter width
|
|
30
30
|
let score = 0;
|
|
31
31
|
const upperLetterScore = 1;
|
|
32
|
-
const lowerLetterScore = 0.
|
|
32
|
+
const lowerLetterScore = 0.67;
|
|
33
|
+
const specialSmallSymbols = [",", ".", " "];
|
|
33
34
|
for (let i = 0; i < word.length; i++) {
|
|
34
|
-
if (word[i].toUpperCase() === word[i] && parseFloat(word[i]).toString() !== word[i])
|
|
35
|
+
if (word[i].toUpperCase() === word[i] && parseFloat(word[i]).toString() !== word[i] && !specialSmallSymbols.includes(word[i]) && word[i].trim().length > 0)
|
|
35
36
|
score += upperLetterScore;
|
|
36
37
|
else
|
|
37
38
|
score += lowerLetterScore;
|