amaannawab923 commented on code in PR #33559:
URL: https://github.com/apache/superset/pull/33559#discussion_r2102277436
##########
superset-frontend/plugins/plugin-chart-echarts/src/Radar/transformProps.ts:
##########
@@ -212,7 +250,40 @@ export default function transformProps(
{},
);
+ // Add normalization function
+ const normalizeArray = (arr: number[], decimals = 10, seriesName: string) =>
{
+ const max = Math.max(...arr);
+ return arr.map(value => {
+ const normalisedValue = Number((value / max).toFixed(decimals));
+ denormalizedSeriesValues[seriesName][String(normalisedValue)] = value;
+ return normalisedValue;
+ });
+ };
+
+ if (isNormalised) {
+ // Normalize the transformed data
+ transformedData = transformedData.map(series => {
+ if (Array.isArray(series.value)) {
+ const seriesName = String(series?.name || '');
+ denormalizedSeriesValues[seriesName] = {};
+
+ return {
+ ...series,
+ value: normalizeArray(series.value as number[], 10, seriesName),
+ };
+ }
+ return series;
+ });
+ }
+
const indicator = metricLabels.map(metricLabel => {
+ if (isNormalised) {
+ return {
+ name: metricLabel,
+ max: 1,
+ min: 0,
+ };
+ }
Review Comment:
If the values are normalised we consider min & max as 0 & 1 respectively &
hence we dont need to calculate the rest as they are only in case when
isNormalised is not true & some column config is provided
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]