Skip to content

Commit

Permalink
adjust yaxis mode according to field format (#117646)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dominiqueclarke and kibanamachine authored Nov 9, 2021
1 parent 06ab784 commit b7173dd
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { LayerConfig, LensAttributes } from './lens_attributes';
import { mockAppIndexPattern, mockIndexPattern } from '../rtl_helpers';
import { getDefaultConfigs } from './default_configs';
import { sampleAttribute } from './test_data/sample_attribute';

import {
LCP_FIELD,
TRANSACTION_DURATION,
Expand Down Expand Up @@ -467,7 +468,7 @@ describe('Lens Attribute', () => {
palette: undefined,
seriesType: 'line',
xAccessor: 'x-axis-column-layer0',
yConfig: [{ color: 'green', forAccessor: 'y-axis-column-layer0' }],
yConfig: [{ color: 'green', forAccessor: 'y-axis-column-layer0', axisMode: 'left' }],
},
],
legend: { isVisible: true, showSingleSeries: true, position: 'right' },
Expand Down Expand Up @@ -510,7 +511,7 @@ describe('Lens Attribute', () => {
seriesType: 'line',
splitAccessor: 'breakdown-column-layer0',
xAccessor: 'x-axis-column-layer0',
yConfig: [{ color: 'green', forAccessor: 'y-axis-column-layer0' }],
yConfig: [{ color: 'green', forAccessor: 'y-axis-column-layer0', axisMode: 'left' }],
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,19 @@ export class LensAttributes {
seriesType: layerConfig.seriesType || layerConfig.seriesConfig.defaultSeriesType,
palette: layerConfig.seriesConfig.palette,
yConfig: layerConfig.seriesConfig.yConfig || [
{ forAccessor: `y-axis-column-layer${index}`, color: layerConfig.color },
{
forAccessor: `y-axis-column-layer${index}`,
color: layerConfig.color,
/* if the fields format matches the field format of the first layer, use the default y axis (right)
* if not, use the secondary y axis (left) */
axisMode:
layerConfig.indexPattern.fieldFormatMap[layerConfig.selectedMetricField]?.id ===
this.layerConfigs[0].indexPattern.fieldFormatMap[
this.layerConfigs[0].selectedMetricField
]?.id
? 'left'
: 'right',
},
],
xAccessor: `x-axis-column-layer${index}`,
...(layerConfig.breakdown &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export const sampleAttribute = {
{
color: 'green',
forAccessor: 'y-axis-column-layer0',
axisMode: 'left',
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const sampleAttributeKpi = {
{
color: 'green',
forAccessor: 'y-axis-column-layer0',
axisMode: 'left',
},
],
},
Expand Down

0 comments on commit b7173dd

Please sign in to comment.