UI: Improve time series charts ticks generator function.
This commit is contained in:
parent
fd7c7e9b51
commit
0f9aeaa697
@ -974,18 +974,19 @@ export const createTimeSeriesYAxis = (units: string,
|
|||||||
ticksFormatter = parseFunction(settings.ticksFormatter, ['value']);
|
ticksFormatter = parseFunction(settings.ticksFormatter, ['value']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
let configuredTicksGenerator: TimeSeriesChartTicksGenerator;
|
||||||
let ticksGenerator: TimeSeriesChartTicksGenerator;
|
let ticksGenerator: TimeSeriesChartTicksGenerator;
|
||||||
let minInterval: number;
|
let minInterval: number;
|
||||||
let interval: number;
|
let interval: number;
|
||||||
let splitNumber: number;
|
let splitNumber: number;
|
||||||
if (settings.ticksGenerator) {
|
if (settings.ticksGenerator) {
|
||||||
if (isFunction(settings.ticksGenerator)) {
|
if (isFunction(settings.ticksGenerator)) {
|
||||||
ticksGenerator = settings.ticksGenerator as TimeSeriesChartTicksGenerator;
|
configuredTicksGenerator = settings.ticksGenerator as TimeSeriesChartTicksGenerator;
|
||||||
} else if (settings.ticksGenerator.length) {
|
} else if (settings.ticksGenerator.length) {
|
||||||
ticksGenerator = parseFunction(settings.ticksGenerator, ['extent', 'interval', 'niceTickExtent', 'intervalPrecision']);
|
configuredTicksGenerator = parseFunction(settings.ticksGenerator, ['extent', 'interval', 'niceTickExtent', 'intervalPrecision']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ticksGenerator) {
|
if (!configuredTicksGenerator) {
|
||||||
interval = settings.interval;
|
interval = settings.interval;
|
||||||
if (isUndefinedOrNull(interval)) {
|
if (isUndefinedOrNull(interval)) {
|
||||||
if (isDefinedAndNotNull(settings.splitNumber)) {
|
if (isDefinedAndNotNull(settings.splitNumber)) {
|
||||||
@ -994,6 +995,11 @@ export const createTimeSeriesYAxis = (units: string,
|
|||||||
minInterval = (1 / Math.pow(10, decimals));
|
minInterval = (1 / Math.pow(10, decimals));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
ticksGenerator = (extent, ticksInterval, niceTickExtent, intervalPrecision) => {
|
||||||
|
const ticks = configuredTicksGenerator(extent, ticksInterval, niceTickExtent, intervalPrecision);
|
||||||
|
return ticks?.filter(tick => tick.value >= extent[0] && tick.value <= extent[1]);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
id: settings.id,
|
id: settings.id,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user