sea-chart 0.0.77 → 0.0.78-alpha.0

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.
@@ -8,6 +8,7 @@ import DtableSearchInput from '../dtable-search-input';
8
8
  import Loading from '../loading';
9
9
  import { searchRows } from '../../utils/search';
10
10
  import ChartDataSQL from '../../utils/sql/chart-data-sql';
11
+ import { getFilterConditions } from '../../utils/row-record-utils';
11
12
  import RowCard from '../row-card/row-card';
12
13
  import { CommonEventTypes } from '../../constants/common-constants';
13
14
  import './index.css';
@@ -31,8 +32,7 @@ class StatisticRecordDialog extends React.Component {
31
32
  } = statisticRecord || {};
32
33
  const {
33
34
  table_id,
34
- view_id,
35
- filters
35
+ view_id
36
36
  } = chart.config;
37
37
  this.table = getTableById(tables, table_id);
38
38
  if (view_id) {
@@ -44,15 +44,8 @@ class StatisticRecordDialog extends React.Component {
44
44
  if (this.isArchiveView || !isCalculateByView || statisticRecord.isQueryBySql) {
45
45
  var _context$api, _context$api2;
46
46
  if ((_context$api = context.api) === null || _context$api === void 0 ? void 0 : _context$api.customQueryRows) {
47
- const newFilters = (filters === null || filters === void 0 ? void 0 : filters.map(item => {
48
- return {
49
- ...item,
50
- column_key: (item === null || item === void 0 ? void 0 : item.column_key) || '',
51
- value: (item === null || item === void 0 ? void 0 : item.filter_term) || ''
52
- };
53
- })) || [];
54
47
  const detailFilterConditions = {
55
- filters: newFilters
48
+ filters: getFilterConditions(statisticRecord, chart, this.table.columns)
56
49
  };
57
50
  context.api.customQueryRows(detailFilterConditions).then(res => {
58
51
  const {
@@ -256,4 +256,47 @@ export const MONTH_MIRROR = {
256
256
  '10': 'Nov',
257
257
  '11': 'Dec'
258
258
  };
259
+ export const xAxisMap = {
260
+ [CHART_TYPE.BAR_CUSTOM]: 'x_axis_column_key',
261
+ [CHART_TYPE.BAR_GROUP]: 'x_axis_column_key',
262
+ [CHART_TYPE.BAR_STACK]: 'x_axis_column_key',
263
+ [CHART_TYPE.BAR]: 'x_axis_column_key',
264
+ [CHART_TYPE.AREA_GROUP]: 'x_axis_column_key',
265
+ [CHART_TYPE.AREA]: 'x_axis_column_key',
266
+ [CHART_TYPE.BASIC_NUMBER_CARD]: 'numeric_column_key',
267
+ [CHART_TYPE.COMBINATION]: 'x_axis_column_key',
268
+ [CHART_TYPE.COMPARE_BAR]: 'x_axis_column_key',
269
+ [CHART_TYPE.COMPLETENESS_GROUP]: 'groupby_column_key',
270
+ [CHART_TYPE.COMPLETENESS]: 'groupby_column_key',
271
+ [CHART_TYPE.DASHBOARD]: 'target_value_column_key',
272
+ [CHART_TYPE.HEAT_MAP]: 'time_column_key',
273
+ [CHART_TYPE.HORIZONTAL_BAR]: 'vertical_axis_column_key',
274
+ [CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'vertical_axis_column_key',
275
+ [CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'vertical_axis_column_key',
276
+ [CHART_TYPE.LINE_GROUP]: 'x_axis_column_key',
277
+ [CHART_TYPE.LINE]: 'x_axis_column_key',
278
+ [CHART_TYPE.MAP_BUBBLE]: 'geo_column_key',
279
+ [CHART_TYPE.MAP]: 'geo_column_key',
280
+ [CHART_TYPE.WORLD_MAP_BUBBLE]: 'geo_column_key',
281
+ [CHART_TYPE.WORLD_MAP]: 'geo_column_key',
282
+ [CHART_TYPE.MIRROR]: 'column_key',
283
+ [CHART_TYPE.PIE]: 'groupby_column_key',
284
+ [CHART_TYPE.RING]: 'groupby_column_key',
285
+ [CHART_TYPE.SCATTER]: 'x_axis_column_key',
286
+ [CHART_TYPE.TABLE]: 'groupby_column_key',
287
+ [CHART_TYPE.TREE_MAP]: 'groupby_column_key',
288
+ [CHART_TYPE.TREND]: 'date_column_key'
289
+ };
290
+ export const groupAxisMap = {
291
+ [CHART_TYPE.BAR_GROUP]: 'column_groupby_column_key',
292
+ [CHART_TYPE.BAR_STACK]: 'column_groupby_column_key',
293
+ [CHART_TYPE.AREA_GROUP]: 'column_groupby_column_key',
294
+ [CHART_TYPE.COMPLETENESS_GROUP]: 'column_groupby_column_key',
295
+ [CHART_TYPE.HORIZONTAL_GROUP_BAR]: 'column_groupby_column_key',
296
+ [CHART_TYPE.STACKED_HORIZONTAL_BAR]: 'column_groupby_column_key',
297
+ [CHART_TYPE.LINE_GROUP]: 'column_groupby_column_key',
298
+ [CHART_TYPE.SCATTER]: 'column_groupby_column_key',
299
+ [CHART_TYPE.MIRROR]: 'group_column_key',
300
+ [CHART_TYPE.TABLE]: 'groupby_column_key'
301
+ };
259
302
  export { GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP, CHART_KEY, GENERIC_KEY, GENERIC_KEY_2_SIMILAR_KEYS, STYLE_COLORS, HORIZONTAL_ALIGN, HORIZONTAL_ALIGNS, HORIZONTAL_ALIGN_SHOW, CHART_TYPE, CHART_TYPE_SHOW, CHART_TYPES, CHART_TYPE_IMAGE, GEOLOCATION_GRANULARITY, GEOLOCATION_GRANULARITY_LIST, MAP_LEVEL, MUNICIPALITIES, regions, TABLE_DIMENSIONS };
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import intl from '../intl';
5
- import { settingsContext, DepartmentsContext } from '../utils/contexts';
5
+ import { settingsContext } from '../utils/contexts';
6
6
  import { eventStopPropagation } from '../utils';
7
7
  import { BaseUtils } from '../utils';
8
8
  import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
@@ -18,8 +18,7 @@ const Settings = _ref => {
18
18
  hideTitleStyleSetting,
19
19
  tables,
20
20
  onChange,
21
- children,
22
- departments
21
+ children
23
22
  } = _ref;
24
23
  const [type, setType] = useState(CHART_SETTINGS_TYPE.DATA);
25
24
  const [labelColorConfigs, setLabelColorConfigs] = useState([]);
@@ -84,16 +83,12 @@ const Settings = _ref => {
84
83
  }, /*#__PURE__*/React.createElement("div", {
85
84
  id: "sea-chart-settings-content",
86
85
  className: "chart-settings-content"
87
- }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DepartmentsContext.Provider, {
88
- value: {
89
- departments
90
- }
91
- }, /*#__PURE__*/React.createElement(DataSettings, {
86
+ }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DataSettings, {
92
87
  dataSources: dataSources,
93
88
  chart: chart,
94
89
  tables: tables,
95
90
  onChange: modifyStatistic
96
- })), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
91
+ }), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
97
92
  chart: chart,
98
93
  labelColorConfigs: labelColorConfigs,
99
94
  onChange: modifyStyle
@@ -1,11 +1,10 @@
1
1
  import _DTableFiltersPopover from "dtable-ui-component/lib/DTableFiltersPopover";
2
- import React, { useCallback, useContext, useMemo, useState } from 'react';
2
+ import React, { useCallback, useMemo, useState } from 'react';
3
3
  import { Label, FormGroup } from 'reactstrap';
4
4
  import { getTableById } from 'dtable-utils';
5
5
  import { eventStopPropagation, generatorKey } from '../../../utils';
6
6
  import intl from '../../../intl';
7
7
  import context from '../../../context';
8
- import { DepartmentsContext } from '../../../utils/contexts';
9
8
  import './index.css';
10
9
  const DataFilter = _ref => {
11
10
  let {
@@ -14,9 +13,6 @@ const DataFilter = _ref => {
14
13
  onChange
15
14
  } = _ref;
16
15
  const [isFilterSetterShow, setIsFilterSetterShow] = useState(false);
17
- const {
18
- departments
19
- } = useContext(DepartmentsContext);
20
16
  const toggleFilterPopover = useCallback(event => {
21
17
  eventStopPropagation(event);
22
18
  setIsFilterSetterShow(!isFilterSetterShow);
@@ -82,7 +78,6 @@ const DataFilter = _ref => {
82
78
  filterConjunction: filterConjunction,
83
79
  columns: table.columns,
84
80
  collaborators: collaborators,
85
- departments: departments,
86
81
  hidePopover: toggleFilterPopover,
87
82
  update: updateFilters
88
83
  }))) : /*#__PURE__*/React.createElement("div", {
@@ -1,3 +1,2 @@
1
1
  import React from 'react';
2
- export const settingsContext = React.createContext('');
3
- export const DepartmentsContext = React.createContext([]);
2
+ export const settingsContext = React.createContext('');
@@ -1,7 +1,7 @@
1
1
  import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
2
2
  import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
3
3
  import React from 'react';
4
- import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber } from 'dtable-utils';
4
+ import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn } from 'dtable-utils';
5
5
  import { LinksUtils } from 'dtable-store';
6
6
  import dayjs from 'dayjs';
7
7
  import cellFormatterFactory from '../components/cell-factory/cell-formatter-factory';
@@ -10,7 +10,9 @@ import SingleSelectOption from '../components/cell-factory/SingleSelectOption';
10
10
  import { isFunction, getFileIconUrl, getImageThumbnailUrl, isArchiveViewRowData } from '../utils/common-utils';
11
11
  import Highlighter from '../components/highlighter/highlighter';
12
12
  import DigitalSignUtils from '../utils/digital-sign-utils';
13
+ import { getColumnByKey } from '../utils/column-utils';
13
14
  import context from '../context';
15
+ import { xAxisMap, groupAxisMap } from '../constants';
14
16
  export const UNSHOW_COLUMN_TYPE = [CellType.LINK, CellType.LONG_TEXT, CellType.FORMULA, CellType.LINK_FORMULA];
15
17
  export const getCellRecordWidth = column => {
16
18
  let {
@@ -479,4 +481,59 @@ const createColumnFormatter = (columnType, formatterProps) => {
479
481
  return /*#__PURE__*/React.createElement(Formatter, formatterProps);
480
482
  }
481
483
  return /*#__PURE__*/React.createElement(SimpleCellFormatter, formatterProps);
484
+ };
485
+ const filterPredicateMap = {
486
+ [CellType.TEXT]: 'is',
487
+ [CellType.NUMBER]: 'equal',
488
+ [CellType.CHECKBOX]: 'is',
489
+ [CellType.DATE]: 'is',
490
+ [CellType.CTIME]: 'is',
491
+ [CellType.MTIME]: 'is',
492
+ [CellType.SINGLE_SELECT]: 'is',
493
+ [CellType.MULTIPLE_SELECT]: 'has_all_of',
494
+ [CellType.DEPARTMENT_SINGLE_SELECT]: 'is',
495
+ [CellType.COLLABORATOR]: 'has_all_of',
496
+ [CellType.CREATOR]: 'is',
497
+ [CellType.LAST_MODIFIER]: 'is',
498
+ [CellType.AUTO_NUMBER]: 'is',
499
+ [CellType.EMAIL]: 'is',
500
+ [CellType.URL]: 'is',
501
+ [CellType.STRING]: 'is',
502
+ [CellType.BOOL]: 'is'
503
+ };
504
+ const getFilterByColumnType = (columnKey, columns, value) => {
505
+ const filter = {
506
+ column_key: columnKey || ''
507
+ };
508
+ const column = getColumnByKey(columnKey, columns);
509
+ if (isDateColumn(column) || (column === null || column === void 0 ? void 0 : column.type) === CellType.GEOLOCATION) {
510
+ filter['value'] = value;
511
+ return filter;
512
+ }
513
+ filter['filter_predicate'] = filterPredicateMap[column === null || column === void 0 ? void 0 : column.type];
514
+ filter['filter_term'] = value;
515
+ return filter;
516
+ };
517
+ export const getFilterConditions = function (statisticRecord, chart) {
518
+ let columns = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
519
+ const {
520
+ name = '',
521
+ group_name = ''
522
+ } = statisticRecord || {};
523
+ const {
524
+ config
525
+ } = chart;
526
+ const {
527
+ type
528
+ } = config;
529
+ const filters = [];
530
+ const columnKey = xAxisMap[type];
531
+ const groupColumnKey = groupAxisMap[type];
532
+ const columnFilter = getFilterByColumnType(config[columnKey], columns, name);
533
+ filters.push(columnFilter);
534
+ if (config[groupColumnKey]) {
535
+ const groupColumnFilter = getFilterByColumnType(config[groupColumnKey], columns, group_name);
536
+ filters.push(groupColumnFilter);
537
+ }
538
+ return filters;
482
539
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.77",
3
+ "version": "0.0.78-alpha.0",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",