sea-chart 1.1.111 → 1.1.112-alpha.2

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.
@@ -28,9 +28,15 @@ async function calculator(chart, dtableValue, _ref) {
28
28
  numberList.push(cellValue);
29
29
  }
30
30
  });
31
+ let value;
31
32
  if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
32
- return statRows.length;
33
+ value = statRows.length;
34
+ } else {
35
+ value = BaseUtils.getSummaryResult(numberList, summary_method);
33
36
  }
34
- return BaseUtils.getSummaryResult(numberList, summary_method);
37
+ return {
38
+ value,
39
+ rows: statRows
40
+ };
35
41
  }
36
42
  export default calculator;
@@ -24,6 +24,7 @@ async function calculator(chart, value, _ref) {
24
24
  const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
25
25
  const selectedColumn = getTableColumnByKey(selectedTable, date_column_key);
26
26
  const resultMap = new Map();
27
+ const rowsMap = new Map(); // Store rows for each time period
27
28
  let formulaRows = {};
28
29
  const rows = await getViewRows(selectedView, selectedTable);
29
30
  const numericColumn = getTableColumnByKey(selectedTable, summary_column_key);
@@ -40,6 +41,10 @@ async function calculator(chart, value, _ref) {
40
41
  const dateValue = row[selectedColumn.key];
41
42
  const label = BaseUtils.getGroupLabel(dateValue, {}, selectedColumn, granularity, '', value);
42
43
  if (dateValue) {
44
+ // Store rows for each time period
45
+ const currentRows = rowsMap.get(label) || [];
46
+ currentRows.push(row);
47
+ rowsMap.set(label, currentRows);
43
48
  if (summary_type === CHART_SUMMARY_TYPE.COUNT) {
44
49
  const currentCount = resultMap.get(label) || 0;
45
50
  resultMap.set(label, currentCount + 1);
@@ -54,7 +59,7 @@ async function calculator(chart, value, _ref) {
54
59
  }
55
60
  }
56
61
  });
57
- let currentValues, previousValues;
62
+ let currentValues, previousValues, currentPeriodRows;
58
63
  if (date_granularity === 'days_30' || date_granularity === 'days_7') {
59
64
  const {
60
65
  compareValue: value1,
@@ -62,6 +67,20 @@ async function calculator(chart, value, _ref) {
62
67
  } = summaryDurationResult(resultMap, date_granularity, summary_type, summary_method, false);
63
68
  currentValues = value1;
64
69
  previousValues = value2;
70
+ // Collect rows for the current period (last 7 or 30 days)
71
+ currentPeriodRows = [];
72
+ const currentTime = dayjs();
73
+ const days = date_granularity === 'days_30' ? 30 : 7;
74
+ const formattedEndDate = currentTime.format('YYYY-MM-DD');
75
+ const formattedMiddleDate = currentTime.subtract(days, 'days').format('YYYY-MM-DD');
76
+ const endDate = dayjs(formattedEndDate);
77
+ const middleDate = dayjs(formattedMiddleDate);
78
+ rowsMap.forEach((periodRows, label) => {
79
+ const key = dayjs(label);
80
+ if (key.isValid() && key >= middleDate && key < endDate) {
81
+ currentPeriodRows = currentPeriodRows.concat(periodRows);
82
+ }
83
+ });
65
84
  } else {
66
85
  const {
67
86
  compareDate,
@@ -69,6 +88,7 @@ async function calculator(chart, value, _ref) {
69
88
  } = getCompareDate(date_granularity);
70
89
  currentValues = resultMap.get(compareDate);
71
90
  previousValues = resultMap.get(comparedDate);
91
+ currentPeriodRows = rowsMap.get(compareDate) || [];
72
92
  if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
73
93
  if (currentValues) {
74
94
  currentValues = BaseUtils.getSummaryResult(currentValues, summary_method);
@@ -109,7 +129,8 @@ async function calculator(chart, value, _ref) {
109
129
  latest: currentValues,
110
130
  previous: previousValues,
111
131
  result,
112
- type
132
+ type,
133
+ rows: currentPeriodRows
113
134
  };
114
135
  }
115
136
  export default calculator;
@@ -1806,7 +1806,7 @@ SQLStatisticsUtils.scatterSQLResult2JavaScript = async (chart, sqlRows, chartSQL
1806
1806
  summaryColumn
1807
1807
  } = columnMap;
1808
1808
  // format sql rows
1809
- const originalSqlRows = cloneDeep(sqlRows);
1809
+ const originalSqlRows = deepCopy(sqlRows);
1810
1810
  const isScatter = true;
1811
1811
  await BaseUtils.updateTableViewList(sqlRows, groupbyColumn, groupbyColumn.key, 'color', isScatter, true);
1812
1812
  await BaseUtils.updateTableViewList(sqlRows, summaryColumn, summaryColumn.key, 'color', isScatter, true);
@@ -29,7 +29,7 @@ export function getCompareDate(dateGranularity) {
29
29
  {
30
30
  var _dayOfWeekMap$firstDa;
31
31
  const firstDayOfWeek = getFirstDayOfWeekForGroupby('app');
32
- const startDayIndex = (_dayOfWeekMap$firstDa = dayOfWeekMap[firstDayOfWeek]) !== null && _dayOfWeekMap$firstDa !== void 0 ? _dayOfWeekMap$firstDa : 6; // default to Saturday
32
+ const startDayIndex = (_dayOfWeekMap$firstDa = dayOfWeekMap[firstDayOfWeek]) !== null && _dayOfWeekMap$firstDa !== void 0 ? _dayOfWeekMap$firstDa : 0; // default to Sunday
33
33
  const currentWeek = dayjs().day(startDayIndex);
34
34
  const compareDate = dayjs(currentWeek).subtract(1, 'weeks').format('YYYY-MM-DD');
35
35
  const comparedDate = dayjs(currentWeek).subtract(2, 'weeks').format('YYYY-MM-DD');
@@ -24,6 +24,24 @@ class BasicNumericCard extends Component {
24
24
  });
25
25
  }
26
26
  };
27
+ this.handleClickNumber = () => {
28
+ const {
29
+ toggleRecords,
30
+ result
31
+ } = this.props;
32
+ if (!toggleRecords) return;
33
+ if (typeof result === 'object' && result !== null && result.rows) {
34
+ // isCalculateByView = true: use rows of base
35
+ toggleRecords({
36
+ rows: result.rows
37
+ });
38
+ } else {
39
+ // isCalculateByView = false: use rows of sql query
40
+ toggleRecords({
41
+ isQueryBySql: true
42
+ });
43
+ }
44
+ };
27
45
  this.formatData = data => {
28
46
  if (!data && data !== 0) return intl.get(EMPTY_NAME);
29
47
  const {
@@ -98,11 +116,12 @@ class BasicNumericCard extends Component {
98
116
  label_text_align,
99
117
  label_font_weight
100
118
  } = config;
119
+ const numericValue = typeof result === 'object' && result !== null ? result.value : result;
101
120
  let content = null;
102
121
  if (summary_method === 'Distinct_values') {
103
- content = isNumber(result) ? result : 0;
122
+ content = isNumber(numericValue) ? numericValue : 0;
104
123
  } else {
105
- content = this.formatData(result);
124
+ content = this.formatData(numericValue);
106
125
  }
107
126
  return /*#__PURE__*/React.createElement("div", {
108
127
  className: "sea-chart-container plugin-number-card"
@@ -114,6 +133,7 @@ class BasicNumericCard extends Component {
114
133
  position: 'relative'
115
134
  }
116
135
  }, /*#__PURE__*/React.createElement("p", {
136
+ onClick: this.handleClickNumber,
117
137
  style: {
118
138
  position: 'absolute',
119
139
  width: '100%',
@@ -123,7 +143,8 @@ class BasicNumericCard extends Component {
123
143
  margin: '-8px 0 2px 0',
124
144
  textAlign: `${text_align}`,
125
145
  fontWeight: `${font_weight}`,
126
- color: `${font_color}`
146
+ color: `${font_color}`,
147
+ cursor: 'pointer'
127
148
  }
128
149
  }, content), /*#__PURE__*/React.createElement("p", {
129
150
  ref: ref => this.labelRef = ref,
@@ -6,6 +6,24 @@ import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE, C
6
6
  class Trend extends Component {
7
7
  constructor() {
8
8
  super(...arguments);
9
+ this.handleClickNumber = () => {
10
+ const {
11
+ toggleRecords,
12
+ result
13
+ } = this.props;
14
+ if (!toggleRecords) return;
15
+ if (typeof result === 'object' && result !== null && result.rows) {
16
+ // isCalculateByView = true: use rows of current period
17
+ toggleRecords({
18
+ rows: result.rows
19
+ });
20
+ } else {
21
+ // isCalculateByView = false: use rows of sql query
22
+ toggleRecords({
23
+ isQueryBySql: true
24
+ });
25
+ }
26
+ };
9
27
  this.formatData = data => {
10
28
  if (!data && data !== 0) return intl.get(EMPTY_NAME);
11
29
  const {
@@ -194,6 +212,7 @@ class Trend extends Component {
194
212
  position: 'relative'
195
213
  }
196
214
  }, /*#__PURE__*/React.createElement("p", {
215
+ onClick: this.handleClickNumber,
197
216
  style: {
198
217
  position: 'absolute',
199
218
  width: '100%',
@@ -203,7 +222,8 @@ class Trend extends Component {
203
222
  margin: '-8px 0 2px 0',
204
223
  textAlign: `${num_text_align}`,
205
224
  fontWeight: `${num_font_weight}`,
206
- color: `${num_font_color}`
225
+ color: `${num_font_color}`,
226
+ cursor: 'pointer'
207
227
  }
208
228
  }, content), /*#__PURE__*/React.createElement("p", {
209
229
  className: "label-content",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.111",
3
+ "version": "1.1.112-alpha.2",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",
@@ -101,6 +101,7 @@
101
101
  "dotenv": "6.2.0",
102
102
  "dotenv-expand": "5.1.0",
103
103
  "dtable-store": "~6.0.11",
104
+ "dtable-ui-component": "6.0.102",
104
105
  "ejs": "3.1.10",
105
106
  "eslint": "^6.8.0",
106
107
  "eslint-config-react-app": "^5.0.2",