{"version":3,"file":"transformDataForGraph-Y8AvNF-O.cjs","names":[],"sources":["../src/Utils/transformData/transformDataForAggregation.ts","../src/Utils/transformData/graphConfig.ts","../src/Utils/checkDataValidity.ts","../src/Utils/transformData/transformDataForGraph.ts"],"sourcesContent":["import flattenDeep from 'lodash.flattendeep';\r\nimport sum from 'lodash.sum';\r\nimport type { AggregationSettingsDataType } from '@/Types';\r\nimport { uniqBy } from '../uniqBy';\r\n/**\r\n * Transforms the data for aggregation based on a key column and specified aggregation settings.\r\n * It groups the data by unique values in the key column and applies the aggregation methods to each group.\r\n *\r\n * @param data - The input data to be aggregated. Can be an array of objects, where each object represents a data row.\r\n * @param keyColumn - The name of the column to group the data by (key column).\r\n * @param aggregationSettings - Optional settings for the aggregation, specifying the column and aggregation method (e.g., 'average', 'max', 'min', 'sum').\r\n *                              Each setting can define a column and a corresponding aggregation method to apply to that column.\r\n *\r\n * @returns An array of objects where each object contains the aggregated values for each unique value in the key column.\r\n *          Each object includes the key column value, count of occurrences, and the aggregated values for each specified column.\r\n *\r\n * @example\r\n * const data = [\r\n *   { category: 'A', value: 10, amount: 5 },\r\n *   { category: 'A', value: 20, amount: 10 },\r\n *   { category: 'B', value: 15, amount: 7 },\r\n * ];\r\n * const aggregationSettings = [\r\n *   { column: 'value', aggregationMethod: 'average' },\r\n *   { column: 'amount', aggregationMethod: 'sum' },\r\n * ];\r\n * const transformedData = transformDataForAggregation(data, 'category', aggregationSettings);\r\n * console.log(transformedData);\r\n * // Output:\r\n * // [\r\n * //   { category: 'A', count: 2, value: 15, amount: 15 },\r\n * //   { category: 'B', count: 1, value: 15, amount: 7 },\r\n * // ]\r\n */\r\nexport function transformDataForAggregation(\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  data: any,\r\n  keyColumn: string,\r\n  aggregationSettings?: AggregationSettingsDataType[],\r\n) {\r\n  if (data.length === 0) return [];\r\n  if (typeof data[0][keyColumn] !== 'object') {\r\n    const uniqValues = uniqBy(data, keyColumn).map((d) => {\r\n      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n      const dataObj: any = {};\r\n      dataObj[keyColumn] = d;\r\n      const filteredData = data.filter(\r\n        // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n        (j: any) => j[keyColumn] === d,\r\n      );\r\n      dataObj.count = filteredData.length;\r\n      dataObj.rollUpData = filteredData;\r\n      aggregationSettings?.forEach((el) => {\r\n        dataObj[el.column] =\r\n          el.aggregationMethod === 'average'\r\n            ? parseFloat(\r\n                // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                (sum(filteredData.map((j: any) => j[el.column])) / filteredData.length).toFixed(2),\r\n              )\r\n            : el.aggregationMethod === 'max'\r\n              ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                Math.max(...filteredData.map((j: any) => j[el.column]))\r\n              : el.aggregationMethod === 'min'\r\n                ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  Math.min(...filteredData.map((j: any) => j[el.column]))\r\n                : // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                  sum(filteredData.map((j: any) => j[el.column]));\r\n      });\r\n      return dataObj;\r\n    });\r\n    return uniqValues;\r\n  }\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  const values = [...new Set(flattenDeep(data.map((d: any) => d[keyColumn])))];\r\n  const uniqValues = values.map((d) => {\r\n    // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n    const dataObj: any = {};\r\n    dataObj[keyColumn] = d;\r\n    const filteredData = data.filter(\r\n      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n      (j: any) => j[keyColumn].indexOf(d) !== -1,\r\n    );\r\n    dataObj.rollUpData = filteredData;\r\n    dataObj.count = filteredData.length;\r\n    aggregationSettings?.forEach((el) => {\r\n      dataObj[el.column] =\r\n        el.aggregationMethod === 'average'\r\n          ? parseFloat(\r\n              // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n              (sum(filteredData.map((j: any) => j[el.column])) / filteredData.length).toFixed(2),\r\n            )\r\n          : el.aggregationMethod === 'max'\r\n            ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n              Math.max(...filteredData.map((j: any) => j[el.column]))\r\n            : el.aggregationMethod === 'min'\r\n              ? // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                Math.min(...filteredData.map((j: any) => j[el.column]))\r\n              : // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n                sum(filteredData.map((j: any) => j[el.column]));\r\n    });\r\n    return dataObj;\r\n  });\r\n  return uniqValues;\r\n}\r\n","import type { GraphType, ThreeDGraphType } from '@/Types';\r\n\r\nexport const ChartConfiguration: {\r\n  chartID: GraphType | ThreeDGraphType;\r\n  configuration: { id: string; required: boolean; multiple: boolean }[];\r\n}[] = [\r\n  {\r\n    chartID: 'barChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'waterfallChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'bulletChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'target',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'qualitativeRange',\r\n        required: false,\r\n        multiple: true,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'radarChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'values',\r\n        required: true,\r\n        multiple: true,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'stackedBarChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        multiple: true,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'groupedBarChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        multiple: true,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'lineChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'dualAxisLineChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y1',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'y2',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'differenceLineChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y1',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'y2',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'multiLineChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        multiple: true,\r\n        required: true,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'multiLineAltChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'label',\r\n        multiple: false,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'color',\r\n        multiple: false,\r\n        required: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'stackedAreaChart',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        multiple: true,\r\n        required: true,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'threeDGlobe',\r\n    configuration: [\r\n      {\r\n        id: 'id',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'x',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'choroplethMap',\r\n    configuration: [\r\n      {\r\n        id: 'id',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'x',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'biVariateChoroplethMap',\r\n    configuration: [\r\n      {\r\n        id: 'id',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'x',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'dotDensityMap',\r\n    configuration: [\r\n      {\r\n        id: 'lat',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'long',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'label',\r\n        multiple: false,\r\n        required: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        multiple: false,\r\n        required: false,\r\n      },\r\n      {\r\n        id: 'radius',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'hybridMap',\r\n    configuration: [\r\n      {\r\n        id: 'id',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'x',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'lat',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'long',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'label',\r\n        multiple: false,\r\n        required: false,\r\n      },\r\n      {\r\n        id: 'radius',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'donutChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'slopeChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y1',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y2',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'scatterPlot',\r\n    configuration: [\r\n      {\r\n        id: 'x',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'radius',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'dumbbellChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'x',\r\n        multiple: true,\r\n        required: true,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'treeMap',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'circlePacking',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'size',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'sankeyChart',\r\n    configuration: [\r\n      {\r\n        id: 'source',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'target',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'value',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'heatMap',\r\n    configuration: [\r\n      {\r\n        id: 'row',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'column',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'value',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'stripChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'group',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'position',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'statCard',\r\n    configuration: [\r\n      {\r\n        id: 'value',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'beeSwarmChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'group',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'position',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'radius',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'color',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'butterflyChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'leftBar',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'rightBar',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'date',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'lineChartWithConfidenceInterval',\r\n    configuration: [\r\n      {\r\n        id: 'date',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'yMin',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'yMax',\r\n        required: false,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'histogram',\r\n    configuration: [\r\n      {\r\n        id: 'value',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'sparkLine',\r\n    configuration: [\r\n      {\r\n        id: 'dale',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'y',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'paretoChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'bar',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'line',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n  {\r\n    chartID: 'unitChart',\r\n    configuration: [\r\n      {\r\n        id: 'label',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n      {\r\n        id: 'value',\r\n        required: true,\r\n        multiple: false,\r\n      },\r\n    ],\r\n  },\r\n];\r\n","import flattenDeep from 'lodash.flattendeep';\r\nimport type { GraphConfigurationDataType, GraphType, ThreeDGraphType } from '@/Types';\r\nimport { ChartConfiguration } from './transformData/graphConfig';\r\n\r\nfunction missingValuesInArray(superset: string[], subset: string[]): string[] {\r\n  return subset.filter((value) => !superset.includes(value));\r\n}\r\n\r\nexport function checkDataConfigValidity(\r\n  dataConfig: GraphConfigurationDataType[],\r\n  graph: GraphType | ThreeDGraphType,\r\n  dataKeys: string[],\r\n) {\r\n  const dataKeyFromDataConfig = flattenDeep(dataConfig.map((d) => d.columnId));\r\n  const checkDataKeys = missingValuesInArray(dataKeys, dataKeyFromDataConfig);\r\n  if (checkDataKeys.length !== 0)\r\n    return {\r\n      isValid: false,\r\n      err: `Key(s) in configuration that don't match keys in the data: ${checkDataKeys.join(\r\n        ', ',\r\n      )}. Possible reason: If you are using 'dataTransform' then the allowed keys (columns) are only the one present in 'aggregationColumnsSetting' array in 'dataTransform' object plus an additional key called 'count'.`,\r\n    };\r\n  const ids = dataConfig.map((el) => el.chartConfigId);\r\n  const requiredIds = ChartConfiguration[\r\n    ChartConfiguration.findIndex((el) => el.chartID === graph)\r\n  ].configuration\r\n    .filter((el) => el.required)\r\n    .map((el) => el.id);\r\n  const ifRequiredIdsPresent = missingValuesInArray(ids, requiredIds);\r\n  return {\r\n    isValid: ifRequiredIdsPresent.length === 0,\r\n    err:\r\n      ifRequiredIdsPresent.length === 0\r\n        ? undefined\r\n        : `Missing required ID(s) in configuration: ${ifRequiredIdsPresent.join(', ')}`,\r\n  };\r\n}\r\n","import type { GraphConfigurationDataType, GraphType, ThreeDGraphType } from '@/Types';\r\nimport { checkDataConfigValidity } from '../checkDataValidity';\r\nimport { checkIfNullOrUndefined } from '../checkIfNullOrUndefined';\r\nimport { graphList } from '../getGraphList';\r\nimport { ChartConfiguration } from './graphConfig';\r\n/**\r\n * Transforms the input data into a format suitable for graph visualization based on the given graph type and configuration.\r\n *\r\n * The function formats the data according to the specified graph configuration and checks the validity of the configuration.\r\n * It also handles cases for graphs like \"dataTable\" and \"dataCards\" without additional processing, and it processes\r\n * more complex graphs (e.g., charts) with a specific configuration.\r\n *\r\n * @param data - The data to be transformed, typically an array of objects representing rows of data.\r\n * @param graph - The type of graph to transform the data for (e.g., lineChart, barChart, etc.).\r\n * @param config - An optional array of configuration objects that define how the data should be mapped to the graph.\r\n *                 Each object in the array should define column mappings and how data should be grouped or aggregated.\r\n *\r\n * @returns The transformed data in the format required by the graph. If no valid configuration is provided, or if\r\n *          data is invalid, an error message is returned.\r\n *          - If the graph type is \"dataTable\" or \"dataCards\", the original data is returned unchanged.\r\n *          - If data is invalid, an error message will be returned.\r\n *\r\n * @throws {string} If the configuration is invalid or the data can't be processed, an error message is logged and\r\n *                  returned.\r\n *\r\n * @example\r\n * const graphData = [\r\n *   { category: 'A', value: 10 },\r\n *   { category: 'B', value: 15 },\r\n * ];\r\n * const graph = 'barChart';\r\n * const config = [\r\n *   { columnId: 'category', chartConfigId: 'label' },\r\n *   { columnId: 'value', chartConfigId: 'size' },\r\n * ];\r\n * const transformedData = transformDataForGraph(graphData, graph, config);\r\n * console.log(transformedData);\r\n */\r\nexport function transformDataForGraph(\r\n  // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n  data: any,\r\n  graph: GraphType | ThreeDGraphType,\r\n  config?: GraphConfigurationDataType[],\r\n) {\r\n  if (\r\n    graphList\r\n      .filter((el) => el.geoHubMapPresentation)\r\n      .map((el) => el.graphID)\r\n      .indexOf(graph) !== -1\r\n  )\r\n    return data;\r\n  if (!data) return 'Cannot fetch data';\r\n  if (graph === 'dataTable' || graph === 'dataCards' || data.length === 0) return data;\r\n  if (!config) {\r\n    console.error('Your data configuration is not accurate');\r\n    return 'No graph configuration is provided';\r\n  }\r\n  const dataConfigValidity = checkDataConfigValidity(config, graph, Object.keys(data[0]));\r\n  if (dataConfigValidity.isValid) {\r\n    const chartConfig =\r\n      ChartConfiguration[ChartConfiguration.findIndex((d) => d.chartID === graph)].configuration;\r\n    // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n    const dataFormatted = data.map((d: any) => {\r\n      // biome-ignore lint/suspicious/noExplicitAny: undefined data type\r\n      const obj: any = {};\r\n      config\r\n        .filter((el) => el.columnId)\r\n        .forEach((el) => {\r\n          if (chartConfig[chartConfig.findIndex((k) => k.id === el.chartConfigId)].multiple) {\r\n            obj[chartConfig[chartConfig.findIndex((k) => k.id === el.chartConfigId)].id] = [];\r\n            (el.columnId as string[]).forEach((l) => {\r\n              obj[chartConfig[chartConfig.findIndex((k) => k.id === el.chartConfigId)].id].push(\r\n                checkIfNullOrUndefined(d[l]) ? null : d[l],\r\n              );\r\n            });\r\n          } else {\r\n            obj[chartConfig[chartConfig.findIndex((k) => k.id === el.chartConfigId)].id] =\r\n              checkIfNullOrUndefined(d[el.columnId as string]) ? null : d[el.columnId as string];\r\n          }\r\n          obj[`${el.chartConfigId}Columns`] = el.columnId;\r\n        });\r\n      obj.data = d;\r\n      return obj;\r\n    });\r\n    return dataFormatted;\r\n  }\r\n  console.error(dataConfigValidity.err);\r\n  return dataConfigValidity.err;\r\n}\r\n"],"mappings":"+RAkCA,SAAgB,EAEd,EACA,EACA,EACA,CA+DA,OA9DI,EAAK,SAAW,EAAU,CAAC,EAC3B,OAAO,EAAK,GAAG,IAAe,SAiCf,CADH,GAAG,IAAI,KAAA,EAAA,EAAA,SAAgB,EAAK,IAAK,GAAW,EAAE,EAAU,CAAC,CAAC,CACvD,EAAO,IAAK,GAAM,CAEnC,IAAM,EAAe,CAAC,EACtB,EAAQ,GAAa,EACrB,IAAM,EAAe,EAAK,OAEvB,GAAW,EAAE,GAAW,QAAQ,CAAC,IAAM,EAC1C,EAmBA,MAlBA,GAAQ,WAAa,EACrB,EAAQ,MAAQ,EAAa,OAC7B,GAAqB,QAAS,GAAO,CACnC,EAAQ,EAAG,QACT,EAAG,oBAAsB,UACrB,aAAA,EAAA,EAAA,SAEO,EAAa,IAAK,GAAW,EAAE,EAAG,OAAO,CAAC,EAAI,EAAa,QAAQ,QAAQ,CAAC,CACnF,EACA,EAAG,oBAAsB,MAEvB,KAAK,IAAI,GAAG,EAAa,IAAK,GAAW,EAAE,EAAG,OAAO,CAAC,EACtD,EAAG,oBAAsB,MAEvB,KAAK,IAAI,GAAG,EAAa,IAAK,GAAW,EAAE,EAAG,OAAO,CAAC,GAAA,EAAA,EAAA,SAElD,EAAa,IAAK,GAAW,EAAE,EAAG,OAAO,CAAC,CAC1D,CAAC,EACM,CACT,CACO,EA5Dc,EAAA,EAAO,EAAM,CAAS,EAAE,IAAK,GAAM,CAEpD,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SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,aACT,cAAe,CACb,CACE,GAAI,QACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,SACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,QACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,kBACT,cAAe,CACb,CACE,GAAI,QACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,kBACT,cAAe,CACb,CACE,GAAI,QACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,YACT,cAAe,CACb,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,IACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,oBACT,cAAe,CACb,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,KACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,KACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,sBACT,cAAe,CACb,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,KACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,KACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,iBACT,cAAe,CACb,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,IACJ,SAAU,GACV,SAAU,EACZ,CACF,CACF,EACA,CACE,QAAS,oBACT,cAAe,CACb,CACE,GAAI,OACJ,SAAU,GACV,SAAU,EACZ,EACA,CACE,GAAI,IACJ,S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