sea-chart 0.0.74-alpha.1 → 0.0.74-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.
@@ -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 } from '../utils/contexts';
5
+ import { settingsContext, DepartmentsContext } 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,7 +18,8 @@ const Settings = _ref => {
18
18
  hideTitleStyleSetting,
19
19
  tables,
20
20
  onChange,
21
- children
21
+ children,
22
+ departments
22
23
  } = _ref;
23
24
  const [type, setType] = useState(CHART_SETTINGS_TYPE.DATA);
24
25
  const [labelColorConfigs, setLabelColorConfigs] = useState([]);
@@ -83,12 +84,16 @@ const Settings = _ref => {
83
84
  }, /*#__PURE__*/React.createElement("div", {
84
85
  id: "sea-chart-settings-content",
85
86
  className: "chart-settings-content"
86
- }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DataSettings, {
87
+ }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DepartmentsContext.Provider, {
88
+ value: {
89
+ departments
90
+ }
91
+ }, /*#__PURE__*/React.createElement(DataSettings, {
87
92
  dataSources: dataSources,
88
93
  chart: chart,
89
94
  tables: tables,
90
95
  onChange: modifyStatistic
91
- }), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
96
+ })), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
92
97
  chart: chart,
93
98
  labelColorConfigs: labelColorConfigs,
94
99
  onChange: modifyStyle
@@ -1,10 +1,11 @@
1
1
  import _DTableFiltersPopover from "dtable-ui-component/lib/DTableFiltersPopover";
2
- import React, { useCallback, useMemo, useState } from 'react';
2
+ import React, { useCallback, useContext, 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';
8
9
  import './index.css';
9
10
  const DataFilter = _ref => {
10
11
  let {
@@ -13,6 +14,9 @@ const DataFilter = _ref => {
13
14
  onChange
14
15
  } = _ref;
15
16
  const [isFilterSetterShow, setIsFilterSetterShow] = useState(false);
17
+ const {
18
+ departments
19
+ } = useContext(DepartmentsContext);
16
20
  const toggleFilterPopover = useCallback(event => {
17
21
  eventStopPropagation(event);
18
22
  setIsFilterSetterShow(!isFilterSetterShow);
@@ -78,6 +82,7 @@ const DataFilter = _ref => {
78
82
  filterConjunction: filterConjunction,
79
83
  columns: table.columns,
80
84
  collaborators: collaborators,
85
+ departments: departments,
81
86
  hidePopover: toggleFilterPopover,
82
87
  update: updateFilters
83
88
  }))) : /*#__PURE__*/React.createElement("div", {
@@ -73,36 +73,27 @@ async function calculator(chart, value, _ref) {
73
73
  targetValue,
74
74
  rows
75
75
  } = labelCountMap[label];
76
- let completedRate;
77
- if (!targetValue && targetValue) {
78
- completedRate = 100;
79
- } else if (!targetValue && !targetValue) {
80
- completedRate = 'empty';
81
- } else {
82
- completedRate = (targetValue / targetValue * 100).toFixed(0);
83
- }
84
76
  if (currentValue < targetValue) {
85
77
  result.unshift({
86
78
  name: label,
87
79
  value: currentValue,
88
- group_name: 'completed',
80
+ type: 'completed',
89
81
  current_value: currentValue,
90
82
  target_value: targetValue,
91
83
  rows
92
84
  }, {
93
85
  name: label,
94
86
  value: targetValue - currentValue,
95
- group_name: 'rest',
87
+ type: 'uncompleted',
96
88
  current_value: currentValue,
97
89
  target_value: targetValue,
98
- rows,
99
- completedRate
90
+ rows
100
91
  });
101
92
  } else {
102
93
  result.unshift({
103
94
  name: label,
104
95
  value: currentValue,
105
- group_name: 'completed',
96
+ type: 'completed',
106
97
  current_value: currentValue,
107
98
  target_value: targetValue,
108
99
  rows
@@ -181,21 +172,13 @@ async function calculator(chart, value, _ref) {
181
172
  targetValue,
182
173
  rows
183
174
  } = labelCountMap[key];
184
- let completedRate;
185
- if (!targetValue && targetValue) {
186
- completedRate = 100;
187
- } else if (!targetValue && !targetValue) {
188
- completedRate = 'empty';
189
- } else {
190
- completedRate = (targetValue / targetValue * 100).toFixed(0);
191
- }
192
175
  if (currentValue < targetValue) {
193
176
  result.unshift({
194
177
  name: label,
195
178
  groupby: groupLabel,
196
179
  value: currentValue,
197
180
  color,
198
- group_name: 'completed',
181
+ type: 'completed',
199
182
  current_value: currentValue,
200
183
  target_value: targetValue,
201
184
  rows
@@ -204,11 +187,10 @@ async function calculator(chart, value, _ref) {
204
187
  groupby: groupLabel,
205
188
  value: targetValue - currentValue,
206
189
  color,
207
- group_name: 'rest',
190
+ type: 'uncompleted',
208
191
  current_value: currentValue,
209
192
  target_value: targetValue,
210
- rows,
211
- completedRate
193
+ rows
212
194
  });
213
195
  } else {
214
196
  result.unshift({
@@ -216,7 +198,7 @@ async function calculator(chart, value, _ref) {
216
198
  groupby: groupLabel,
217
199
  value: currentValue,
218
200
  color,
219
- group_name: 'completed',
201
+ type: 'completed',
220
202
  current_value: currentValue,
221
203
  target_value: targetValue,
222
204
  rows
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
- export const settingsContext = React.createContext('');
2
+ export const settingsContext = React.createContext('');
3
+ export const DepartmentsContext = React.createContext([]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.74-alpha.1",
3
+ "version": "0.0.74-alpha.2",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",