dtable-statistic 4.3.7 → 4.3.9

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.
@@ -302,7 +302,7 @@
302
302
 
303
303
  .statistic-chart-axis-label {
304
304
  font-size: 12px;
305
- color: #444;
305
+ color: #212529;
306
306
  }
307
307
 
308
308
  .statistic-chart-summary-types__value-container .summary-type-explanation {
@@ -366,7 +366,7 @@
366
366
 
367
367
  .statistic-tabs-dropdown-light {
368
368
  --dropdown-bg-color: #ffffff;
369
- --common-font-color: #000000;
369
+ --common-font-color: #212529;
370
370
  --dropdown-border-color: rgba(0, 40, 100, 0.12);
371
371
  --font-color: #6e7687;
372
372
  --font-hover-color: #ffffff;
@@ -191,7 +191,7 @@
191
191
  flex: 1 1;
192
192
  line-height: 34px;
193
193
  text-align: center;
194
- color: #000000;
194
+ color: #212529;
195
195
  cursor: pointer;
196
196
  box-sizing: border-box;
197
197
  }
@@ -35,31 +35,31 @@
35
35
  --dashboard-header-icon-color: rgba(0, 0, 0, .5);
36
36
  --dashboard-header-icon-hover-color: rgba(0, 0, 0, .75);
37
37
  --container-bg-color: #f5f5f5;
38
- --common-font-color: #000000;
38
+ --common-font-color: #212529;
39
39
  --item-wrapper-bg-color: #ffffff;
40
40
  /*header*/
41
- --statistic-header-focused-font-color: #444444;
41
+ --statistic-header-focused-font-color: #212529;
42
42
  --statistic-header-font-color: #999999;
43
43
  --add-stat-item-border-color: rgba(0, 40, 100, 0.12);
44
44
  --add-stat-item-hover-border-color: rgba(0, 40, 100, 0.12);
45
45
  --add-stat-item-bg-color: #ffffff;
46
- --add-stat-item-color: #000000;
47
- --add-stat-item-icon-hover-color: #000000;
48
- --add-stat-item-icon-color: #000000;
49
- --add-stat-item-icon-hover-color: #000000;
46
+ --add-stat-item-color: #212529;
47
+ --add-stat-item-icon-hover-color: #212529;
48
+ --add-stat-item-icon-color: #212529;
49
+ --add-stat-item-icon-hover-color: #212529;
50
50
  --border-color: #e7eaec;
51
51
  --view-icon-color: #949494;
52
52
  --icon-font-opcity: .5;
53
- --btn-add-view-hover-color: #000;
53
+ --btn-add-view-hover-color: #212529;
54
54
  --op-item-icon-color: #808080;
55
55
  --op-item-icon-hover-color: #404040;
56
56
  /*header*/
57
57
  --stat-item-font-color: #999999;
58
- --stat-item-font-hover-color: #000000;
58
+ --stat-item-font-hover-color: #212529;
59
59
  --dropdown-bg-color: #ffffff;
60
60
  --dropdown-border-color: rgba(0, 40, 100, 0.12);
61
61
  --stat-item-resizable-handler-color: #666666;
62
62
  --btn-scroll-icon-color: #c2c2c2;
63
63
  --btn-scroll-icon-active-color: #8c8c8c;
64
- --btn-scroll-icon-active-hover-color: #000;
64
+ --btn-scroll-icon-active-hover-color: #212529;
65
65
  }
@@ -13,12 +13,6 @@ var _rowUtils = require("../utils/row-utils");
13
13
  var _sqlUtils = require("../utils/sql-utils");
14
14
  var _constants = require("../constants");
