autoql-fe-utils 1.0.37 → 1.0.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -767,6 +767,7 @@ interface getSupportedDisplayTypesParams {
767
767
  dataLength?: number;
768
768
  pivotDataLength?: number;
769
769
  isDataLimited?: boolean;
770
+ allowNumericStringColumns?: boolean;
770
771
  }
771
772
  declare const isChartType: (type: any) => boolean;
772
773
  declare const isTableType: (type: any) => boolean;
@@ -781,7 +782,7 @@ declare const supportsRegularPivotTable: (columns: any, data?: any, dataLength?:
781
782
  declare const supportsDatePivotTable: (columns: any) => boolean;
782
783
  declare const isSingleValueResponse: (response: any) => boolean;
783
784
  declare const getUniqueYearsForColumn: (data: any, columns: any, index: any) => any;
784
- declare const getSupportedDisplayTypes: ({ response, columns, dataLength, pivotDataLength, isDataLimited, }?: getSupportedDisplayTypesParams) => string[];
785
+ declare const getSupportedDisplayTypes: ({ response, columns, dataLength, pivotDataLength, isDataLimited, allowNumericStringColumns, }?: getSupportedDisplayTypesParams) => string[];
785
786
  declare const getFirstChartDisplayType: (supportedDisplayTypes: any, fallback: any) => any;
786
787
  declare const getDefaultDisplayType: (response?: AxiosResponse, defaultToChart?: boolean, columns?: Column[], dataLength?: number, pivotDataLength?: number, preferredDisplayType?: string, isDataLimited?: boolean) => string;
787
788
  declare const hasData: (response: any) => any;
@@ -936,7 +937,7 @@ declare const formatQueryColumns: ({ columns, aggConfig, queryResponse, onTableH
936
937
  enableTableSorting?: boolean;
937
938
  dataFormatting?: DataFormatting;
938
939
  }) => Column[] | undefined;
939
- declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean) => {
940
+ declare const getStringColumnIndices: (columns: any, supportsPivot?: boolean, includeNumerics?: boolean) => {
940
941
  stringColumnIndices: any;
941
942
  stringColumnIndex: any;
942
943
  legendColumnIndex?: undefined;
@@ -14708,7 +14708,8 @@
14708
14708
  columns,
14709
14709
  dataLength,
14710
14710
  pivotDataLength,
14711
- isDataLimited: isDataLimited2
14711
+ isDataLimited: isDataLimited2,
14712
+ allowNumericStringColumns = true
14712
14713
  } = {}) => {
14713
14714
  var _a, _b, _c, _d, _e, _f, _g;
14714
14715
  try {
@@ -14731,6 +14732,11 @@
14731
14732
  if (!(rows == null ? void 0 : rows.length)) {
14732
14733
  return ["table"];
14733
14734
  }
14735
+ const { amountOfNumberColumns, amountOfStringColumns } = getColumnTypeAmounts(visibleColumns);
14736
+ if (amountOfNumberColumns === 0) {
14737
+ return ["table"];
14738
+ }
14739
+ const supportedDisplayTypes = ["table"];
14734
14740
  const numRows = dataLength != null ? dataLength : rows.length;
14735
14741
  let pivotDataHasLength = true;
14736
14742
  const pivotDataLengthProvided = pivotDataLength !== void 0 && pivotDataLength !== null;
@@ -14738,7 +14744,6 @@
14738
14744
  pivotDataHasLength = !!pivotDataLength;
14739
14745
  }
14740
14746
  if (supportsRegularPivotTable(visibleColumns, rows, numRows)) {
14741
- const supportedDisplayTypes = ["table"];
14742
14747
  if (!isDataLimited2) {
14743
14748
  supportedDisplayTypes.push("pivot_table");
14744
14749
  }
@@ -14752,11 +14757,8 @@
14752
14757
  supportedDisplayTypes.push("stacked_line", "line");
14753
14758
  }
14754
14759
  }
