sea-chart 1.1.67 → 1.1.69

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.
@@ -1,5 +1,5 @@
1
1
  import { CellType } from 'dtable-utils';
2
- import { cloneDeep } from 'lodash-es';
2
+ import { cloneDeep } from 'lodash';
3
3
  import { CHART_SUMMARY_TYPE, CHART_TYPE, FUNNEL_LABEL_FORMAT, FUNNEL_LABEL_POSITIONS } from '../constants';
4
4
  import BaseModel from './base-model';
5
5
  class Funnel extends BaseModel {
@@ -2,7 +2,7 @@ import _DTableSelect from "dtable-ui-component/lib/DTableSelect";
2
2
  import { COLUMNS_ICON_CONFIG } from 'dtable-utils';
3
3
  import React, { useCallback, useMemo } from 'react';
4
4
  import { FormGroup, Label } from 'reactstrap';
5
- import { cloneDeep } from 'lodash-es';
5
+ import { cloneDeep } from 'lodash';
6
6
  import intl from '../../../intl';
7
7
  import DndList from './dnd-list';
8
8
  export default function FunnelLayerSetting(_ref) {
@@ -1,4 +1,4 @@
1
- import { uniqueId } from 'lodash-es';
1
+ import { uniqueId } from 'lodash';
2
2
  import context from '../../context';
3
3
  import { getErrorMessage } from '..';
4
4
  import intl from '../../intl';
@@ -1,8 +1,7 @@
1
1
  var _SQLStatisticsUtils;
2
2
  import dayjs from 'dayjs';
3
3
  import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
4
- import { isObject } from 'lodash';
5
- import { cloneDeep } from 'lodash-es';
4
+ import { isObject, cloneDeep } from 'lodash';
6
5
  import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES, CHART_STYLE_COLORS, MAP_CHART_TYPES } from '../../constants';
7
6
  import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
8
7
  import { getClientLinkDisplayString } from '../cell-format-utils';
@@ -883,6 +882,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = async (chart, sqlRows, chartSQL
883
882
  const comparedEndDate = new Date(x_axis_compared_date_range_end);
884
883
  for (const item of sqlRows) {
885
884
  let name = item[sqlGroupbyColumnKey];
885
+ if (!name) continue;
886
886
  const label = await _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, chart.config);
887
887
  if (x_axis_date_granularity === 'quarter') {
888
888
  name = convertQuarterToDate(name);
@@ -898,42 +898,65 @@ SQLStatisticsUtils.compareSQLResult2Javascript = async (chart, sqlRows, chartSQL
898
898
  const currentValue = dateRangeResult.get(label);
899
899
  if (!currentValue) {
900
900
  if (isAdvanced) {
901
- dateRangeResult.set(label, [value]);
901
+ dateRangeResult.set(label, {
902
+ value: [value],
903
+ date: name,
904
+ rows: [item]
905
+ });
902
906
  } else {
903
- dateRangeResult.set(label, value);
907
+ dateRangeResult.set(label, {
908
+ value,
909
+ date: name,
910
+ rows: [item]
911
+ });
904
912
  }
905
913
  } else {
906
914
  if (isAdvanced) {
907
- currentValue.push(value);
915
+ currentValue.value.push(value);
916
+ currentValue.rows.push(item);
908
917
  } else {
909
- dateRangeResult.set(label, value + currentValue);
918
+ currentValue.value = value + currentValue.value;
919
+ currentValue.rows.push(item);
910
920
  }
911
921
  }
912
922
  } else if (name >= comparedStartDate && name <= comparedEndDate) {
913
923
  const currentValue = dateComparedResult.get(label);
914
924
  if (!currentValue) {
915
925
  if (isAdvanced) {
916
- dateComparedResult.set(label, [value]);
926
+ dateComparedResult.set(label, {
927
+ value: [value],
928
+ date: name,
929
+ rows: [item]
930
+ });
917
931
  } else {
918
- dateComparedResult.set(label, value);
932
+ dateComparedResult.set(label, {
933
+ value,
934
+ date: name,
935
+ rows: [item]
936
+ });
919
937
  }
920
938
  } else {
921
939
  if (isAdvanced) {
922
- dateComparedResult.push(value);
940
+ currentValue.value.push(value);
941
+ currentValue.rows.push(item);
923
942
  } else {
924
- dateComparedResult.set(label, value + currentValue);
943
+ currentValue.value = value + currentValue.value;
944
+ currentValue.rows.push(item);
925
945
  }
926
946
  }
927
947
  }
928
948
  }
929
949
  let comparedResult = [];
930
950
  let rangeResult = [];
951
+ let sortedDateRange = Array.from(dateRangeResult.entries()).sort((a, b) => a[1].date - b[1].date);
952
+ let sortedDateCompared = Array.from(dateComparedResult.entries()).sort((a, b) => a[1].date - b[1].date);
931
953
  const data = (summaryColumn === null || summaryColumn === void 0 ? void 0 : summaryColumn.data) || {};
932
- for (let item of dateRangeResult) {
933
- let value = item[1];
954
+ for (let item of sortedDateRange) {
955
+ let value = item[1].value;
956
+ const rows = item[1].rows;
934
957
  let formatted_value = value;
935
958
  if (isAdvanced) {
936
- value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
959
+ value = getSummaryResult(item[1].value, y_axis_summary_method, data.precision);
937
960
  formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
938
961
  }
939
962
  rangeResult.push({
@@ -941,19 +964,21 @@ SQLStatisticsUtils.compareSQLResult2Javascript = async (chart, sqlRows, chartSQL
941
964
  group_name: groupName1,
942
965
  raw_name: item[0],
943
966
  value,
967
+ rows,
944
968
  formatted_value
945
969
  });
946
970
  }
947
971
  let index = 0;
948
- for (let item of dateComparedResult) {
972
+ for (let item of sortedDateCompared) {
949
973
  let dateRangeItem = rangeResult[index];
950
974
  if (!dateRangeItem) {
951
975
  break;
952
976
  }
953
- let value = item[1];
977
+ let value = item[1].value;
978
+ const rows = item[1].rows;
954
979
  let formatted_value = value;
955
980
  if (isAdvanced) {
956
- value = getSummaryResult(item[1], y_axis_summary_method, data.precision);
981
+ value = getSummaryResult(item[1].value, y_axis_summary_method, data.precision);
957
982
  formatted_value = getFormattedValue(value, summaryColumn, y_axis_summary_method);
958
983
  }
959
984
  const newItem = {
@@ -961,6 +986,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = async (chart, sqlRows, chartSQL
961
986
  group_name: groupName2,
962
987
  raw_name: item[0],
963
988
  value,
989
+ rows,
964
990
  formatted_value
965
991
  };
966
992
  if (display_increase) {
@@ -979,6 +1005,8 @@ SQLStatisticsUtils.compareSQLResult2Javascript = async (chart, sqlRows, chartSQL
979
1005
  }
980
1006
  BaseUtils.updateSummaryValuePrecision(comparedResult, summaryColumn, 'value');
981
1007
  BaseUtils.updateSummaryValuePrecision(rangeResult, summaryColumn, 'value');
1008
+ BaseUtils.sortCharts(rangeResult, groupbyColumn, 'name');
1009
+ BaseUtils.sortCharts(comparedResult, groupbyColumn, 'name');
982
1010
  return [...comparedResult, ...rangeResult];
983
1011
  };
984
1012
  SQLStatisticsUtils.combinationSQLResult2Javascript = async (chart, sqlRows, chartSQLMap, columnMap, tables) => {
@@ -1,4 +1,4 @@
1
- import { cloneDeep } from 'lodash-es';
1
+ import { cloneDeep } from 'lodash';
2
2
  import { GENERIC_KEY_2_SIMILAR_KEYS, GEOLOCATION_GRANULARITY, MAP_LEVEL, MUNICIPALITIES, regions } from '../constants';
3
3
  import intl from '../intl';
4
4
  import { SERVER_ERROR_DISPLAY_KEY, SERVER_ERROR_MSG } from '../constants/error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.67",
3
+ "version": "1.1.69",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",