15
15
  class CombinationCalculator extends _baseCalculator.default {
16
- constructor() {
17
- super(...arguments);
18
- this.isEmptyLabel = label => {
19
- return !label;
20
- };
21
- }
22
16
  isValidChart(chart) {
23
17
  if (!this.validateBaseConfigs(chart)) {
24
18
  return false;
@@ -245,5 +239,8 @@ class CombinationCalculator extends _baseCalculator.default {
245
239
  }
246
240
  return label;
247
241
  }
242
+ isEmptyLabel(label) {
243
+ return !label;
244
+ }
248
245
  }
249
246
  var _default = exports.default = CombinationCalculator;
@@ -6,52 +6,52 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  class ThreadManager {
8
8
  constructor(threadCount) {
9
- this.applyThread = async (id, workerConstructor) => {
10
- return new Promise((resolve, reject) => {
11
- if (this.threadList.length < this.threadCount) {
12
- const worker = new workerConstructor();
13
- worker.id = id;
14
- this.threadList.push(worker);
15
- resolve(worker);
16
- } else {
17
- this.queue.push({
18
- id,
19
- emitter: resolve,
20
- workerConstructor
21
- });
22
- }
23
- });
24
- };
25
- this.removeThread = id => {
26
- const index = this.threadList.findIndex(worker => worker.id === id);
27
- if (index > -1) {
28
- this.threadList[index] && this.threadList[index].terminate();
29
- this.threadList.splice(index, 1);
30
- }
31
- if (this.queue.length > 0) {
32
- const {
33
- id,
34
- emitter,
35
- workerConstructor
36
- } = this.queue.shift();
9
+ this.threadCount = threadCount;
10
+ this.threadList = [];
11
+ this.queue = [];
12
+ }
13
+ async applyThread(id, workerConstructor) {
14
+ return new Promise((resolve, reject) => {
15
+ if (this.threadList.length < this.threadCount) {
37
16
  const worker = new workerConstructor();
38
17
  worker.id = id;
39
18
  this.threadList.push(worker);
40
- emitter(worker);
19
+ resolve(worker);
20
+ } else {
21
+ this.queue.push({
22
+ id,
23
+ emitter: resolve,
24
+ workerConstructor
25
+ });
41
26
  }
42
- };
43
- this.clearQueue = () => {
44
- this.queue = [];
45
- };
46
- this.terminateWorkers = () => {
47
- this.threadList.forEach(item => {
48
- item && item.terminate();
49
- });
50
- this.threadList = [];
51
- };
52
- this.threadCount = threadCount;
53
- this.threadList = [];
27
+ });
28
+ }
29
+ removeThread(id) {
30
+ const index = this.threadList.findIndex(worker => worker.id === id);
31
+ if (index > -1) {
32
+ this.threadList[index] && this.threadList[index].terminate();
33
+ this.threadList.splice(index, 1);
34
+ }
35
+ if (this.queue.length > 0) {
36
+ const {
37
+ id,
38
+ emitter,
39
+ workerConstructor
40
+ } = this.queue.shift();
41
+ const worker = new workerConstructor();
42
+ worker.id = id;
43
+ this.threadList.push(worker);
44
+ emitter(worker);
45
+ }
46
+ }
47
+ clearQueue() {
54
48
  this.queue = [];
55
49
  }
50
+ terminateWorkers() {
51
+ this.threadList.forEach(item => {
52
+ item && item.terminate();
53
+ });
54
+ this.threadList = [];
55
+ }
56
56
  }
57
57
  var _default = exports.default = ThreadManager;
@@ -26,7 +26,7 @@
26
26
  .statistic-type-title {
27
27
  font-weight: 600;
28
28
  font-size: 18px;
29
- color: #202428;
29
+ color: #212529;
30
30
  }
31
31
 
32
32
  .chart-categories-nav {
@@ -75,7 +75,7 @@
75
75
  }
76
76
 
77
77
  .chart-icon:not(.icon-highlight):hover {
78
- color: #202428;
78
+ color: #212529;
79
79
  }
80
80
 
81
81
  .icon-highlight {
@@ -31,7 +31,7 @@ class Select extends _react.Component {
31
31
  });
32
32
  window.app.eventBus.dispatch(_constants.CommonEventTypes.OPEN_SELECT, !this.state.isShowSelectOptions);
33
33
  };
34
- this.onClick = event => {
34
+ this.onMousedown = event => {
35
35
  if (this.props.isShowSelected && event.target.className.includes('icon-fork-number')) {
36
36
  return;
37
37
  }
@@ -84,10 +84,10 @@ class Select extends _react.Component {
84
84
  };
85
85
  }
86
86
  componentDidMount() {
87
- document.addEventListener('click', this.onClick);
87
+ document.addEventListener('mousedown', this.onMousedown);
88
88
  }
89
89
  componentWillUnmount() {
90
- document.removeEventListener('click', this.onClick);
90
+ document.removeEventListener('mousedown', this.onMousedown);
91
91
  }
92
92
  render() {
93
93
  let {
@@ -485,8 +485,8 @@ const STAT_ITEM_THEME_COLORS = exports.STAT_ITEM_THEME_COLORS = {
485
485
  [THEME_NAME_MAP.LIGHT]: {
486
486
  textColor: '#6e6e6e',
487
487
  gridColor: '#bfbfbf',
488
- labelColor: '#000000',
489
- legendPageNavigatorMarkerColor: '#000000',
488
+ labelColor: '#212529',
489
+ legendPageNavigatorMarkerColor: '#212529',
490
490
  cardColor: '#545454'
491
491
  }
492
492
  };
@@ -24,9 +24,10 @@ class TimeComparisonSettings extends _react.Component {
24
24
  this.renderGroupbyDateGranularity = () => {
25
25
  let {
26
26
  dateGranularityOptions,
27
- groupbyDateGranularity
27
+ statItem
28
28
  } = this.props;
29
- let selectedDateGranularity = this.getSelectedDateGranularity(groupbyDateGranularity);
29
+ dateGranularityOptions = dateGranularityOptions.filter(item => item.value !== 'year');
30
+ let selectedDateGranularity = this.getSelectedDateGranularity(statItem.x_axis_date_granularity);
30
31
  return /*#__PURE__*/_react.default.createElement("div", {
31
32
  className: "statistic-chart-parameter-item"
32
33
  }, /*#__PURE__*/_react.default.createElement(_components.DTableSelect, {
@@ -52,21 +53,6 @@ class TimeComparisonSettings extends _react.Component {
52
53
  options: this.columnsOptions
53
54
  }));
54
55
  };
55
- this.renderGroupbyDateGranularity = () => {
56
- let {
57
- dateGranularityOptions,
58
- statItem
59
- } = this.props;
60
- dateGranularityOptions = dateGranularityOptions.filter(item => item.value !== 'year');
61
- let selectedDateGranularity = this.getSelectedDateGranularity(statItem.x_axis_date_granularity);
62
- return /*#__PURE__*/_react.default.createElement("div", {
63
- className: "statistic-chart-parameter-item"
64
- }, /*#__PURE__*/_react.default.createElement(_components.DTableSelect, {
65
- value: selectedDateGranularity,
66
- onChange: this.onSelectGroupbyDateGranularity,
67
- options: dateGranularityOptions
68
- }));
69
- };
70
56
  this.onSelectGroupbyDateGranularity = dateGranularity => {
71
57
  let updated = {
72
58
  x_axis_date_granularity: dateGranularity.value
@@ -21,6 +21,7 @@ class ColorPicker extends _react.default.PureComponent {
21
21
  this.onInputChanged = event => {
22
22
  const value = event.target.value;
23
23
  if (value === this.state.activeColor) return;
24
+
24
25
  // todo valid color
25
26
  this.updateColor(value);
26
27
  this.setState({
@@ -21,53 +21,6 @@ const propTypes = {
21
21
  class BasicNumericCard extends _baseChart.default {
22
22
  constructor(props) {
23
23
  super(props);
24
- this.componentDidMount = async () => {
25
- const {
26
- statItem,
27
- chartCalculator
28
- } = this.props;
29
- if (this.container) {
30
- const data = await chartCalculator.calculate(statItem);
31
- this.setState({
32
- isCalculatingData: false
33
- });
34
- this.drawChart(data);
35
- this.calculateData = data;
36
- }
37
- };
38
- this.componentDidUpdate = async (preProps, preState) => {
39
- const {
40
- statItem,
41
- chartCalculator
42
- } = this.props;
43
- const {
44
- isCalculatingData
45
- } = this.state;
46
- if (isCalculatingData !== preState.isCalculatingData) return;
47
- if (this.shouldCalculateStatItem(preProps, this.props)) {
48
- this.setState({
49
- isCalculatingData: true
50
- });
51
- if (this.container) {
52
- const data = await chartCalculator.calculate(statItem);
53
- this.calculateData = data;
54
- this.setState({
55
- isCalculatingData: false
56
- });
57
- this.chart && this.chart.destroy();
58
- this.drawChart(data);
59
- if (this.props.isPreview) {
60
- this.chart.forceFit();
61
- }
62
- }
63
- } else {
64
- this.chart && this.chart.destroy();
65
- this.drawChart(this.calculateData);
66
- if (this.props.isPreview) {
67
- this.chart.forceFit();
68
- }
69
- }
70
- };
71
24
  this.drawChart = data => {
72
25
  const {
73
26
  isPreview,
@@ -175,6 +128,20 @@ class BasicNumericCard extends _baseChart.default {
175
128
  };
176
129
  this.calculateData = null;
177
130
  }
131
+ async componentDidMount() {
132
+ const {
133
+ statItem,
134
+ chartCalculator
135
+ } = this.props;
136
+ if (this.container) {
137
+ const data = await chartCalculator.calculate(statItem);
138
+ this.setState({
139
+ isCalculatingData: false
140
+ });
141
+ this.drawChart(data);
142
+ this.calculateData = data;
143
+ }
144
+ }
178
145
  shouldComponentUpdate(nextProps, nextState) {
179
146
  if (this.canUpdate(this.props, nextProps)) {
180
147
  return true;
@@ -184,6 +151,39 @@ class BasicNumericCard extends _baseChart.default {
184
151
  }
185
152
  return false;
186
153
  }
154
+ async componentDidUpdate(preProps, preState) {
155
+ const {
156
+ statItem,
157
+ chartCalculator
158
+ } = this.props;
159
+ const {
160
+ isCalculatingData
161
+ } = this.state;
162
+ if (isCalculatingData !== preState.isCalculatingData) return;
163
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
164
+ this.setState({
165
+ isCalculatingData: true
166
+ });
167
+ if (this.container) {
168
+ const data = await chartCalculator.calculate(statItem);
169
+ this.calculateData = data;
170
+ this.setState({
171
+ isCalculatingData: false
172
+ });
173
+ this.chart && this.chart.destroy();
174
+ this.drawChart(data);
175
+ if (this.props.isPreview) {
176
+ this.chart.forceFit();
177
+ }
178
+ }
179
+ } else {
180
+ this.chart && this.chart.destroy();
181
+ this.drawChart(this.calculateData);
182
+ if (this.props.isPreview) {
183
+ this.chart.forceFit();
184
+ }
185
+ }
186
+ }
187
187
  componentWillUnmount() {
188
188
  this.container = null;
189
189
  }
@@ -27,66 +27,6 @@ const propTypes = {
27
27
  class CombinationChart extends _baseChart.default {
28
28
  constructor(props) {
29
29
  super(props);
30
- this.componentDidMount = async () => {
31
- const {
32
- statItem,
33
- chartCalculator,
34
- eventBus
35
- } = this.props;
36
- this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
37
- this.renderAxisLabel(newStatItem);
38
- });
39
- if (!this.container) return;
40
- const data = await chartCalculator.calculate(statItem);
41
- let showResultDescription = data.length > 0 ? false : true;
42
- this.setState({
43
- isCalculatingData: false,
44
- showResultDescription
45
- }, () => {
46
- if (!showResultDescription) {
47
- this.drawChart(data);
48
- this.calculateData = data;
49
- }
50
- });
51
- };
52
- this.componentDidUpdate = async (preProps, preState) => {
53
- const {
54
- statItem,
55
- chartCalculator
56
- } = this.props;
57
- const {
58
- isCalculatingData
59
- } = this.state;
60
- if (isCalculatingData !== preState.isCalculatingData) return;
61
- if (this.shouldCalculateStatItem(preProps, this.props)) {
62
- this.setState({
63
- isCalculatingData: true
64
- });
65
- if (this.container) {
66
- const data = await chartCalculator.calculate(statItem);
67
- const showResultDescription = data.length > 0 ? false : true;
68
- this.chart && this.destroyChart();
69
- this.calculateData = data;
70
- this.setState({
71
- isCalculatingData: false,
72
- showResultDescription
73
- }, () => {
74
- if (!showResultDescription) {
75
- this.drawChart(data);
76
- if (this.props.isPreview) this.chart.forceFit();
77
- }
78
- });
79
- }
80
- } else {
81
- if (!this.state.showResultDescription) {
82
- this.chart && this.destroyChart();
83
- this.drawChart(this.calculateData);
84
- if (this.props.isPreview) {
85
- this.chart.forceFit();
86
- }
87
- }
88
- }
89
- };
90
30
  this.renderAxisLabel = newStatItem => {
91
31
  let {
92
32
  getTableById,
@@ -498,6 +438,28 @@ class CombinationChart extends _baseChart.default {
498
438
  };
499
439
  this.calculateData = null;
500
440
  }
441
+ async componentDidMount() {
442
+ const {
443
+ statItem,
444
+ chartCalculator,
445
+ eventBus
446
+ } = this.props;
447
+ this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
448
+ this.renderAxisLabel(newStatItem);
449
+ });
450
+ if (!this.container) return;
451
+ const data = await chartCalculator.calculate(statItem);
452
+ let showResultDescription = data.length > 0 ? false : true;
453
+ this.setState({
454
+ isCalculatingData: false,
455
+ showResultDescription
456
+ }, () => {
457
+ if (!showResultDescription) {
458
+ this.drawChart(data);
459
+ this.calculateData = data;
460
+ }
461
+ });
462
+ }
501
463
  shouldComponentUpdate(nextProps, nextState) {
502
464
  const {
503
465
  theme,
@@ -517,6 +479,44 @@ class CombinationChart extends _baseChart.default {
517
479
  }
518
480
  return false;
519
481
  }
482
+ async componentDidUpdate(preProps, preState) {
483
+ const {
484
+ statItem,
485
+ chartCalculator
486
+ } = this.props;
487
+ const {
488
+ isCalculatingData
489
+ } = this.state;
490
+ if (isCalculatingData !== preState.isCalculatingData) return;
491
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
492
+ this.setState({
493
+ isCalculatingData: true
494
+ });
495
+ if (this.container) {
496
+ const data = await chartCalculator.calculate(statItem);
497
+ const showResultDescription = data.length > 0 ? false : true;
498
+ this.chart && this.destroyChart();
499
+ this.calculateData = data;
500
+ this.setState({
501
+ isCalculatingData: false,
502
+ showResultDescription
503
+ }, () => {
504
+ if (!showResultDescription) {
505
+ this.drawChart(data);
506
+ if (this.props.isPreview) this.chart.forceFit();
507
+ }
508
+ });
509
+ }
510
+ } else {
511
+ if (!this.state.showResultDescription) {
512
+ this.chart && this.destroyChart();
513
+ this.drawChart(this.calculateData);
514
+ if (this.props.isPreview) {
515
+ this.chart.forceFit();
516
+ }
517
+ }
518
+ }
519
+ }
520
520
  componentWillUnmount() {
521
521
  this.container = null;
522
522
  this.unsubscribeStyleChange();
@@ -20,56 +20,6 @@ const HEIGHT = 400;
20
20
  class DashboardChart extends _baseChart.default {
21
21
  constructor(props) {
22
22
  super(props);
23
- this.componentDidMount = async () => {
24
- const {
25
- statItem,
26
- chartCalculator
27
- } = this.props;
28
- if (this.container) {
29
- const data = await chartCalculator.calculate(statItem);
30
- this.setState({
31
- isCalculatingData: false
32
- });
33
- this.drawChart(data);
34
- this.calculateData = data;
35
- }
36
- };
37
- this.componentDidUpdate = async (preProps, preState) => {
38
- const {
39
- statItem,
40
- chartCalculator
41
- } = this.props;
42
- const {
43
- isCalculatingData
44
- } = this.state;
45
- if (isCalculatingData !== preState.isCalculatingData) return;
46
- if (this.shouldCalculateStatItem(preProps, this.props)) {
47
- this.setState({
48
- isCalculatingData: true
49
- });
50
- if (this.container) {
51
- const data = await chartCalculator.calculate(statItem);
52
- if (!this.container) return;
53
- this.calculateData = data;
54
- this.setState({
55
- isCalculatingData: false
56
- });
57
- this.chart && this.chart.destroy();
58
- this.drawChart(data);
59
- if (this.props.isPreview) {
60
- const canvasSize = this.getCanvasSize();
61
- this.chart.changeSize(canvasSize.w, canvasSize.h);
62
- }
63
- }
64
- } else {
65
- this.chart && this.chart.destroy();
66
- this.drawChart(this.calculateData);
67
- if (this.props.isPreview) {
68
- const canvasSize = this.getCanvasSize();
69
- this.chart.changeSize(canvasSize.w, canvasSize.h);
70
- }
71
- }
72
- };
73
23
  this.getCanvasSize = () => {
74
24
  const maxWidth = this.container.clientWidth;
75
25
  const maxHeight = this.container.clientHeight;
@@ -243,6 +193,20 @@ class DashboardChart extends _baseChart.default {
243
193
  };
244
194
  this.calculateData = null;
245
195
  }
196
+ async componentDidMount() {
197
+ const {
198
+ statItem,
199
+ chartCalculator
200
+ } = this.props;
201
+ if (this.container) {
202
+ const data = await chartCalculator.calculate(statItem);
203
+ this.setState({
204
+ isCalculatingData: false
205
+ });
206
+ this.drawChart(data);
207
+ this.calculateData = data;
208
+ }
209
+ }
246
210
  shouldComponentUpdate(nextProps, nextState) {
247
211
  if (this.canUpdate(this.props, nextProps)) {
248
212
  return true;
@@ -252,6 +216,42 @@ class DashboardChart extends _baseChart.default {
252
216
  }
253
217
  return false;
254
218
  }
219
+ async componentDidUpdate(preProps, preState) {
220
+ const {
221
+ statItem,
222
+ chartCalculator
223
+ } = this.props;
224
+ const {
225
+ isCalculatingData
226
+ } = this.state;
227
+ if (isCalculatingData !== preState.isCalculatingData) return;
228
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
229
+ this.setState({
230
+ isCalculatingData: true
231
+ });
232
+ if (this.container) {
233
+ const data = await chartCalculator.calculate(statItem);
234
+ if (!this.container) return;
235
+ this.calculateData = data;
236
+ this.setState({
237
+ isCalculatingData: false
238
+ });
239
+ this.chart && this.chart.destroy();
240
+ this.drawChart(data);
241
+ if (this.props.isPreview) {
242
+ const canvasSize = this.getCanvasSize();
243
+ this.chart.changeSize(canvasSize.w, canvasSize.h);
244
+ }
245
+ }
246
+ } else {
247
+ this.chart && this.chart.destroy();
248
+ this.drawChart(this.calculateData);
249
+ if (this.props.isPreview) {
250
+ const canvasSize = this.getCanvasSize();
251
+ this.chart.changeSize(canvasSize.w, canvasSize.h);
252
+ }
253
+ }
254
+ }
255
255
  render() {
256
256
  const {
257
257
  isCalculatingData
@@ -26,57 +26,6 @@ const propTypes = {
26
26
  class ScatterChart extends _baseChart.default {
27
27
  constructor(props) {
28
28
  super(props);
29
- this.componentDidMount = async () => {
30
- const {
31
- statItem,
32
- chartCalculator,
33
- eventBus
34
- } = this.props;
35
- if (this.container) {
36
- const data = await chartCalculator.calculate(statItem);
37
- this.setState({
38
- isCalculatingData: false
39
- });
40
- this.drawChart(data);
41
- this.calculateData = data;
42
- }
43
- this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
44
- this.renderAxisLabel(newStatItem);
45
- });
46
- };
47
- this.componentDidUpdate = async (preProps, preState) => {
48
- const {
49
- statItem,
50
- chartCalculator
51
- } = this.props;
52
- const {
53
- isCalculatingData
54
- } = this.state;
55
- if (isCalculatingData !== preState.isCalculatingData) return;
56
- if (this.shouldCalculateStatItem(preProps, this.props)) {
57
- if (this.container) {
58
- this.setState({
59
- isCalculatingData: true
60
- });
61
- const data = await chartCalculator.calculate(statItem);
62
- this.calculateData = data;
63
- this.setState({
64
- isCalculatingData: false
65
- });
66
- this.chart && this.chart.destroy();
67
- this.drawChart(data);
68
- if (this.props.isPreview) {
69
- this.chart.forceFit();
70
- }
71
- }
72
- } else {
73
- this.chart && this.chart.destroy();
74
- this.drawChart(this.calculateData);
75
- if (this.props.isPreview) {
76
- this.chart.forceFit();
77
- }
78
- }
79
- };
80
29
  this.drawChart = data => {
81
30
  const {
82
31
  getTableById,
@@ -261,6 +210,24 @@ class ScatterChart extends _baseChart.default {
261
210
  };
262
211
  this.calculateData = null;
263
212
  }
213
+ async componentDidMount() {
214
+ const {
215
+ statItem,
216
+ chartCalculator,
217
+ eventBus
218
+ } = this.props;
219
+ if (this.container) {
220
+ const data = await chartCalculator.calculate(statItem);
221
+ this.setState({
222
+ isCalculatingData: false
223
+ });
224
+ this.drawChart(data);
225
+ this.calculateData = data;
226
+ }
227
+ this.unsubscribeStyleChange = eventBus.subscribe(_constants.LABEL_CONFIG_CHANGED, newStatItem => {
228
+ this.renderAxisLabel(newStatItem);
229
+ });
230
+ }
264
231
  shouldComponentUpdate(nextProps, nextState) {
265
232
  const {
266
233
  colorThemeName
@@ -276,6 +243,39 @@ class ScatterChart extends _baseChart.default {
276
243
  }
277
244
  return false;
278
245
  }
246
+ async componentDidUpdate(preProps, preState) {
247
+ const {
248
+ statItem,
249
+ chartCalculator
250
+ } = this.props;
251
+ const {
252
+ isCalculatingData
253
+ } = this.state;
254
+ if (isCalculatingData !== preState.isCalculatingData) return;
255
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
256
+ if (this.container) {
257
+ this.setState({
258
+ isCalculatingData: true
259
+ });
260
+ const data = await chartCalculator.calculate(statItem);
261
+ this.calculateData = data;
262
+ this.setState({
263
+ isCalculatingData: false
264
+ });
265
+ this.chart && this.chart.destroy();
266
+ this.drawChart(data);
267
+ if (this.props.isPreview) {
268
+ this.chart.forceFit();
269
+ }
270
+ }
271
+ } else {
272
+ this.chart && this.chart.destroy();
273
+ this.drawChart(this.calculateData);
274
+ if (this.props.isPreview) {
275
+ this.chart.forceFit();
276
+ }
277
+ }
278
+ }
279
279
  componentWillUnmount() {
280
280
  this.container = null;
281
281
  this.unsubscribeStyleChange && this.unsubscribeStyleChange();
@@ -30,53 +30,6 @@ const propTypes = {
30
30
  class TreemapChart extends _baseChart.default {
31
31
  constructor(props) {
32
32
  super(props);
33
- this.componentDidMount = async () => {
34
- const {
35
- statItem,
36
- chartCalculator
37
- } = this.props;
38
- if (this.container) {
39
- const data = await chartCalculator.calculate(statItem);
40
- this.setState({
41
- isCalculatingData: false
42
- });
43
- this.drawChart(data);
44
- this.calculateData = data;
45
- }
46
- };
47
- this.componentDidUpdate = async (preProps, preState) => {
48
- const {
49
- statItem,
50
- chartCalculator
51
- } = this.props;
52
- const {
53
- isCalculatingData
54
- } = this.state;
55
- if (isCalculatingData !== preState.isCalculatingData) return;
56
- if (this.shouldCalculateStatItem(preProps, this.props)) {
57
- this.setState({
58
- isCalculatingData: true
59
- });
60
- if (this.container) {
61
- const data = await chartCalculator.calculate(statItem);
62
- this.calculateData = data;
63
- this.setState({
64
- isCalculatingData: false
65
- });
66
- this.chart && this.chart.destroy();
67
- this.drawChart(data);
68
- if (this.props.isPreview) {
69
- this.chart.forceFit();
70
- }
71
- }
72
- } else {
73
- this.chart && this.chart.destroy();
74
- this.drawChart(this.calculateData);
75
- if (this.props.isPreview) {
76
- this.chart.forceFit();
77
- }
78
- }
79
- };
80
33
  this.drawChart = data => {
81
34
  const {
82
35
  getTableById,
@@ -221,6 +174,20 @@ class TreemapChart extends _baseChart.default {
221
174
  }
222
175
  (0, _customG.registerGeometryLabelLayout)('custom-limit-in-shape', limitInShape);
223
176
  }
177
+ async componentDidMount() {
178
+ const {
179
+ statItem,
180
+ chartCalculator
181
+ } = this.props;
182
+ if (this.container) {
183
+ const data = await chartCalculator.calculate(statItem);
184
+ this.setState({
185
+ isCalculatingData: false
186
+ });
187
+ this.drawChart(data);
188
+ this.calculateData = data;
189
+ }
190
+ }
224
191
  shouldComponentUpdate(nextProps, nextState) {
225
192
  const {
226
193
  colorThemeName
@@ -236,6 +203,39 @@ class TreemapChart extends _baseChart.default {
236
203
  }
237
204
  return false;
238
205
  }
206
+ async componentDidUpdate(preProps, preState) {
207
+ const {
208
+ statItem,
209
+ chartCalculator
210
+ } = this.props;
211
+ const {
212
+ isCalculatingData
213
+ } = this.state;
214
+ if (isCalculatingData !== preState.isCalculatingData) return;
215
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
216
+ this.setState({
217
+ isCalculatingData: true
218
+ });
219
+ if (this.container) {
220
+ const data = await chartCalculator.calculate(statItem);
221
+ this.calculateData = data;
222
+ this.setState({
223
+ isCalculatingData: false
224
+ });
225
+ this.chart && this.chart.destroy();
226
+ this.drawChart(data);
227
+ if (this.props.isPreview) {
228
+ this.chart.forceFit();
229
+ }
230
+ }
231
+ } else {
232
+ this.chart && this.chart.destroy();
233
+ this.drawChart(this.calculateData);
234
+ if (this.props.isPreview) {
235
+ this.chart.forceFit();
236
+ }
237
+ }
238
+ }
239
239
  componentWillUnmount() {
240
240
  this.container = null;
241
241
  }
@@ -18,56 +18,9 @@ const propTypes = {
18
18
  chartCalculator: _propTypes.default.object,
19
19
  getTableById: _propTypes.default.func
20
20
  };
21
- class BasicNumericCard extends _baseChart.default {
21
+ class TrendChart extends _baseChart.default {
22
22
  constructor(props) {
23
23
  super(props);
24
- this.componentDidMount = async () => {
25
- const {
26
- statItem,
27
- chartCalculator
28
- } = this.props;
29
- if (this.container) {
30
- const data = await chartCalculator.calculate(statItem);
31
- this.setState({
32
- isCalculatingData: false
33
- });
34
- this.drawChart(data);
35
- this.calculateData = data;
36
- }
37
- };
38
- this.componentDidUpdate = async (preProps, preState) => {
39
- const {
40
- statItem,
41
- chartCalculator
42
- } = this.props;
43
- const {
44
- isCalculatingData
45
- } = this.state;
46
- if (isCalculatingData !== preState.isCalculatingData) return;
47
- if (this.shouldCalculateStatItem(preProps, this.props)) {
48
- this.setState({
49
- isCalculatingData: true
50
- });
51
- if (this.container) {
52
- const data = await chartCalculator.calculate(statItem);
53
- this.calculateData = data;
54
- this.setState({
55
- isCalculatingData: false
56
- });
57
- this.chart && this.chart.destroy();
58
- this.drawChart(data);
59
- if (this.props.isPreview) {
60
- this.chart.forceFit();
61
- }
62
- }
63
- } else {
64
- this.chart && this.chart.destroy();
65
- this.drawChart(this.calculateData);
66
- if (this.props.isPreview) {
67
- this.chart.forceFit();
68
- }
69
- }
70
- };
71
24
  this.drawChart = data => {
72
25
  const {
73
26
  isPreview,
@@ -223,6 +176,20 @@ class BasicNumericCard extends _baseChart.default {
223
176
  };
224
177
  this.calculateData = null;
225
178
  }
179
+ async componentDidMount() {
180
+ const {
181
+ statItem,
182
+ chartCalculator
183
+ } = this.props;
184
+ if (this.container) {
185
+ const data = await chartCalculator.calculate(statItem);
186
+ this.setState({
187
+ isCalculatingData: false
188
+ });
189
+ this.drawChart(data);
190
+ this.calculateData = data;
191
+ }
192
+ }
226
193
  shouldComponentUpdate(nextProps, nextState) {
227
194
  if (this.canUpdate(this.props, nextProps)) {
228
195
  return true;
@@ -232,6 +199,39 @@ class BasicNumericCard extends _baseChart.default {
232
199
  }
233
200
  return false;
234
201
  }
202
+ async componentDidUpdate(preProps, preState) {
203
+ const {
204
+ statItem,
205
+ chartCalculator
206
+ } = this.props;
207
+ const {
208
+ isCalculatingData
209
+ } = this.state;
210
+ if (isCalculatingData !== preState.isCalculatingData) return;
211
+ if (this.shouldCalculateStatItem(preProps, this.props)) {
212
+ this.setState({
213
+ isCalculatingData: true
214
+ });
215
+ if (this.container) {
216
+ const data = await chartCalculator.calculate(statItem);
217
+ this.calculateData = data;
218
+ this.setState({
219
+ isCalculatingData: false
220
+ });
221
+ this.chart && this.chart.destroy();
222
+ this.drawChart(data);
223
+ if (this.props.isPreview) {
224
+ this.chart.forceFit();
225
+ }
226
+ }
227
+ } else {
228
+ this.chart && this.chart.destroy();
229
+ this.drawChart(this.calculateData);
230
+ if (this.props.isPreview) {
231
+ this.chart.forceFit();
232
+ }
233
+ }
234
+ }
235
235
  componentWillUnmount() {
236
236
  this.container = null;
237
237
  }
@@ -245,5 +245,5 @@ class BasicNumericCard extends _baseChart.default {
245
245
  }));
246
246
  }
247
247
  }
248
- BasicNumericCard.propTypes = propTypes;
249
- var _default = exports.default = BasicNumericCard;
248
+ TrendChart.propTypes = propTypes;
249
+ var _default = exports.default = TrendChart;
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.getClientFormulaDisplayString = exports.getClientCellValueDisplayString = void 0;
8
8
  var _dayjs = _interopRequireDefault(require("dayjs"));
9
9
  var _dtableUtils = require("dtable-utils");
10
+ var _object = require("./object");
10
11
  const getClientFormulaDisplayString = function (value, columnData) {
11
12
  let {
12
13
  collaborators = []
@@ -48,7 +49,7 @@ const getClientLinkDisplayString = function (links, columnData) {
48
49
  let formulaData = {
49
50
  ...columnData
50
51
  };
51
- if (!columnData.hasOwnProperty('result_type')) {
52
+ if (!(0, _object.hasOwnProperty)(columnData, 'result_type')) {
52
53
  formulaData.result_type = _dtableUtils.FORMULA_RESULT_TYPE.ARRAY;
53
54
  }
54
55
  const displayValue = links.map(link => link.display_value);
@@ -8,17 +8,17 @@ var _react = require("react");
8
8
  const isSameObject = (a, b) => {
9
9
  let k;
10
10
  for (k in a) {
11
- if (a.hasOwnProperty(k)) {
11
+ if (hasOwnProperty(a, k)) {
12
12
  if (typeof a[k] === 'function' && typeof b[k] === 'function' || /*#__PURE__*/(0, _react.isValidElement)(a[k]) && /*#__PURE__*/(0, _react.isValidElement)(b[k])) {
13
13
  continue;
14
14
  }
15
- if (!b.hasOwnProperty(k) || a[k] !== b[k]) {
15
+ if (!hasOwnProperty(b, k) || a[k] !== b[k]) {
16
16
  return false;
17
17
  }
18
18
  }
19
19
  }
20
20
  for (k in b) {
21
- if (b.hasOwnProperty(k) && !a.hasOwnProperty(k)) {
21
+ if (hasOwnProperty(b, k) && !hasOwnProperty(a, k)) {
22
22
  return false;
23
23
  }
24
24
  }
@@ -189,7 +189,7 @@ class StatUtils {
189
189
  }
190
190
  return (0, _dtableUtils.sortNumber)(current, next, sortType);
191
191
  }
192
- return (0, _dtableUtils.sortText)(result_type, current, next, sortType);
192
+ return (0, _dtableUtils.sortText)(current, next, sortType);
193
193
  }
194
194
  default:
195
195
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-statistic",
3
- "version": "4.3.7",
3
+ "version": "4.3.9",
4
4
  "description": "statistics",
5
5
  "main": "dist/dtable-statistic.js",
6
6
  "author": "seafile",
@@ -31,6 +31,7 @@
31
31
  "devDependencies": {
32
32
  "@babel/cli": "7.22.15",
33
33
  "@babel/core": "^7.16.0",
34
+ "@babel/eslint-parser": "^7.16.3",
34
35
  "@babel/plugin-proposal-private-property-in-object": "7.21.11",
35
36
  "@babel/plugin-transform-runtime": "7.22.10",
36
37
  "@babel/runtime": "7.22.11",
@@ -39,8 +40,8 @@
39
40
  "@testing-library/jest-dom": "5.17.0",
40
41
  "@testing-library/react": "^11.1.0",
41
42
  "@testing-library/user-event": "13.5.0",
43
+ "@types/jest": "^29.5.10",
42
44
  "autoprefixer": "10.4.5",
43
- "babel-eslint": "10.0.1",
44
45
  "babel-jest": "^27.4.2",
45
46
  "babel-loader": "^8.2.3",
46
47
  "babel-plugin-import": "^1.13.6",
@@ -51,6 +52,7 @@
51
52
  "browserslist": "^4.18.1",
52
53
  "camelcase": "^6.2.1",
53
54
  "case-sensitive-paths-webpack-plugin": "^2.4.0",
55
+ "circular-dependency-plugin": "^5.2.2",
54
56
  "css-loader": "^6.5.1",
55
57
  "css-minimizer-webpack-plugin": "^3.2.0",
56
58
  "dotenv": "^10.0.0",