Skip to content

Commit

Permalink
[Lens] Add log and sqrt scale (#131940)
Browse files Browse the repository at this point in the history
* add log and sqrt scale

* Update axis_settings_popover.tsx

* fix types

* carry over scale types

* fix test

* bump limit ever so slightly

Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co>
  • Loading branch information
flash1293 and stratoula authored May 16, 2022
1 parent ee22d7e commit b1473f8
Show file tree
Hide file tree
Showing 27 changed files with 150 additions and 65 deletions.
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,5 +128,5 @@ pageLoadAssetSize:
eventAnnotation: 19334
screenshotting: 22870
synthetics: 40958
expressionXY: 30000
expressionXY: 31000
kibanaUsageCollection: 16463
Original file line number Diff line number Diff line change
Expand Up @@ -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([]),
Expand Down Expand Up @@ -108,6 +107,8 @@ export const createArgsWithLayers = (
type: 'axisExtentConfig',
},
layers: Array.isArray(layers) ? layers : [layers],
yLeftScale: 'linear',
yRightScale: 'linear',
});

export function sampleArgs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
TICK_LABELS_CONFIG,
ValueLabelModes,
XYCurveTypes,
YScaleTypes,
} from '../constants';
import { strings } from '../i18n';
import { LayeredXyVisFn, XyVisFn } from '../types';
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -55,7 +54,6 @@ export const xyVisFn: XyVisFn['fn'] = async (data, args, handlers) => {
hide,
splitAccessor,
columnToLabel,
yScaleType,
xScaleType,
isHistogram,
yConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -213,6 +213,8 @@ export interface LayeredXYArgs {
yRightTitle: string;
yLeftExtent: AxisExtentConfigResult;
yRightExtent: AxisExtentConfigResult;
yLeftScale: YScaleType;
yRightScale: YScaleType;
legend: LegendConfigResult;
endValue?: EndValue;
emphasizeFitting?: boolean;
Expand All @@ -236,6 +238,8 @@ export interface XYProps {
yRightTitle: string;
yLeftExtent: AxisExtentConfigResult;
yRightExtent: AxisExtentConfigResult;
yLeftScale: YScaleType;
yRightScale: YScaleType;
legend: LegendConfigResult;
endValue?: EndValue;
emphasizeFitting?: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export const dateHistogramLayer: DataLayerConfig = {
layerType: LayerTypes.DATA,
hide: false,
xAccessor: 'xAccessorId',
yScaleType: 'linear',
xScaleType: 'time',
isHistogram: true,
splitAccessor: 'splitAccessorId',
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit b1473f8

Please sign in to comment.