feat(chart): add toggle for percentage metric calculation mode in Table chart (#33656)

This commit is contained in:
Levis Mbote
2025-06-13 21:00:58 +03:00
committed by GitHub
parent 0d3eebd221
commit 7deca8f2cd
6 changed files with 216 additions and 13 deletions

View File

@@ -161,12 +161,30 @@ const generateComparisonColumns = (colname: string) => [
`${colname}`,
`% ${colname}`,
];
/**
* Generate column types for the comparison columns.
*/
const generateComparisonColumnTypes = (count: number) =>
Array(count).fill(GenericDataType.Numeric);
const percentMetricCalculationControl: ControlConfig<'SelectControl'> = {
type: 'SelectControl',
label: t('Percentage metric calculation'),
description: t(
'Row Limit: percentages are calculated based on the subset of data retrieved, respecting the row limit. ' +
'All Records: Percentages are calculated based on the total dataset, ignoring the row limit.',
),
default: 'row_limit',
clearable: false,
choices: [
['row_limit', t('Row limit')],
['all_records', t('All records')],
],
visibility: isAggMode,
renderTrigger: false,
};
const processComparisonColumns = (columns: any[], suffix: string) =>
columns
.map(col => {
@@ -433,6 +451,13 @@ const config: ControlPanelConfig = {
},
},
],
[
{
name: 'percent_metric_calculation',
config: percentMetricCalculationControl,
},
],
[
{
name: 'show_totals',