Update axis-chart-utils.js
Fix issue with overlapping labels on seriese charts.
This commit is contained in:
parent
e95f0aadaa
commit
b6f2483fd2
@ -101,6 +101,13 @@ export function getShortenedLabels(chartWidth, labels=[], isSeries=true) {
|
||||
if(allowedSpace <= 0) allowedSpace = 1;
|
||||
let allowedLetters = allowedSpace / DEFAULT_CHAR_WIDTH;
|
||||
|
||||
let seriesMultiple;
|
||||
if(isSeries) {
|
||||
// Find the maximum label length for spacing calculations
|
||||
let maxLabelLength = Math.max(...labels.map(label => label.length));
|
||||
seriesMultiple = Math.ceil(maxLabelLength/allowedLetters);
|
||||
}
|
||||
|
||||
let calcLabels = labels.map((label, i) => {
|
||||
label += "";
|
||||
if(label.length > allowedLetters) {
|
||||
@ -112,8 +119,7 @@ export function getShortenedLabels(chartWidth, labels=[], isSeries=true) {
|
||||
label = label.slice(0, allowedLetters) + '..';
|
||||
}
|
||||
} else {
|
||||
let multiple = Math.ceil(label.length/allowedLetters);
|
||||
if(i % multiple !== 0) {
|
||||
if(i % seriesMultiple !== 0) {
|
||||
label = "";
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user