sea-chart 1.1.112-alpha.2 → 1.1.112-oad2.1

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.
@@ -32,11 +32,11 @@ function getMapJsonQueryUrl(mapLevel, mapLocation) {
32
32
  switch (mapLevel) {
33
33
  case MAP_LEVEL.WORLD:
34
34
  {
35
- return 'world';
35
+ return 'world-old-version';
36
36
  }
37
37
  case MAP_LEVEL.COUNTRY:
38
38
  {
39
- return 'china';
39
+ return 'china-old-version';
40
40
  }
41
41
  case MAP_LEVEL.PROVINCE:
42
42
  {
@@ -9,7 +9,7 @@ import OriginalDataUtils from './original-data-utils';
9
9
  class ChartUtils {}
10
10
  ChartUtils.calculateChart = async (chart, value, callback) => {
11
11
  if (!BaseUtils.isValidExistChart(value.tables, chart)) {
12
- const tip_message = 'Please_complete_the_chart_configuration_first';
12
+ const tip_message = 'Please_complete_the_chart_configuration_first11111';
13
13
  return callback && callback('', tip_message, null);
14
14
  }
15
15
  const id = uniqueId();
@@ -49,7 +49,7 @@ ChartUtils.calculateChart = async (chart, value, callback) => {
49
49
  };
50
50
  ChartUtils.calculateStaticChart = (chart, value, statisticalResult, callback) => {
51
51
  if (!BaseUtils.isValidExistChart(value.tables, chart)) {
52
- const tip_message = 'Please_complete_the_chart_configuration_first';
52
+ const tip_message = 'Please_complete_the_chart_configuration_first22222';
53
53
  return callback && callback('', tip_message, null);
54
54
  }
55
55
  if (!statisticalResult) {
@@ -52,7 +52,7 @@ OriginalDataUtils.isValidExistChart = (tables, chart) => {
52
52
  };
53
53
  OriginalDataUtils.calculateChart = async (chart, value, callback, refreshCache) => {
54
54
  if (!_OriginalDataUtils.isValidExistChart((value === null || value === void 0 ? void 0 : value.tables) || [], chart)) {
55
- const tip_message = 'Please_complete_the_chart_configuration_first';
55
+ const tip_message = 'Please_complete_the_chart_configuration_first44444';
56
56
  return callback && callback('', tip_message, null);
57
57
  }
58
58
  try {
@@ -1,6 +1,6 @@
1
1
  var _SQLStatisticsUtils;
2
2
  import dayjs from 'dayjs';
3
- import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
3
+ import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber } from 'dtable-utils';
4
4
  import { isObject } from 'lodash';
5
5
  import deepCopy from 'deep-copy';
6
6
  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';
@@ -16,7 +16,6 @@ class SQLStatisticsUtils {}
16
16
  _SQLStatisticsUtils = SQLStatisticsUtils;
17
17
  SQLStatisticsUtils.DATA_SOURCE = 'sql_statistics';
18
18
  SQLStatisticsUtils.getGroupLabelFromDB = async (cellValue, column, chart, isPivot) => {
19
- const dateGranularity = BaseUtils.getDateGranularityByType(chart);
20
19
  const {
21
20
  type,
22
21
  data
@@ -1316,6 +1315,69 @@ SQLStatisticsUtils.groupingTwoDimensionChartSQLResult2JavaScript = async (chart,
1316
1315
  }
1317
1316
  }
1318
1317
  }
1318
+
1319
+ // fill empty group name with value 0
1320
+ const allGroupNames = new Set();
1321
+ const nameGroupMap = new Map();
1322
+ result.forEach(item => {
1323
+ const {
1324
+ name,
1325
+ group_name: groupName
1326
+ } = item;
1327
+ allGroupNames.add(groupName);
1328
+ if (!nameGroupMap.has(name)) {
1329
+ nameGroupMap.set(name, new Set());
1330
+ }
1331
+ nameGroupMap.get(name).add(groupName);
1332
+ });
1333
+ const isEmptyGroupName = groupName => groupName === undefined || groupName === null || groupName === '';
1334
+ const groupNameList = Array.from(allGroupNames).sort((a, b) => {
1335
+ const aEmpty = isEmptyGroupName(a);
1336
+ const bEmpty = isEmptyGroupName(b);
1337
+ if (aEmpty && !bEmpty) return 1;
1338
+ if (!aEmpty && bEmpty) return -1;
1339
+ return `${a !== null && a !== void 0 ? a : ''}`.localeCompare(`${b !== null && b !== void 0 ? b : ''}`);
1340
+ });
1341
+ nameGroupMap.forEach((groupSet, name) => {
1342
+ groupNameList.forEach(groupName => {
1343
+ if (!groupSet.has(groupName)) {
1344
+ result.push({
1345
+ name,
1346
+ rows: [],
1347
+ group_name: groupName,
1348
+ value: 0
1349
+ });
1350
+ }
1351
+ });
1352
+ });
1353
+
1354
+ // ensure each name keeps original order while its group_name entries follow the normalized group order
1355
+ const groupOrder = new Map(groupNameList.map((groupName, index) => [groupName, index]));
1356
+ const nameOrder = [];
1357
+ const seenNames = new Set();
1358
+ const nameBuckets = new Map();
1359
+ result.forEach(item => {
1360
+ if (!seenNames.has(item.name)) {
1361
+ seenNames.add(item.name);
1362
+ nameOrder.push(item.name);
1363
+ }
1364
+ if (!nameBuckets.has(item.name)) {
1365
+ nameBuckets.set(item.name, []);
1366
+ }
1367
+ nameBuckets.get(item.name).push(item);
1368
+ });
1369
+ const orderedResult = [];
1370
+ nameOrder.forEach(name => {
1371
+ const items = nameBuckets.get(name).sort((a, b) => {
1372
+ var _a$group_name, _b$group_name;
1373
+ const aOrder = groupOrder.has(a.group_name) ? groupOrder.get(a.group_name) : Number.MAX_SAFE_INTEGER;
1374
+ const bOrder = groupOrder.has(b.group_name) ? groupOrder.get(b.group_name) : Number.MAX_SAFE_INTEGER;
1375
+ if (aOrder !== bOrder) return aOrder - bOrder;
1376
+ return `${(_a$group_name = a.group_name) !== null && _a$group_name !== void 0 ? _a$group_name : ''}`.localeCompare(`${(_b$group_name = b.group_name) !== null && _b$group_name !== void 0 ? _b$group_name : ''}`);
1377
+ });
1378
+ orderedResult.push(...items);
1379
+ });
1380
+ result.splice(0, result.length, ...orderedResult);
1319
1381
  BaseUtils.sortCharts(result, groupbyColumn, 'name');
1320
1382
  await BaseUtils.updateTableViewList(result, groupbyColumn, 'name', 'color', false, true);
1321
1383
  await BaseUtils.updateTableViewList(result, columnGroupbyColumn, 'group_name', 'group_color', false, false);
@@ -1967,7 +2029,7 @@ SQLStatisticsUtils.calculateChart = async (chart, value, callback, sqlRows) => {
1967
2029
  tables
1968
2030
  } = value;
1969
2031
  if (!BaseUtils.isValidExistChart(tables, chart)) {
1970
- const tip_message = 'Please_complete_the_chart_configuration_first';
2032
+ const tip_message = 'Please_complete_the_chart_configuration_first33333';
1971
2033
  return callback && callback('', tip_message, null);
1972
2034
  }
1973
2035
  const {
@@ -502,7 +502,8 @@ const filterPredicateMap = {
502
502
  [CellType.URL]: 'is',
503
503
  [CellType.STRING]: 'is',
504
504
  [CellType.BOOL]: 'is',
505
- [CellType.LINK_FORMULA]: 'has_any_of'
505
+ [CellType.LINK_FORMULA]: 'is',
506
+ [CellType.LINK]: 'is'
506
507
  };
507
508
  const USE_OPTION_ID_CELL_TYPES = [CellType.SINGLE_SELECT, CellType.MULTIPLE_SELECT];
508
509
  const getFilterByColumnTypeForPivot = (columnKey, columns, value, rows) => {
@@ -516,11 +517,28 @@ const getFilterByColumnTypeForPivot = (columnKey, columns, value, rows) => {
516
517
  }
517
518
  let type = column.type;
518
519
  const columnType = column.type;
519
- if (type === CellType.FORMULA) {
520
+ if (columnType === CellType.FORMULA) {
520
521
  type = column.data.result_type;
521
522
  }
522
- if (type === CellType.LINK_FORMULA) {
523
+ if (columnType === CellType.LINK_FORMULA) {
523
524
  type = column.data.array_type;
525
+ // extract display_value from link formula column value
526
+ if (Array.isArray(value) && value.length > 0) {
527
+ value = value[0];
528
+ }
529
+ }
530
+
531
+ // handle link column based on array_type
532
+ if (columnType === CellType.LINK) {
533
+ var _column$data, _value$;
534
+ const arrayType = (_column$data = column.data) === null || _column$data === void 0 ? void 0 : _column$data.array_type;
535
+ if (arrayType) {
536
+ type = arrayType;
537
+ }
538
+ // extract display_value from link column value
539
+ if (Array.isArray(value) && value.length > 0 && ((_value$ = value[0]) === null || _value$ === void 0 ? void 0 : _value$.display_value) !== undefined) {
540
+ value = value[0].display_value;
541
+ }
524
542
  }
525
543
  if (column && [CellType.GEOLOCATION, CellType.DATE, CellType.MTIME, CellType.CTIME].includes(type)) {
526
544
  filter['value'] = value;
@@ -540,8 +558,8 @@ const getFilterByColumnTypeForPivot = (columnKey, columns, value, rows) => {
540
558
  filter['filter_term'] = value;
541
559
  }
542
560
 
543
- // link_formula use has_any_of
544
- if (columnType === CellType.LINK_FORMULA) {
561
+ // link_formula and link use is
562
+ if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
545
563
  filter['filter_predicate'] = filterPredicateMap[columnType];
546
564
  } else {
547
565
  filter['filter_predicate'] = filterPredicateMap[type];
@@ -566,11 +584,28 @@ const getFilterByColumnType = (columnKey, columns, rows, sqlColumnKey) => {
566
584
  let columnType = column.type;
567
585
  const correctRow = rows.find(r => sqlColumnKey in r);
568
586
  value = correctRow && correctRow[sqlColumnKey];
569
- if (type === CellType.FORMULA) {
587
+ if (columnType === CellType.FORMULA) {
570
588
  type = column.data.result_type;
571
589
  }
572
- if (type === CellType.LINK_FORMULA) {
590
+ if (columnType === CellType.LINK_FORMULA) {
573
591
  type = column.data.array_type;
592
+ // extract display_value from link formula column value
593
+ if (Array.isArray(value) && value.length > 0) {
594
+ value = value[0];
595
+ }
596
+ }
597
+
598
+ // handle link column based on array_type
599
+ if (columnType === CellType.LINK) {
600
+ var _column$data2, _value$2;
601
+ const arrayType = (_column$data2 = column.data) === null || _column$data2 === void 0 ? void 0 : _column$data2.array_type;
602
+ if (arrayType) {
603
+ type = arrayType;
604
+ }
605
+ // extract display_value from link column value
606
+ if (Array.isArray(value) && value.length > 0 && ((_value$2 = value[0]) === null || _value$2 === void 0 ? void 0 : _value$2.display_value) !== undefined) {
607
+ value = value[0].display_value;
608
+ }
574
609
  }
575
610
  if (column && [CellType.GEOLOCATION, CellType.DATE, CellType.MTIME, CellType.CTIME].includes(type)) {
576
611
  // link_formula result is an array, but can't pass the value directly as an array here
@@ -585,8 +620,8 @@ const getFilterByColumnType = (columnKey, columns, rows, sqlColumnKey) => {
585
620
  }
586
621
  filter['filter_term'] = value;
587
622
 
588
- // link_formula use has_any_of
589
- if (columnType === CellType.LINK_FORMULA) {
623
+ // link_formula and link use is
624
+ if ([CellType.LINK_FORMULA, CellType.LINK].includes(columnType)) {
590
625
  filter['filter_predicate'] = filterPredicateMap[columnType];
591
626
  } else {
592
627
  filter['filter_predicate'] = filterPredicateMap[type];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.112-alpha.2",
3
+ "version": "1.1.112oad2.1",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",