From 63046107133b0b8b641721c3015f68c29db01638 Mon Sep 17 00:00:00 2001 From: "SPRINX0\\prochazka" Date: Wed, 16 Jul 2025 13:42:50 +0200 Subject: [PATCH] SYNC: hard limit for pie chart --- packages/datalib/src/chartDefinitions.ts | 1 + packages/datalib/src/chartProcessor.ts | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/datalib/src/chartDefinitions.ts b/packages/datalib/src/chartDefinitions.ts index b4e3b2d36..d335c15cd 100644 --- a/packages/datalib/src/chartDefinitions.ts +++ b/packages/datalib/src/chartDefinitions.ts @@ -25,6 +25,7 @@ export const ChartLimits = { VALID_VALUE_RATIO_LIMIT: 0.5, // limit for valid value ratio, y defs below this will not be used in auto-detect PIE_RATIO_LIMIT: 0.05, // limit for other values in pie chart, if the value is below this, it will be grouped into "Other" PIE_COUNT_LIMIT: 10, // limit for number of pie chart slices, if the number of slices is above this, it will be grouped into "Other" + MAX_PIE_COUNT_LIMIT: 50, // max pie limit CHART_FILL_LIMIT: 10000, // limit for filled charts (time intervals), to avoid too many points CHART_GROUP_LIMIT: 32, // limit for number of groups in a chart }; diff --git a/packages/datalib/src/chartProcessor.ts b/packages/datalib/src/chartProcessor.ts index 6aa61f430..a1696af30 100644 --- a/packages/datalib/src/chartProcessor.ts +++ b/packages/datalib/src/chartProcessor.ts @@ -407,14 +407,17 @@ export class ChartProcessor { ]; } groupPieOtherBuckets(chart: ProcessedChart) { - if (chart.definition.chartType !== 'pie') { + if (chart.definition.chartType != 'pie' && chart.definition.chartType != 'polarArea') { return; // only for pie charts } const ratioLimit = chart.definition.pieRatioLimit ?? ChartLimits.PIE_RATIO_LIMIT; - const countLimit = chart.definition.pieCountLimit ?? ChartLimits.PIE_COUNT_LIMIT; - if (ratioLimit == 0 && countLimit == 0) { - return; // no grouping if limit is 0 + let countLimit = chart.definition.pieCountLimit ?? ChartLimits.PIE_COUNT_LIMIT; + if (!countLimit || countLimit <= 1 || countLimit > ChartLimits.MAX_PIE_COUNT_LIMIT) { + countLimit = ChartLimits.MAX_PIE_COUNT_LIMIT; // limit to max pie count } + // if (ratioLimit == 0 && countLimit == 0) { + // return; // no grouping if limit is 0 + // } const otherBucket: any = {}; let newBuckets: any = {}; const cardSum = _sum(Object.values(chart.buckets).map(bucket => computeChartBucketCardinality(bucket)));