Skip to content

Instantly share code, notes, and snippets.

@thomasneirynck
Last active May 28, 2025 22:24
Show Gist options
  • Save thomasneirynck/95ae5c5834c4f48bb6d3fcfdb6375b50 to your computer and use it in GitHub Desktop.
Save thomasneirynck/95ae5c5834c4f48bb6d3fcfdb6375b50 to your computer and use it in GitHub Desktop.
Lens Chart Definition
interface LensChart {
attributes:
| {
visualizationType: 'lnsXY';
title: string;
description?: string;
state: {
datasourceStates: Record<string, unknown>;
query: any;
filters: any;
needsRefresh?: boolean;
globalPalette?: {
activePaletteId: string;
state?: unknown;
};
visualization: {
preferredSeriesType:
| 'bar'
| 'line'
| 'area'
| 'bar_stacked'
| 'area_stacked'
| 'bar_horizontal'
| 'bar_percentage_stacked'
| 'bar_horizontal_stacked'
| 'area_percentage_stacked'
| 'bar_horizontal_percentage_stacked';
legend: {
isVisible: boolean;
position: 'top' | 'bottom' | 'left' | 'right';
showSingleSeries?: boolean;
isInside?: boolean;
horizontalAlignment?: 'right' | 'left';
verticalAlignment?: 'top' | 'bottom';
floatingColumns?: number;
maxLines?: number;
shouldTruncate?: boolean;
legendSize?: 'auto' | 'small' | 'medium' | 'large' | 'xlarge';
legendStats?: (
| 'currentAndLastValue'
| 'lastValue'
| 'lastNonNullValue'
| 'average'
| 'median'
| 'max'
| 'min'
| 'firstValue'
| 'firstNonNullValue'
| 'total'
| 'count'
| 'distinctCount'
| 'variance'
| 'stdDeviation'
| 'range'
| 'difference'
| 'differencePercent'
)[];
layout?: 'table' | 'list';
title?: string;
isTitleVisible?: boolean;
};
valueLabels?: 'hide' | 'show';
fittingFunction?: 'None' | 'Zero' | 'Linear' | 'Carry' | 'Lookahead' | 'Average' | 'Nearest';
emphasizeFitting?: boolean;
endValue?: 'None' | 'Zero' | 'Nearest';
xExtent?: {
mode: 'full' | 'custom' | 'dataBounds';
lowerBound?: number;
upperBound?: number;
enforce?: boolean;
niceValues?: boolean;
};
yLeftExtent?: {
mode: 'full' | 'custom' | 'dataBounds';
lowerBound?: number;
upperBound?: number;
enforce?: boolean;
niceValues?: boolean;
};
yRightExtent?: {
mode: 'full' | 'custom' | 'dataBounds';
lowerBound?: number;
upperBound?: number;
enforce?: boolean;
niceValues?: boolean;
};
layers: (
| {
layerId: string;
accessors: string[];
layerType: 'data';
seriesType:
| 'bar'
| 'line'
| 'area'
| 'bar_stacked'
| 'area_stacked'
| 'bar_horizontal'
| 'bar_percentage_stacked'
| 'bar_horizontal_stacked'
| 'area_percentage_stacked'
| 'bar_horizontal_percentage_stacked';
xAccessor?: string;
simpleView?: boolean;
yConfig?: {
forAccessor: string;
color?: string;
icon?: string;
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted';
fill?: 'none' | 'above' | 'below';
iconPosition?: 'auto' | 'left' | 'right' | 'above' | 'below';
textVisibility?: boolean;
axisMode?: 'auto' | 'left' | 'right' | 'bottom';
}[];
splitAccessor?: string;
palette?: {
type: 'palette' | 'system_palette';
name: string;
params?: Record<string, unknown>;
};
collapseFn?: 'sum' | 'avg' | 'min' | 'max';
xScaleType?: 'time' | 'linear' | 'ordinal';
isHistogram?: boolean;
columnToLabel?: string;
colorMapping?: {
paletteId: string;
colorMode:
| { type: 'categorical' }
| {
type: 'gradient';
steps: Array<
(
| { type: 'categorical'; paletteId: string; colorIndex: number }
| { type: 'colorCode'; colorCode: string }
) & { touched: boolean }
>;
sort: 'asc' | 'desc';
};
assignments: Array<
{
rule:
| { type: 'auto' }
| { type: 'range'; min: number; max: number; minInclusive: boolean; maxInclusive: boolean }
| { type: 'matchExactly'; values: Array<string | string[]> }
| { type: 'matchExactlyCI'; values: string[] }
| { type: 'regex'; values: string };
color:
| { type: 'categorical'; paletteId: string; colorIndex: number }
| { type: 'colorCode'; colorCode: string }
| { type: 'gradient' };
touched: boolean;
}
>;
};
}
| {
layerId: string;
accessors: string[];
layerType: 'referenceLine';
yConfig?: {
forAccessor: string;
color?: string;
icon?: string;
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted';
fill?: 'none' | 'above' | 'below';
iconPosition?: 'auto' | 'left' | 'right' | 'above' | 'below';
textVisibility?: boolean;
axisMode?: 'auto' | 'left' | 'right' | 'bottom';
}[];
}
| {
layerId: string;
layerType: 'annotations';
annotations: (
| {
id: string;
type: 'manual';
key: {
type: 'point_in_time';
timestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
| {
type: 'manual';
id: string;
key: {
type: 'range';
timestamp: string;
endTimestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
outside?: boolean;
}
| {
id: string;
type: 'query';
filter: any;
timeField?: string;
textField?: string;
extraFields?: string[];
key: {
type: 'point_in_time';
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
)[];
indexPatternId: string;
ignoreGlobalFilters: boolean;
cachedMetadata?: {
title: string;
description: string;
tags: string[];
};
}
| {
layerId: string;
layerType: 'annotations';
annotations: (
| {
id: string;
type: 'manual';
key: {
type: 'point_in_time';
timestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
| {
type: 'manual';
id: string;
key: {
type: 'range';
timestamp: string;
endTimestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
outside?: boolean;
}
| {
id: string;
type: 'query';
filter: any;
timeField?: string;
textField?: string;
extraFields?: string[];
key: {
type: 'point_in_time';
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
)[];
indexPatternId: string;
ignoreGlobalFilters: boolean;
annotationGroupId: string;
__lastSaved: {
annotations: (
| {
id: string;
type: 'manual';
key: {
type: 'point_in_time';
timestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
| {
type: 'manual';
id: string;
key: {
type: 'range';
timestamp: string;
endTimestamp: string;
};
label: string;
color?: string;
isHidden?: boolean;
outside?: boolean;
}
| {
id: string;
type: 'query';
filter: any;
timeField?: string;
textField?: string;
extraFields?: string[];
key: {
type: 'point_in_time';
};
label: string;
color?: string;
isHidden?: boolean;
icon?: 'asterisk' | 'alert' | 'bell' | 'bolt' | 'bug' | 'circle' | 'editorComment' | 'flag' | 'heart' | 'mapMarker' | 'pinFilled' | 'starEmpty' | 'starFilled' | 'tag' | 'triangle';
lineWidth?: number;
lineStyle?: 'solid' | 'dashed' | 'dotted' | 'dot-dashed';
textVisibility?: boolean;
}
)[];
indexPatternId: string;
ignoreGlobalFilters: boolean;
title: string;
description: string;
tags: string[];
dataViewSpec?: any;
};
}
)[];
xTitle?: string;
yTitle?: string;
yRightTitle?: string;
yLeftScale?: 'time' | 'linear' | 'log' | 'sqrt';
yRightScale?: 'time' | 'linear' | 'log' | 'sqrt';
axisTitlesVisibilitySettings?: {
yLeft: boolean;
yRight: boolean;
};
tickLabelsVisibilitySettings?: {
yLeft: boolean;
yRight: boolean;
};
gridlinesVisibilitySettings?: {
yLeft: boolean;
yRight: boolean;
};
labelsOrientation?: {
x: number;
yLeft: number;
yRight: number;
};
curveType?: 'LINEAR' | 'CURVE_MONOTONE_X' | 'CURVE_STEP_AFTER';
fillOpacity?: number;
minBarHeight?: number;
hideEndzones?: boolean;
showCurrentTimeMarker?: boolean;
};
};
}
| {
visualizationType: 'lnsPie';
title: string;
description?: string;
state: {
datasourceStates: Record<string, unknown>;
query: any;
filters: any;
needsRefresh?: boolean;
globalPalette?: {
activePaletteId: string;
state?: unknown;
};
visualization: {
shape: 'pie' | 'donut' | 'treemap' | 'mosaic' | 'waffle';
layers: {
layerId: string;
layerType: 'data' | 'referenceLine' | 'annotations' | 'metricTrendline';
metrics: string[];
primaryGroups: string[];
secondaryGroups?: string[];
allowMultipleMetrics?: boolean;
colorsByDimension?: Record<string, string>;
collapseFns?: Record<string, 'sum' | 'avg' | 'min' | 'max'>;
numberDisplay: 'hidden' | 'percent' | 'value';
categoryDisplay: 'default' | 'inside' | 'hide';
legendDisplay: 'default' | 'show' | 'hide';
legendPosition?: 'top' | 'bottom' | 'left' | 'right';
legendStats?: ('value' | 'percent')[];
nestedLegend?: boolean;
percentDecimals?: number;
emptySizeRatio?: number;
legendMaxLines?: number;
legendSize?: 'auto' | 'small' | 'medium' | 'large' | 'xlarge';
truncateLegend?: boolean;
colorMapping?: {
paletteId: string;
colorMode:
| { type: 'categorical' }
| {
type: 'gradient';
steps: Array<
(
| { type: 'categorical'; paletteId: string; colorIndex: number }
| { type: 'colorCode'; colorCode: string }
) & { touched: boolean }
>;
sort: 'asc' | 'desc';
};
assignments: Array<
{
rule:
| { type: 'auto' }
| { type: 'range'; min: number; max: number; minInclusive: boolean; maxInclusive: boolean }
| { type: 'matchExactly'; values: Array<string | string[]> }
| { type: 'matchExactlyCI'; values: string[] }
| { type: 'regex'; values: string };
color:
| { type: 'categorical'; paletteId: string; colorIndex: number }
| { type: 'colorCode'; colorCode: string }
| { type: 'gradient' };
touched: boolean;
}
>;
};
}[];
palette?: {
type: 'palette' | 'system_palette';
name: string;
params?: Record<string, unknown>;
};
};
};
};
}
@thomasneirynck
Copy link
Author

Flattened definition of a Lens object. Generated from kibana source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment