diff --git a/packages/kbn-optimizer/limits.yml b/packages/kbn-optimizer/limits.yml index ae6c2f58fa28d..561007cb33b23 100644 --- a/packages/kbn-optimizer/limits.yml +++ b/packages/kbn-optimizer/limits.yml @@ -128,5 +128,5 @@ pageLoadAssetSize: eventAnnotation: 19334 screenshotting: 22870 synthetics: 40958 - expressionXY: 30000 + expressionXY: 31000 kibanaUsageCollection: 16463 diff --git a/src/plugins/chart_expressions/expression_xy/common/__mocks__/index.ts b/src/plugins/chart_expressions/expression_xy/common/__mocks__/index.ts index 3a4a1fdb813fc..b8969fd599765 100644 --- a/src/plugins/chart_expressions/expression_xy/common/__mocks__/index.ts +++ b/src/plugins/chart_expressions/expression_xy/common/__mocks__/index.ts @@ -56,7 +56,6 @@ export const sampleLayer: DataLayerConfig = { splitAccessor: 'd', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: createSampleDatatableWithRows([]), @@ -108,6 +107,8 @@ export const createArgsWithLayers = ( type: 'axisExtentConfig', }, layers: Array.isArray(layers) ? layers : [layers], + yLeftScale: 'linear', + yRightScale: 'linear', }); export function sampleArgs() { diff --git a/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_data_layer_args.ts b/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_data_layer_args.ts index 8c728f1c8e99e..0c9085cce7664 100644 --- a/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_data_layer_args.ts +++ b/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_data_layer_args.ts @@ -7,7 +7,7 @@ */ import { ArgumentType } from '@kbn/expressions-plugin/common'; -import { SeriesTypes, XScaleTypes, YScaleTypes, Y_CONFIG } from '../constants'; +import { SeriesTypes, XScaleTypes, Y_CONFIG } from '../constants'; import { strings } from '../i18n'; import { DataLayerArgs, ExtendedDataLayerArgs } from '../types'; @@ -44,12 +44,6 @@ export const commonDataLayerArgs: Omit< default: false, help: strings.getIsHistogramHelp(), }, - yScaleType: { - options: [...Object.values(YScaleTypes)], - help: strings.getYScaleTypeHelp(), - default: YScaleTypes.LINEAR, - strict: true, - }, yConfig: { types: [Y_CONFIG], help: strings.getYConfigHelp(), diff --git a/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_xy_args.ts b/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_xy_args.ts index f80d814571076..0dbe71ef554cc 100644 --- a/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_xy_args.ts +++ b/src/plugins/chart_expressions/expression_xy/common/expression_functions/common_xy_args.ts @@ -17,6 +17,7 @@ import { TICK_LABELS_CONFIG, ValueLabelModes, XYCurveTypes, + YScaleTypes, } from '../constants'; import { strings } from '../i18n'; import { LayeredXyVisFn, XyVisFn } from '../types'; @@ -46,6 +47,18 @@ export const commonXYArgs: CommonXYFn['args'] = { help: strings.getYRightExtentHelp(), default: `{${AXIS_EXTENT_CONFIG}}`, }, + yLeftScale: { + options: [...Object.values(YScaleTypes)], + help: strings.getYLeftScaleTypeHelp(), + default: YScaleTypes.LINEAR, + strict: true, + }, + yRightScale: { + options: [...Object.values(YScaleTypes)], + help: strings.getYRightScaleTypeHelp(), + default: YScaleTypes.LINEAR, + strict: true, + }, legend: { types: [LEGEND_CONFIG], help: strings.getLegendHelp(), diff --git a/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis_fn.ts b/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis_fn.ts index 8b850f39afbbe..04d0b954c5d5c 100644 --- a/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis_fn.ts +++ b/src/plugins/chart_expressions/expression_xy/common/expression_functions/xy_vis_fn.ts @@ -31,7 +31,6 @@ const createDataLayer = (args: XYArgs, table: Datatable): DataLayerConfigResult seriesType: args.seriesType, hide: args.hide, columnToLabel: args.columnToLabel, - yScaleType: args.yScaleType, xScaleType: args.xScaleType, isHistogram: args.isHistogram, palette: args.palette, @@ -55,7 +54,6 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => { hide, splitAccessor, columnToLabel, - yScaleType, xScaleType, isHistogram, yConfig, diff --git a/src/plugins/chart_expressions/expression_xy/common/i18n/index.tsx b/src/plugins/chart_expressions/expression_xy/common/i18n/index.tsx index 5b5906ac71582..a69f0034b9e23 100644 --- a/src/plugins/chart_expressions/expression_xy/common/i18n/index.tsx +++ b/src/plugins/chart_expressions/expression_xy/common/i18n/index.tsx @@ -49,6 +49,14 @@ export const strings = { i18n.translate('expressionXY.xyVis.yRightExtent.help', { defaultMessage: 'Y right axis extents', }), + getYLeftScaleTypeHelp: () => + i18n.translate('expressionXY.xyVis.yLeftScaleType.help', { + defaultMessage: 'The scale type of the left y axis', + }), + getYRightScaleTypeHelp: () => + i18n.translate('expressionXY.xyVis.yRightScaleType.help', { + defaultMessage: 'The scale type of the right y axis', + }), getLegendHelp: () => i18n.translate('expressionXY.xyVis.legend.help', { defaultMessage: 'Configure the chart legend.', @@ -149,10 +157,6 @@ export const strings = { i18n.translate('expressionXY.dataLayer.isHistogram.help', { defaultMessage: 'Whether to layout the chart as a histogram', }), - getYScaleTypeHelp: () => - i18n.translate('expressionXY.dataLayer.yScaleType.help', { - defaultMessage: 'The scale type of the y axes', - }), getSplitAccessorHelp: () => i18n.translate('expressionXY.dataLayer.splitAccessor.help', { defaultMessage: 'The column to split by', diff --git a/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts b/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts index 5cca9a0431ad0..375ee584f380c 100644 --- a/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts +++ b/src/plugins/chart_expressions/expression_xy/common/types/expression_functions.ts @@ -101,7 +101,6 @@ export interface DataLayerArgs { hide?: boolean; splitAccessor?: string | ExpressionValueVisDimension; columnToLabel?: string; // Actually a JSON key-value pair - yScaleType: YScaleType; xScaleType: XScaleType; isHistogram: boolean; palette: PaletteOutput; @@ -120,7 +119,6 @@ export interface ExtendedDataLayerArgs { hide?: boolean; splitAccessor?: string; columnToLabel?: string; // Actually a JSON key-value pair - yScaleType: YScaleType; xScaleType: XScaleType; isHistogram: boolean; palette: PaletteOutput; @@ -187,6 +185,8 @@ export interface XYArgs extends DataLayerArgs { yRightTitle: string; yLeftExtent: AxisExtentConfigResult; yRightExtent: AxisExtentConfigResult; + yLeftScale: YScaleType; + yRightScale: YScaleType; legend: LegendConfigResult; endValue?: EndValue; emphasizeFitting?: boolean; @@ -213,6 +213,8 @@ export interface LayeredXYArgs { yRightTitle: string; yLeftExtent: AxisExtentConfigResult; yRightExtent: AxisExtentConfigResult; + yLeftScale: YScaleType; + yRightScale: YScaleType; legend: LegendConfigResult; endValue?: EndValue; emphasizeFitting?: boolean; @@ -236,6 +238,8 @@ export interface XYProps { yRightTitle: string; yLeftExtent: AxisExtentConfigResult; yRightExtent: AxisExtentConfigResult; + yLeftScale: YScaleType; + yRightScale: YScaleType; legend: LegendConfigResult; endValue?: EndValue; emphasizeFitting?: boolean; diff --git a/src/plugins/chart_expressions/expression_xy/public/__mocks__/index.tsx b/src/plugins/chart_expressions/expression_xy/public/__mocks__/index.tsx index e84d8c001fb82..77ce5ee76ebbf 100644 --- a/src/plugins/chart_expressions/expression_xy/public/__mocks__/index.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/__mocks__/index.tsx @@ -164,7 +164,6 @@ export const dateHistogramLayer: DataLayerConfig = { layerType: LayerTypes.DATA, hide: false, xAccessor: 'xAccessorId', - yScaleType: 'linear', xScaleType: 'time', isHistogram: true, splitAccessor: 'splitAccessorId', diff --git a/src/plugins/chart_expressions/expression_xy/public/components/__snapshots__/xy_chart.test.tsx.snap b/src/plugins/chart_expressions/expression_xy/public/components/__snapshots__/xy_chart.test.tsx.snap index 3eeeee402205a..0bc41100012de 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/__snapshots__/xy_chart.test.tsx.snap +++ b/src/plugins/chart_expressions/expression_xy/public/components/__snapshots__/xy_chart.test.tsx.snap @@ -766,7 +766,6 @@ exports[`XYChart component it renders area 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -807,6 +806,7 @@ exports[`XYChart component it renders area 1`] = ` }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -1310,7 +1310,6 @@ exports[`XYChart component it renders bar 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -1351,6 +1350,7 @@ exports[`XYChart component it renders bar 1`] = ` }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -1854,7 +1854,6 @@ exports[`XYChart component it renders horizontal bar 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -1895,6 +1894,7 @@ exports[`XYChart component it renders horizontal bar 1`] = ` }, "groupId": "left", "position": "bottom", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -2398,7 +2398,6 @@ exports[`XYChart component it renders line 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -2439,6 +2438,7 @@ exports[`XYChart component it renders line 1`] = ` }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -2942,7 +2942,6 @@ exports[`XYChart component it renders stacked area 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -2983,6 +2982,7 @@ exports[`XYChart component it renders stacked area 1`] = ` }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -3486,7 +3486,6 @@ exports[`XYChart component it renders stacked bar 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -3527,6 +3526,7 @@ exports[`XYChart component it renders stacked bar 1`] = ` }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -4030,7 +4030,6 @@ exports[`XYChart component it renders stacked horizontal bar 1`] = ` "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -4071,6 +4070,7 @@ exports[`XYChart component it renders stacked horizontal bar 1`] = ` }, "groupId": "left", "position": "bottom", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -4829,7 +4829,6 @@ exports[`XYChart component split chart should render split chart if both, splitR "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -4870,6 +4869,7 @@ exports[`XYChart component split chart should render split chart if both, splitR }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -5627,7 +5627,6 @@ exports[`XYChart component split chart should render split chart if splitColumnA "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -5668,6 +5667,7 @@ exports[`XYChart component split chart should render split chart if splitColumnA }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", @@ -6425,7 +6425,6 @@ exports[`XYChart component split chart should render split chart if splitRowAcce "type": "dataLayer", "xAccessor": "c", "xScaleType": "ordinal", - "yScaleType": "linear", }, ] } @@ -6466,6 +6465,7 @@ exports[`XYChart component split chart should render split chart if splitRowAcce }, "groupId": "left", "position": "left", + "scale": "linear", "series": Array [ Object { "accessor": "a", diff --git a/src/plugins/chart_expressions/expression_xy/public/components/legend_action.test.tsx b/src/plugins/chart_expressions/expression_xy/public/components/legend_action.test.tsx index 78ac1ed8d10cf..8289d605aa913 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/legend_action.test.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/components/legend_action.test.tsx @@ -162,7 +162,6 @@ const sampleLayer: DataLayerConfig = { splitAccessor: 'splitAccessorId', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table, diff --git a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx index 7f6dcb7a73925..911dbeea10416 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.test.tsx @@ -157,7 +157,6 @@ describe('XYChart component', () => { splitAccessor: 'd', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'time', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: { @@ -254,7 +253,6 @@ describe('XYChart component', () => { splitAccessor: 'd', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'time', - yScaleType: 'linear', isHistogram: true, palette: mockPaletteOutput, table: data, @@ -847,7 +845,6 @@ describe('XYChart component', () => { layerType: LayerTypes.DATA, hide: false, xAccessor: 'xAccessorId', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: true, seriesType: 'bar_stacked', @@ -923,7 +920,6 @@ describe('XYChart component', () => { isHistogram: true, seriesType: 'bar_stacked', xAccessor: 'b', - yScaleType: 'linear', xScaleType: 'time', splitAccessor: 'b', accessors: ['d'], @@ -1045,7 +1041,6 @@ describe('XYChart component', () => { layerType: LayerTypes.DATA, hide: false, xAccessor: 'xAccessorId', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: true, seriesType: 'bar_stacked', @@ -1125,7 +1120,6 @@ describe('XYChart component', () => { accessors: ['a', 'b'], columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data, @@ -1184,7 +1178,6 @@ describe('XYChart component', () => { accessors: ['a', 'b'], columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: newData, @@ -1215,7 +1208,6 @@ describe('XYChart component', () => { accessors: ['a', 'b'], columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data, @@ -1898,7 +1890,7 @@ describe('XYChart component', () => { {...defaultProps} args={{ ...args, - layers: [{ ...(args.layers[0] as DataLayerConfig), yScaleType: 'sqrt' }], + yLeftScale: 'sqrt', }} /> ); @@ -2107,6 +2099,8 @@ describe('XYChart component', () => { xTitle: '', yTitle: '', yRightTitle: '', + yLeftScale: 'linear', + yRightScale: 'linear', legend: { type: 'legendConfig', isVisible: false, position: Position.Top }, valueLabels: 'hide', tickLabelsVisibilitySettings: { @@ -2146,7 +2140,6 @@ describe('XYChart component', () => { splitAccessor: 'b', columnToLabel: '', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data1, @@ -2161,7 +2154,6 @@ describe('XYChart component', () => { splitAccessor: 'b', columnToLabel: '', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data2, @@ -2224,6 +2216,8 @@ describe('XYChart component', () => { mode: 'full', type: 'axisExtentConfig', }, + yLeftScale: 'linear', + yRightScale: 'linear', layers: [ { layerId: 'first', @@ -2235,7 +2229,6 @@ describe('XYChart component', () => { splitAccessor: 'b', columnToLabel: '', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data, @@ -2296,6 +2289,8 @@ describe('XYChart component', () => { mode: 'full', type: 'axisExtentConfig', }, + yLeftScale: 'linear', + yRightScale: 'linear', layers: [ { layerId: 'first', @@ -2307,7 +2302,6 @@ describe('XYChart component', () => { splitAccessor: 'b', columnToLabel: '', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data, @@ -2557,7 +2551,6 @@ describe('XYChart component', () => { xAccessor: 'c', accessors: ['a', 'b'], xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: mockPaletteOutput, table: data, diff --git a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx index cce61447f16a1..7b31112c4b9ed 100644 --- a/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/components/xy_chart.tsx @@ -157,6 +157,8 @@ export function XYChart({ yLeftExtent, yRightExtent, valuesInLegend, + yLeftScale, + yRightScale, splitColumnAccessor, splitRowAccessor, } = args; @@ -210,7 +212,13 @@ export function XYChart({ filteredLayers.some((layer) => isDataLayer(layer) && layer.splitAccessor); const shouldRotate = isHorizontalChart(dataLayers); - const yAxesConfiguration = getAxesConfiguration(dataLayers, shouldRotate, formatFactory); + const yAxesConfiguration = getAxesConfiguration( + dataLayers, + shouldRotate, + formatFactory, + yLeftScale, + yRightScale + ); const xTitle = args.xTitle || (xAxisColumn && xAxisColumn.name); const axisTitlesVisibilitySettings = args.axisTitlesVisibilitySettings || { diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts index f3abf76b2d05a..7f1f8b62b75a7 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.test.ts @@ -230,7 +230,6 @@ describe('axes_configuration', () => { splitAccessor: 'd', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: { type: 'palette', name: 'default' }, table: tables.first, diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts index 5b6f35c1f8c6e..89dc87ae5383b 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/axes_configuration.ts @@ -9,7 +9,13 @@ import type { IFieldFormat, SerializedFieldFormat } from '@kbn/field-formats-plugin/common'; import { getAccessorByDimension } from '@kbn/visualizations-plugin/common/utils'; import { FormatFactory } from '../types'; -import { AxisExtentConfig, CommonXYDataLayerConfig, ExtendedYConfig, YConfig } from '../../common'; +import { + AxisExtentConfig, + CommonXYDataLayerConfig, + ExtendedYConfig, + YConfig, + YScaleType, +} from '../../common'; import { isDataLayer } from './visualization'; import { getFormat } from './format'; @@ -27,6 +33,7 @@ export type GroupsConfiguration = Array<{ position: 'left' | 'right' | 'bottom' | 'top'; formatter?: IFieldFormat; series: Series[]; + scale?: YScaleType; }>; export function isFormatterCompatible( @@ -110,7 +117,9 @@ export function groupAxesByType(layers: CommonXYDataLayerConfig[]) { export function getAxesConfiguration( layers: CommonXYDataLayerConfig[], shouldRotate: boolean, - formatFactory?: FormatFactory + formatFactory?: FormatFactory, + yLeftScale?: YScaleType, + yRightScale?: YScaleType ): GroupsConfiguration { const series = groupAxesByType(layers); @@ -122,6 +131,7 @@ export function getAxesConfiguration( position: shouldRotate ? 'bottom' : 'left', formatter: formatFactory?.(series.left[0].fieldFormat), series: series.left.map(({ fieldFormat, ...currentSeries }) => currentSeries), + scale: yLeftScale, }); } @@ -131,6 +141,7 @@ export function getAxesConfiguration( position: shouldRotate ? 'top' : 'right', formatter: formatFactory?.(series.right[0].fieldFormat), series: series.right.map(({ fieldFormat, ...currentSeries }) => currentSeries), + scale: yRightScale, }); } diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/color_assignment.test.ts b/src/plugins/chart_expressions/expression_xy/public/helpers/color_assignment.test.ts index 8b1bdeeadb834..836d7209a6a5b 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/color_assignment.test.ts +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/color_assignment.test.ts @@ -52,7 +52,6 @@ describe('color_assignment', () => { { layerId: 'first', type: 'dataLayer', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: true, seriesType: 'bar', @@ -65,7 +64,6 @@ describe('color_assignment', () => { { layerId: 'second', type: 'dataLayer', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: true, seriesType: 'bar', diff --git a/src/plugins/chart_expressions/expression_xy/public/helpers/data_layers.tsx b/src/plugins/chart_expressions/expression_xy/public/helpers/data_layers.tsx index 85b184d74029b..c2a7c847e150b 100644 --- a/src/plugins/chart_expressions/expression_xy/public/helpers/data_layers.tsx +++ b/src/plugins/chart_expressions/expression_xy/public/helpers/data_layers.tsx @@ -329,9 +329,9 @@ export const getSeriesProps: GetSeriesPropsFn = ({ data: rows, xScaleType: xColumnId ? layer.xScaleType : 'ordinal', yScaleType: - formatter?.id === 'bytes' && layer.yScaleType === ScaleType.Linear + formatter?.id === 'bytes' && yAxis?.scale === ScaleType.Linear ? ScaleType.LinearBinary - : layer.yScaleType, + : yAxis?.scale || ScaleType.Linear, color: (series) => getColor(series, { layer, diff --git a/x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap b/x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap index afdfd8e200100..46d7f535f090a 100644 --- a/x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap +++ b/x-pack/plugins/lens/public/xy_visualization/__snapshots__/to_expression.test.ts.snap @@ -145,9 +145,6 @@ Object { "linear", ], "yConfig": Array [], - "yScaleType": Array [ - "linear", - ], }, "function": "extendedDataLayer", "type": "function", @@ -234,6 +231,9 @@ Object { "type": "expression", }, ], + "yLeftScale": Array [ + "linear", + ], "yRightExtent": Array [ Object { "chain": Array [ @@ -256,6 +256,9 @@ Object { "type": "expression", }, ], + "yRightScale": Array [ + "linear", + ], "yRightTitle": Array [ "", ], diff --git a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts b/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts index 73b355bce7ed2..0b14b54f27074 100644 --- a/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts +++ b/x-pack/plugins/lens/public/xy_visualization/axes_configuration.test.ts @@ -228,7 +228,6 @@ describe('axes_configuration', () => { splitAccessor: 'd', columnToLabel: '{"a": "Label A", "b": "Label B", "d": "Label D"}', xScaleType: 'ordinal', - yScaleType: 'linear', isHistogram: false, palette: { type: 'palette', name: 'default' }, }; diff --git a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts b/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts index 368b213428ed7..d83847cb54ca4 100644 --- a/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts +++ b/x-pack/plugins/lens/public/xy_visualization/reference_line_helpers.test.ts @@ -278,7 +278,6 @@ describe('reference_line helpers', () => { xAccessor: 'a', accessors: [], type: 'dataLayer', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: false, palette: { type: 'palette', name: 'palette1' }, @@ -306,7 +305,6 @@ describe('reference_line helpers', () => { xAccessor: 'a', accessors: [], type: 'dataLayer', - yScaleType: 'linear', xScaleType: 'linear', isHistogram: false, palette: { type: 'palette', name: 'palette1' }, diff --git a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts b/x-pack/plugins/lens/public/xy_visualization/to_expression.ts index 8644b085bd454..cb6e6cff2d70e 100644 --- a/x-pack/plugins/lens/public/xy_visualization/to_expression.ts +++ b/x-pack/plugins/lens/public/xy_visualization/to_expression.ts @@ -250,6 +250,8 @@ export const buildExpression = ( fillOpacity: [state.fillOpacity || 0.3], yLeftExtent: [axisExtentConfigToExpression(state.yLeftExtent, validDataLayers)], yRightExtent: [axisExtentConfigToExpression(state.yRightExtent, validDataLayers)], + yLeftScale: [state.yLeftScale || 'linear'], + yRightScale: [state.yRightScale || 'linear'], axisTitlesVisibilitySettings: [ { type: 'expression', @@ -421,9 +423,6 @@ const dataLayerToExpression = ( layerId: [layer.layerId], hide: [Boolean(layer.hide)], xAccessor: layer.xAccessor ? [layer.xAccessor] : [], - yScaleType: [ - getScaleType(metadata[layer.layerId][layer.accessors[0]], ScaleType.Ordinal), - ], xScaleType: [getScaleType(metadata[layer.layerId][layer.xAccessor], ScaleType.Linear)], isHistogram: [isHistogramDimension], splitAccessor: layer.collapseFn || !layer.splitAccessor ? [] : [layer.splitAccessor], diff --git a/x-pack/plugins/lens/public/xy_visualization/types.ts b/x-pack/plugins/lens/public/xy_visualization/types.ts index 5fa583b075e11..d4a83c6f561a3 100644 --- a/x-pack/plugins/lens/public/xy_visualization/types.ts +++ b/x-pack/plugins/lens/public/xy_visualization/types.ts @@ -47,7 +47,6 @@ export interface XYDataLayerConfig { splitAccessor?: string; palette?: PaletteOutput; collapseFn?: string; - yScaleType?: YScaleType; xScaleType?: XScaleType; isHistogram?: boolean; columnToLabel?: string; @@ -93,6 +92,8 @@ export interface XYState { xTitle?: string; yTitle?: string; yRightTitle?: string; + yLeftScale?: YScaleType; + yRightScale?: YScaleType; axisTitlesVisibilitySettings?: AxesSettingsConfig; tickLabelsVisibilitySettings?: AxesSettingsConfig; gridlinesVisibilitySettings?: AxesSettingsConfig; diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx index 28faaf6a9e0b4..2f824cddcd9fc 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx +++ b/x-pack/plugins/lens/public/xy_visualization/xy_config_panel/axis_settings_popover.tsx @@ -14,10 +14,11 @@ import { htmlIdGenerator, EuiFieldNumber, EuiFormControlLayoutDelimited, + EuiSelect, } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { isEqual } from 'lodash'; -import { AxesSettingsConfig, AxisExtentConfig } from '@kbn/expression-xy-plugin/common'; +import { AxesSettingsConfig, AxisExtentConfig, YScaleType } from '@kbn/expression-xy-plugin/common'; import { ToolbarButtonProps } from '@kbn/kibana-react-plugin/public'; import { XYLayerConfig } from '../types'; import { ToolbarPopover, useDebouncedValue, AxisTitleSettings } from '../../shared_components'; @@ -93,6 +94,14 @@ export interface AxisSettingsPopoverProps { * Flag whether endzones are visible */ endzonesVisible?: boolean; + /** + * Set scale + */ + setScale?: (scale: YScaleType) => void; + /** + * Current scale + */ + scale?: YScaleType; /** * axis extent */ @@ -216,6 +225,8 @@ export const AxisSettingsPopover: React.FunctionComponent { const isHorizontal = layers?.length ? isHorizontalChart(layers) : false; const config = popoverConfig(axis, isHorizontal); @@ -351,6 +362,46 @@ export const AxisSettingsPopover: React.FunctionComponent )} + {setScale && ( + + setScale(e.target.value as YScaleType)} + value={scale} + /> + + )} {localExtent && setExtent && ( { + setState({ + ...state, + yLeftScale: scale, + }); + }} /> @@ -516,6 +523,13 @@ export const XyToolbar = memo(function XyToolbar( setExtent={setRightExtent} hasBarOrAreaOnAxis={hasBarOrAreaOnRightAxis} dataBounds={dataBounds.right} + scale={state?.yRightScale} + setScale={(scale) => { + setState({ + ...state, + yRightScale: scale, + }); + }} /> diff --git a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts index 912d5adf53c8f..51e1c5fe2a954 100644 --- a/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts +++ b/x-pack/plugins/lens/public/xy_visualization/xy_suggestions.ts @@ -551,6 +551,8 @@ function buildSuggestion({ valuesInLegend: currentState?.valuesInLegend, yLeftExtent: currentState?.yLeftExtent, yRightExtent: currentState?.yRightExtent, + yLeftScale: currentState?.yLeftScale, + yRightScale: currentState?.yRightScale, axisTitlesVisibilitySettings: currentState?.axisTitlesVisibilitySettings || { x: true, yLeft: true, diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 7232ee8c63f42..69299c57ba546 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -3454,7 +3454,6 @@ "expressionXY.dataLayer.xAccessor.help": "Axe X", "expressionXY.dataLayer.xScaleType.help": "Type d’échelle de l’axe x", "expressionXY.dataLayer.yConfig.help": "Configuration supplémentaire pour les axes y", - "expressionXY.dataLayer.yScaleType.help": "Type d’échelle des axes y", "expressionXY.gridlinesConfig.help": "Configurer l’aspect du quadrillage du graphique xy", "expressionXY.gridlinesConfig.x.help": "Spécifie si le quadrillage de l'axe X est visible ou non.", "expressionXY.gridlinesConfig.yLeft.help": "Spécifie si le quadrillage de l'axe Y de gauche est visible ou non.", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 003a20771c1cb..d25e5e5c2b7a0 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -3551,7 +3551,6 @@ "expressionXY.dataLayer.xAccessor.help": "X 軸", "expressionXY.dataLayer.xScaleType.help": "x軸の目盛タイプ", "expressionXY.dataLayer.yConfig.help": "y軸の詳細構成", - "expressionXY.dataLayer.yScaleType.help": "y軸の目盛タイプ", "expressionXY.gridlinesConfig.help": "xyグラフのグリッド線表示を構成", "expressionXY.gridlinesConfig.x.help": "x 軸のグリッド線を表示するかどうかを指定します。", "expressionXY.gridlinesConfig.yLeft.help": "左y軸のグリッド線を表示するかどうかを指定します。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index e86c12888a520..84a5474c0efa0 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -3562,7 +3562,6 @@ "expressionXY.dataLayer.xAccessor.help": "X 轴", "expressionXY.dataLayer.xScaleType.help": "x 轴的缩放类型", "expressionXY.dataLayer.yConfig.help": "y 轴的其他配置", - "expressionXY.dataLayer.yScaleType.help": "y 轴的缩放类型", "expressionXY.gridlinesConfig.help": "配置 xy 图表的网格线外观", "expressionXY.gridlinesConfig.x.help": "指定 x 轴的网格线是否可见。", "expressionXY.gridlinesConfig.yLeft.help": "指定左侧 y 轴的网格线是否可见。",