mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
[TSVB] Formatting in the left axis is not respected when I have two separate axis (#123903)
Closes: #123891
This commit is contained in:
parent
35f1c4d78e
commit
2c900c65ba
2 changed files with 31 additions and 15 deletions
|
@ -52,6 +52,20 @@ describe('checkIfSeriesHaveSameFormatters(seriesModel, fieldFormatMap)', () => {
|
|||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it('should return true in case of separate y-axis and different field formatters', () => {
|
||||
const seriesModel = [
|
||||
{ formatter: DATA_FORMATTERS.DEFAULT, metrics: [{ type: 'avg', field: 'someField' }] },
|
||||
{
|
||||
formatter: DATA_FORMATTERS.DEFAULT,
|
||||
separate_axis: 1,
|
||||
metrics: [{ id: 'avg', field: 'anotherField' }],
|
||||
},
|
||||
] as Series[];
|
||||
const result = checkIfSeriesHaveSameFormatters(seriesModel, fieldFormatMap);
|
||||
|
||||
expect(result).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should return false for the different field formatters', () => {
|
||||
const seriesModel = [
|
||||
{ formatter: DATA_FORMATTERS.DEFAULT, metrics: [{ type: 'avg', field: 'someField' }] },
|
||||
|
|
|
@ -18,24 +18,26 @@ export const checkIfSeriesHaveSameFormatters = (
|
|||
const uniqFormatters = new Set();
|
||||
|
||||
seriesModel.forEach((seriesGroup) => {
|
||||
if (seriesGroup.formatter === DATA_FORMATTERS.DEFAULT) {
|
||||
const activeMetric = seriesGroup.metrics[seriesGroup.metrics.length - 1];
|
||||
const aggMeta = aggs.find((agg) => agg.id === activeMetric.type);
|
||||
if (!seriesGroup.separate_axis) {
|
||||
if (seriesGroup.formatter === DATA_FORMATTERS.DEFAULT) {
|
||||
const activeMetric = seriesGroup.metrics[seriesGroup.metrics.length - 1];
|
||||
const aggMeta = aggs.find((agg) => agg.id === activeMetric.type);
|
||||
|
||||
if (
|
||||
activeMetric.field &&
|
||||
aggMeta?.meta.isFieldRequired &&
|
||||
fieldFormatMap?.[activeMetric.field]
|
||||
) {
|
||||
return uniqFormatters.add(JSON.stringify(fieldFormatMap[activeMetric.field]));
|
||||
if (
|
||||
activeMetric.field &&
|
||||
aggMeta?.meta.isFieldRequired &&
|
||||
fieldFormatMap?.[activeMetric.field]
|
||||
) {
|
||||
return uniqFormatters.add(JSON.stringify(fieldFormatMap[activeMetric.field]));
|
||||
}
|
||||
}
|
||||
uniqFormatters.add(
|
||||
JSON.stringify({
|
||||
// requirement: in the case of using TSVB formatters, we do not need to check the value_template, just formatter!
|
||||
formatter: seriesGroup.formatter,
|
||||
})
|
||||
);
|
||||
}
|
||||
uniqFormatters.add(
|
||||
JSON.stringify({
|
||||
// requirement: in the case of using TSVB formatters, we do not need to check the value_template, just formatter!
|
||||
formatter: seriesGroup.formatter,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
return uniqFormatters.size === 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue