sea-chart 0.0.89 → 0.0.90

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.
@@ -6,6 +6,11 @@ import { CHART_TYPE, CHART_TYPE_SHOW, CHART_TYPES } from './type';
6
6
  import { CHART_TYPE_IMAGE } from './type-image';
7
7
  import { regions } from './regions';
8
8
  import { TABLE_DIMENSIONS } from './table';
9
+ export const TREND_TYPES = {
10
+ UP: 'up',
11
+ DOWN: 'down',
12
+ EQUAL: 'equal'
13
+ };
9
14
  export const CHART_STYLE_COLORS = ['#5B8FF9', '#5AD8A6', '#5D7092', '#F6BD16', '#6F5EF9', '#6DC8EC', '#945FB9', '#FF9845', '#1E9493', '#FF99C3'];
10
15
  export const ONLY_NEED_NUMBER_OPTIONS_CHART_TYPE = [CHART_TYPE.COMPLETENESS, CHART_TYPE.COMPLETENESS_GROUP, CHART_TYPE.SCATTER];
11
16
  export const COMPLETENESS_GROUPBY_SUPPORTED_COLUMN_TYPE = [CellType.COLLABORATOR, CellType.TEXT, CellType.SINGLE_SELECT];
@@ -692,6 +692,22 @@ BaseUtils.sortCharts = (charts, column, sortKey) => {
692
692
  return sortDate(current, next, sortType);
693
693
  }
694
694
  case CellType.SINGLE_SELECT:
695
+ {
696
+ const {
697
+ name: currentName,
698
+ group_name: currentGroupName
699
+ } = currResult || {};
700
+ const {
701
+ name: nextName,
702
+ group_name: nextGroupName
703
+ } = nextResult || {};
704
+ const current = currentGroupName || currentName;
705
+ const next = nextGroupName || nextName;
706
+ return sortSingleSelect(current, next, {
707
+ sort_type: sortType,
708
+ option_id_index_map: optionIdIndexMap
709
+ });
710
+ }
695
711
  case CellType.MULTIPLE_SELECT:
696
712
  {
697
713
  return sortSingleSelect(current, next, {
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
2
  import quarterOfYear from 'dayjs/plugin/quarterOfYear';
3
3
  import { FORMULA_COLUMN_TYPES_MAP, isNumber, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
4
- import { CHART_SUMMARY_TYPE } from '../../../constants';
4
+ import { CHART_SUMMARY_TYPE, TREND_TYPES } from '../../../constants';
5
5
  import BaseUtils from '../base-utils';
6
6
  import { getCellValue } from '../../row-utils';
7
7
  import { getCompareDate, summaryDurationResult } from '../../trend-utils';
@@ -94,11 +94,22 @@ async function calculator(chart, value, _ref) {
94
94
  result = '--';
95
95
  previousValues = 0;
96
96
  }
97
+ let type;
98
+ if (currentValues > previousValues) {
99
+ type = TREND_TYPES.UP;
100
+ } else if (currentValues < previousValues) {
101
+ type = TREND_TYPES.DOWN;
102
+ } else if (currentValues === previousValues) {
103
+ type = TREND_TYPES.EQUAL;
104
+ }
105
+ if (currentValues === 0 && previousValues === 0) {
106
+ result = '0%';
107
+ }
97
108
  return {
98
109
  latest: currentValues,
99
110
  previous: previousValues,
100
111
  result,
101
- type: currentValues >= previousValues ? 'up' : 'down'
112
+ type
102
113
  };
103
114
  }
104
115
  export default calculator;
@@ -2,7 +2,7 @@ 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
4
  import { isObject } from 'lodash';
5
- import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS } from '../../constants';
5
+ import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS, TREND_TYPES } from '../../constants';
6
6
  import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
7
7
  import { getClientLinkDisplayString } from '../cell-format-utils';
8
8
  import context from '../../context';
@@ -60,7 +60,7 @@ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, chart) => {
60
60
  {
61
61
  if (!Array.isArray(collaborators) || collaborators.length === 0) return [];
62
62
  if (!Array.isArray(cellValue) || cellValue.length === 0) return [];
63
- return cellValue.filter(email => collaborators.find(option => option.email === email));
63
+ return cellValue;
64
64
  }
65
65
  case CellType.CREATOR:
66
66
  case CellType.LAST_MODIFIER:
@@ -1454,11 +1454,22 @@ SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
1454
1454
  result = '--';
1455
1455
  comparedValue = 0;
1456
1456
  }
1457
+ let type;
1458
+ if (compareValue > comparedValue) {
1459
+ type = TREND_TYPES.UP;
1460
+ } else if (compareValue < comparedValue) {
1461
+ type = TREND_TYPES.DOWN;
1462
+ } else if (compareValue === comparedValue) {
1463
+ type = TREND_TYPES.EQUAL;
1464
+ }
1465
+ if (compareValue === 0 && comparedValue === 0) {
1466
+ result = '0%';
1467
+ }
1457
1468
  return {
1458
1469
  latest: compareValue,
1459
1470
  previous: comparedValue,
1460
1471
  result,
1461
- type: compareValue >= comparedValue ? 'up' : 'down'
1472
+ type
1462
1473
  };
1463
1474
  };
1464
1475
  SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables, params) => {
@@ -2,7 +2,7 @@ import React, { Component } from 'react';
2
2
  import classNames from 'classnames';
3
3
  import { BaseUtils } from '../../utils';
4
4
  import intl from '../../intl';
5
- import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE, CHART_THEME_COLOR } from '../../constants';
5
+ import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE, CHART_THEME_COLOR, TREND_TYPES } from '../../constants';
6
6
  class Trend extends Component {
7
7
  constructor() {
8
8
  super(...arguments);
@@ -75,12 +75,19 @@ class Trend extends Component {
75
75
  type,
76
76
  previous
77
77
  } = data || {};
78
- let color = '#fa5757',
79
- icon = 'dtable-icon-down1';
80
- if (type === 'up') {
81
- color = '#34aa95';
78
+ let color, icon;
79
+ if (type === TREND_TYPES.UP) {
80
+ color = '#fa5757';
82
81
  icon = 'dtable-icon-up1';
83
82
  }
83
+ if (type === TREND_TYPES.DOWN) {
84
+ color = '#34aa95';
85
+ icon = 'dtable-icon-down1';
86
+ }
87
+ if (type === TREND_TYPES.EQUAL) {
88
+ color = '#666666';
89
+ icon = 'dtable-icon-narrow';
90
+ }
84
91
  if (labelFontSize <= 12) {
85
92
  return /*#__PURE__*/React.createElement("span", {
86
93
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.89",
3
+ "version": "0.0.90",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",