14755
- return supportedDisplayTypes;
14756
14760
  } else if (numRows > 1) {
14757
- const supportedDisplayTypes = ["table"];
14758
- const { amountOfNumberColumns, amountOfStringColumns } = getColumnTypeAmounts(visibleColumns);
14759
- if (amountOfNumberColumns > 0 && amountOfStringColumns > 0) {
14761
+ if (amountOfStringColumns >= 1 || allowNumericStringColumns && amountOfNumberColumns >= 2) {
14760
14762
  supportedDisplayTypes.push("column");
14761
14763
  supportedDisplayTypes.push("bar");
14762
14764
  if (hasDateColumn(visibleColumns)) {
@@ -14766,11 +14768,13 @@
14766
14768
  supportedDisplayTypes.push("pie");
14767
14769
  }
14768
14770
  }
14769
- if (amountOfNumberColumns > 0 && numRows > MIN_HISTOGRAM_SAMPLE) {
14771
+ if (numRows > MIN_HISTOGRAM_SAMPLE) {
14770
14772
  supportedDisplayTypes.push("histogram");
14771
14773
  }
14772
- if (amountOfNumberColumns > 1) {
14774
+ if (amountOfNumberColumns >= 2 && amountOfStringColumns >= 1 || amountOfNumberColumns >= 3 && allowNumericStringColumns) {
14773
14775
  supportedDisplayTypes.push("column_line");
14776
+ }
14777
+ if (amountOfNumberColumns >= 2) {
14774
14778
  supportedDisplayTypes.push("scatterplot");
14775
14779
  }
14776
14780
  if (!isDataLimited2 && supportsDatePivotTable(visibleColumns)) {
@@ -14782,9 +14786,8 @@
14782
14786
  console.debug("Date pivot not supported - there is only 1 year of data, so there would only be 1 column.");
14783
14787
  }
14784
14788
  }
14785
- return supportedDisplayTypes;
14786
14789
  }
14787
- return ["table"];
14790
+ return supportedDisplayTypes;
14788
14791
  } catch (error) {
14789
14792
  console.error(error);
14790
14793
  return ["table"];
@@ -15432,7 +15435,7 @@
15432
15435
  var DEFAULT_LEGEND_PADDING_TOP = 10;
15433
15436
  var DEFAULT_LEGEND_PADDING_BOTTOM = 10;
15434
15437
  var PATH_SMOOTHING = 0.2;
15435
- var MAX_ROWS_FOR_PIE_CHART2 = 10;
15438
+ var MAX_ROWS_FOR_PIE_CHART = 10;
15436
15439
 
15437
15440
  // src/HelperFns/dateHelpers.ts
15438
15441
  var isISODate = (str) => {
@@ -16007,8 +16010,8 @@
16007
16010
  });
16008
16011
  return formattedColumns;
16009
16012
  };
16010
- var getStringColumnIndices = (columns, supportsPivot = false) => {
16011
- var _a, _b;
16013
+ var getStringColumnIndices = (columns, supportsPivot = false, includeNumerics = false) => {
16014
+ var _a, _b, _c;
16012
16015
  if (!columns) {
16013
16016
  return void 0;
16014
16017
  }
@@ -16023,7 +16026,7 @@
16023
16026
  });
16024
16027
  } else {
16025
16028
  columns.forEach((col, index) => {
16026
- if (isColumnStringType(col) && index !== multiSeriesIndex && col.is_visible) {
16029
+ if (index !== multiSeriesIndex && col.is_visible) {
16027
16030
  stringColumnIndices.push(index);
16028
16031
  }
16029
16032
  });
@@ -16035,14 +16038,18 @@
16035
16038
  stringColumnIndex: drilldownIndex
16036
16039
  };
16037
16040
  }
16038
- let stringColumnIndex = stringColumnIndices[0];
16041
+ let stringColumnIndex = stringColumnIndices.find((index) => !isColumnNumberType(columns[index]));
16042
+ if (includeNumerics && stringColumnIndex == void 0) {
16043
+ const { numberColumnIndices, numberColumnIndices2 } = getNumberColumnIndices(columns);
16044
+ stringColumnIndex = (_a = stringColumnIndices.find(
16045
+ (index) => !numberColumnIndices.includes(index) && !numberColumnIndices2.includes(index)
16046
+ )) != null ? _a : stringColumnIndices.find((index) => !numberColumnIndices.includes(index));
16047
+ }
16039
16048
  if (supportsPivot) {
16040
- const isDateColumnGroupable = (_a = columns[dateColumnIndex]) == null ? void 0 : _a.groupable;
16041
- stringColumnIndex = isDateColumnGroupable ? dateColumnIndex : (_b = stringColumnIndices.findIndex((index) => columns[index].groupable)) != null ? _b : stringColumnIndices[1];
16049
+ const isDateColumnGroupable = (_b = columns[dateColumnIndex]) == null ? void 0 : _b.groupable;
16050
+ stringColumnIndex = isDateColumnGroupable ? dateColumnIndex : (_c = stringColumnIndices.findIndex((index) => columns[index].groupable)) != null ? _c : stringColumnIndex;
16042
16051
  } else if (dateColumnIndex >= 0) {
16043
16052
  stringColumnIndex = dateColumnIndex;
16044
- } else if (stringColumnIndices[1] >= 0) {
16045
- stringColumnIndex = stringColumnIndices[1];
16046
16053
  }
16047
16054
  const legendColumnIndex = stringColumnIndices.find((i) => i !== stringColumnIndex);
16048
16055
  return { stringColumnIndex, stringColumnIndices, legendColumnIndex };