Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export class LensAttributes {
}),
operationType: 'percentile',
params: { percentile: Number(percentileValue.split('th')[0]) },
customLabel: true,
};
}

Expand Down Expand Up @@ -724,10 +725,7 @@ export class LensAttributes {

getDataLayers(): XYState['layers'] {
const dataLayers = this.layerConfigs.map((layerConfig, index) => ({
accessors: [
`y-axis-column-layer${index}`,
...Object.keys(this.getChildYAxises(layerConfig, `layer${index}`)),
],
accessors: [`y-axis-column-layer${index}`],
layerId: `layer${index}`,
layerType: 'data' as any,
seriesType: layerConfig.seriesType || layerConfig.seriesConfig.defaultSeriesType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function getDistributionInPercentageColumn({
}

const main: FormulaIndexPatternColumn = {
customLabel: true,
label: label || 'Percentage of records',
dataType: 'number' as DataType,
operationType: 'formula',
Expand All @@ -41,7 +42,7 @@ export function getDistributionInPercentageColumn({
isFormulaBroken: false,
format: { id: 'percent', params: { decimals: 0 } },
},
references: [`${yAxisColId}X4`],
references: [`${yAxisColId}X3`],
};

const countColumn: CountIndexPatternColumn = {
Expand All @@ -55,24 +56,13 @@ export function getDistributionInPercentageColumn({
filter: { query: columnFilter ?? '', language: 'kuery' },
};

const mathColumn: MathIndexPatternColumn = {
label: 'Part of count() / overall_sum(count())',
dataType: 'number',
operationType: 'math',
isBucketed: false,
scale: 'ratio',
params: { tinymathAst: `${yAxisColId}X1` },
references: [`${yAxisColId}X1`],
customLabel: true,
};

const overAllSumColumn: OverallSumIndexPatternColumn = {
label: 'Part of count() / overall_sum(count())',
dataType: 'number',
operationType: 'overall_sum',
isBucketed: false,
scale: 'ratio',
references: [`${yAxisColId}X2`],
references: [`${yAxisColId}X1`],
customLabel: true,
};

Expand All @@ -86,12 +76,12 @@ export function getDistributionInPercentageColumn({
tinymathAst: {
type: 'function',
name: 'divide',
args: [`${yAxisColId}X0`, `${yAxisColId}X3`],
args: [`${yAxisColId}X0`, `${yAxisColId}X2`],
location: { min: 0, max: 30 },
text: lensFormula,
} as unknown as TinymathAST,
},
references: [`${yAxisColId}X0`, `${yAxisColId}X3`],
references: [`${yAxisColId}X0`, `${yAxisColId}X2`],
customLabel: true,
};

Expand All @@ -101,9 +91,8 @@ export function getDistributionInPercentageColumn({
> = {
[`${yAxisColId}X0`]: countColumn,
[`${yAxisColId}X1`]: countColumn,
[`${yAxisColId}X2`]: mathColumn,
[`${yAxisColId}X3`]: overAllSumColumn,
[`${yAxisColId}X4`]: tinyMathColumn,
[`${yAxisColId}X2`]: overAllSumColumn,
[`${yAxisColId}X3`]: tinyMathColumn,
};

return { main, supportingColumns };
Expand Down