sea-chart 0.0.81-alpha2 → 0.0.82-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.
@@ -254,16 +254,7 @@ const DataSettings = _ref => {
254
254
  summary_type = CHART_SUMMARY_TYPE.ADVANCED;
255
255
  column_groupby_multiple_numeric_column = true;
256
256
  summary_columns = [];
257
- if (numericColumns && numericColumns[0]) {
258
- summary_columns.push({
259
- column_key: numericColumns[0].key,
260
- summary_method: BaseUtils.isDateSummaryColumn(numericColumns[0]) ? CHART_DATE_SUMMARY_CALCULATION_METHOD[0] : CHART_SUMMARY_CALCULATION_METHOD[0]
261
- });
262
- }
263
- // column_groupby_column_key = null;
264
- // column_groupby_date_granularity = null;
265
- // column_groupby_geolocation_granularity = null;
266
- summary_method = summary_method || CHART_SUMMARY_CALCULATION_METHOD[0];
257
+ summary_method = null;
267
258
  summary_column_key = null;
268
259
  if (numericColumns && numericColumns[0]) {
269
260
  summary_column_key = numericColumns[0].key;
@@ -1381,9 +1381,9 @@ BaseUtils.getDateGranularityByType = chart => {
1381
1381
  };
1382
1382
  BaseUtils.recalculateAvg = sqlRows => {
1383
1383
  sqlRows.forEach(item => {
1384
- const avgItemKey = Object.keys(item).find(jtem => jtem.startsWith('AVG'));
1385
- const sumItemKey = Object.keys(item).find(jtem => jtem.startsWith('SUM'));
1386
- const countItemKey = Object.keys(item).find(jtem => jtem.startsWith('COUNT'));
1384
+ const avgItemKey = Object.keys(item).find(item => item.startsWith('AVG'));
1385
+ const sumItemKey = Object.keys(item).find(item => item.startsWith('SUM'));
1386
+ const countItemKey = Object.keys(item).find(item => item.startsWith('COUNT'));
1387
1387
  if (avgItemKey && sumItemKey && countItemKey) {
1388
1388
  item[avgItemKey] = item[sumItemKey] / item[countItemKey];
1389
1389
  }
@@ -5,6 +5,8 @@ import { isArrayCellValue } from '../../cell-value-utils';
5
5
  import { getFormattedLabel, isValidRow } from '../../row-utils';
6
6
  import BaseUtils from '../base-utils';
7
7
  import { summaryMethodColumn2SqlColumn } from '../../sql/column-2-sql-column';
8
+
9
+ // one
8
10
  async function calculateOneDimensionTable(chart, value, _ref) {
9
11
  let {
10
12
  getViewRows,
@@ -205,6 +207,8 @@ function getOneDimensionTotal(columns, summary_type, formula_rows) {
205
207
  pivot_columns_total
206
208
  };
207
209
  }
210
+
211
+ // two
208
212
  async function calculateTwoDimensionTable(chart, value, _ref2) {
209
213
  let {
210
214
  getViewRows,
@@ -528,21 +532,6 @@ function updateTwoDimensionRows(pivot_rows, pivot_columns, index, name, row, isC
528
532
  total
529
533
  });
530
534
  }
531
- function isSameName(prevName, currName) {
532
- if (isNumber(prevName) && isNumber(currName)) {
533
- return prevName === currName;
534
- }
535
- if (!prevName && !currName) {
536
- return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
537
- }
538
- return prevName === currName;
539
- }
540
- function isSameGroup(isColumnDataAsAnArray, source, target) {
541
- if (isColumnDataAsAnArray) {
542
- return (!source || source.length === 0) && !target || source && source.includes(target);
543
- }
544
- return source === null && target === null || source === undefined && target === undefined || source === target;
545
- }
546
535
  function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formula_rows) {
547
536
  let pivot_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
548
537
  let pivot_columns = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
@@ -619,6 +608,23 @@ function getTwoDimensionTotal(summaryColumn, summary_type, summary_method, formu
619
608
  pivot_table_total
620
609
  };
621
610
  }
611
+
612
+ // utils
613
+ function isSameName(prevName, currName) {
614
+ if (isNumber(prevName) && isNumber(currName)) {
615
+ return prevName === currName;
616
+ }
617
+ if (!prevName && !currName) {
618
+ return prevName === null && currName === null || prevName === undefined && currName === undefined || isNaN(prevName) && isNaN(currName);
619
+ }
620
+ return prevName === currName;
621
+ }
622
+ function isSameGroup(isColumnDataAsAnArray, source, target) {
623
+ if (isColumnDataAsAnArray) {
624
+ return (!source || source.length === 0) && !target || source && source.includes(target);
625
+ }
626
+ return source === null && target === null || source === undefined && target === undefined || source === target;
627
+ }
622
628
  function getTotal(summary_column, summary_type, summary_method) {
623
629
  let rows = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
624
630
  let formula_rows = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
@@ -654,6 +660,7 @@ function getTotal(summary_column, summary_type, summary_method) {
654
660
  total++;
655
661
  }
656
662
  });
663
+ total = getTotalByType(oldTotal, total);
657
664
  return total;
658
665
  }
659
666
  if (summary_column && isDateColumn(summary_column)) {
@@ -711,22 +718,10 @@ function getTotal(summary_column, summary_type, summary_method) {
711
718
  }
712
719
  });
713
720
  if (summary_method === 'Sum') {
714
- if (Array.isArray(oldTotal)) {
715
- const newTotal = JSON.parse(JSON.stringify(oldTotal));
716
- newTotal[0][1] = Number.parseFloat(sum.toFixed(8));
717
- total = newTotal;
718
- } else {
719
- total = Number.parseFloat(sum.toFixed(8));
720
- }
721
+ total = getTotalByType(oldTotal, Number.parseFloat(sum.toFixed(8)));
721
722
  } else if (summary_method === 'Mean') {
722
- if (Array.isArray(oldTotal)) {
723
- const newTotal = JSON.parse(JSON.stringify(oldTotal));
724
- const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
725
- newTotal[0][1] = val;
726
- total = newTotal;
727
- } else {
728
- total = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
729
- }
723
+ const val = validNumbersCount === 0 ? 0 : Number.parseFloat((sum / validNumbersCount).toFixed(8));
724
+ total = getTotalByType(oldTotal, val);
730
725
  }
731
726
  break;
732
727
  }
@@ -759,15 +754,15 @@ function getTotal(summary_column, summary_type, summary_method) {
759
754
  let formulaRow = formula_rows[result._id];
760
755
  if (formulaRow) {
761
756
  if (formulaRow[summary_column_key] && typeof formulaRow[summary_column_key] === 'object') {
762
- total = formulaRow[summary_column_key][0];
757
+ total = getTotalByType(oldTotal, formulaRow[summary_column_key][0]);
763
758
  } else {
764
- total = formulaRow[summary_column_key];
759
+ getTotalByType(oldTotal, formulaRow[summary_column_key]);
765
760
  }
766
761
  } else {
767
- total = null;
762
+ total = getTotalByType(oldTotal, null);
768
763
  }
769
764
  } else {
770
- total = result[summary_column_key];
765
+ total = getTotalByType(oldTotal, result[summary_column_key]);
771
766
  }
772
767
  }
773
768
  break;
@@ -781,7 +776,7 @@ function getTotal(summary_column, summary_type, summary_method) {
781
776
  }
782
777
  // formula_rows result can be '#VALUE!'
783
778
  if (total === '#VALUE!') {
784
- total = 0;
779
+ total = getTotalByType(oldTotal, 0);
785
780
  }
786
781
  return total || 0;
787
782
  }
@@ -831,6 +826,18 @@ function getDateMaxOrMinTotal(dateArr, type) {
831
826
  dateIndex = list.indexOf(dateValue);
832
827
  return dateArr[dateIndex];
833
828
  }
829
+ function getTotalByType(oldTotal, value) {
830
+ let newTotal = '';
831
+ if (Array.isArray(oldTotal)) {
832
+ newTotal = JSON.parse(JSON.stringify(oldTotal));
833
+ newTotal[0][1] = value;
834
+ } else {
835
+ newTotal = value;
836
+ }
837
+ return newTotal;
838
+ }
839
+
840
+ // index
834
841
  function calculator(chart, value, _ref3) {
835
842
  let {
836
843
  getViewRows,
@@ -128,18 +128,17 @@ class Area extends ChartComponent {
128
128
 
129
129
  // point
130
130
  let point;
131
- if (y_axis_show_value) {
132
- point = this.chart.point().animate({
133
- appear: {
134
- animation: 'fadeIn',
135
- duration: 1000,
136
- easing: 'easeLinear'
137
- }
138
- }).position('name*value').color(chartBarColor, colorCallBack).shape('circle').size(4).style({
139
- stroke: 0,
140
- fillOpacity: 1
141
- });
142
- }
131
+ point = this.chart.point().animate({
132
+ appear: {
133
+ animation: 'fadeIn',
134
+ duration: 1000,
135
+ easing: 'easeLinear'
136
+ }
137
+ }).position('name*value').color(chartBarColor, colorCallBack).shape('circle').size(4).style({
138
+ stroke: 0,
139
+ fillOpacity: 1,
140
+ opacity: y_axis_show_value ? 1 : 0
141
+ });
143
142
  const area = this.chart.area().position('name*value').animate({
144
143
  appear: {
145
144
  animation: 'fadeIn',
@@ -166,7 +165,8 @@ class Area extends ChartComponent {
166
165
  });
167
166
  if (point) point.style({
168
167
  fillOpacity: 0.3,
169
- stroke: 0
168
+ stroke: 0,
169
+ opacity: 1
170
170
  });
171
171
  this.chart.render();
172
172
  });
@@ -181,7 +181,8 @@ class Area extends ChartComponent {
181
181
  });
182
182
  if (point) point.style({
183
183
  fillOpacity: 1,
184
- stroke: 0
184
+ stroke: 0,
185
+ opacity: 0
185
186
  });
186
187
  this.chart.render();
187
188
  });
@@ -5,8 +5,17 @@ import { BaseUtils, isBoolean } from '../../utils';
5
5
  import intl from '../../intl';
6
6
  import { CHART_TYPE, CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
- export default function Completeness(props) {
8
+ export default function Completeness(_ref) {
9
9
  var _chartRef$current, _chartRef$current2;
10
+ let {
11
+ chart,
12
+ toggleRecords,
13
+ result: data,
14
+ tables,
15
+ summaryColumn,
16
+ globalTheme,
17
+ chartColorTheme
18
+ } = _ref;
10
19
  const chartRef = useRef(null);
11
20
  const chartContainerRef = useRef(null);
12
21
  useEffect(() => {
@@ -20,11 +29,9 @@ export default function Completeness(props) {
20
29
  function createChart() {
21
30
  var _style_config$title;
22
31
  let {
23
- chart: {
24
- style_config,
25
- config
26
- }
27
- } = props;
32
+ style_config,
33
+ config
34
+ } = chart;
28
35
  chartPaddingTop = ((_style_config$title = style_config.title) === null || _style_config$title === void 0 ? void 0 : _style_config$title.text) ? 17 : 0;
29
36
  const chartPaddingRight = (config === null || config === void 0 ? void 0 : config.show_percentage) ? 45 : 0;
30
37
  const appendPadding = [chartPaddingTop, chartPaddingRight, 0, 0];
@@ -32,29 +39,18 @@ export default function Completeness(props) {
32
39
  appendPadding
33
40
  });
34
41
  currentChart.chart.on('interval:click', e => {
35
- props.toggleRecords(e.data.data);
42
+ toggleRecords(e.data.data);
36
43
  });
37
44
  }
38
45
  function drawChart() {
39
- let {
40
- result: data,
41
- chart,
42
- tables
43
- } = props;
44
- data = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
45
- if (!Array.isArray(data)) return;
46
- currentChart.loadData(data);
47
- draw(data);
46
+ const currentData = BaseUtils.formatEmptyName(data, '', intl.get('Empty'));
47
+ if (!Array.isArray(currentData)) return;
48
+ currentChart.loadData(currentData);
49
+ draw(currentData);
48
50
  currentChart.chart.render();
49
51
  currentChart.renderAxisLabel(chart, tables);
50
52
  }
51
53
  function draw(data) {
52
- const {
53
- chart,
54
- summaryColumn,
55
- globalTheme,
56
- chartColorTheme
57
- } = props;
58
54
  const theme = CHART_THEME_COLOR[globalTheme];
59
55
  const {
60
56
  label_font_size,
@@ -156,10 +152,7 @@ export default function Completeness(props) {
156
152
  return () => {
157
153
  currentChart.chart.destroy();
158
154
  };
159
- }, [props]);
160
- const {
161
- chart
162
- } = props;
155
+ }, [chart, chartColorTheme, data, globalTheme, summaryColumn, tables, toggleRecords]);
163
156
  return /*#__PURE__*/React.createElement("div", {
164
157
  className: classnames('sea-chart-completeness-chart sea-chart-container', {
165
158
  'show-x-axis-label': (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 ? void 0 : _chartRef$current.isShowXAxisLabel(chart),
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import { BaseUtils, isFunction } from '../../utils';
5
5
  import intl from '../../intl';
6
- import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE, CHART_THEME_COLOR, CHART_TYPE, EMPTY_NAME } from '../../constants';
6
+ import { CHART_LINE_TYPES, CHART_THEME_COLOR, EMPTY_NAME } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  class LineGroup extends ChartComponent {
9
9
  constructor(props) {
@@ -19,6 +19,9 @@ class LineGroup extends ChartComponent {
19
19
  this.initChart(this.container, {
20
20
  appendPadding
21
21
  });
22
+ this.chart.on('point:click', e => {
23
+ this.props.toggleRecords(e.data.data);
24
+ });
22
25
  };
23
26
  this.clearChart = () => {
24
27
  this.chart.annotation().clear(true);
@@ -93,23 +96,19 @@ class LineGroup extends ChartComponent {
93
96
  };
94
97
  });
95
98
  let point;
96
- if (y_axis_show_value) {
97
- point = this.chart.point().position('name*value').color(chartBarColor, group_name => {
98
- return this.colorMap[group_name];
99
- }).animate({
100
- appear: {
101
- animation: 'fadeIn',
102
- duration: 1000,
103
- easing: 'easeLinear'
104
- }
105
- }).shape('circle').size(3).style({
106
- stroke: 0,
107
- fillOpacity: 1
108
- });
109
- this.chart.on('point:click', e => {
110
- this.props.toggleRecords(e.data.data);
111
- });
112
- }
99
+ point = this.chart.point().position('name*value').color(chartBarColor, group_name => {
100
+ return this.colorMap[group_name];
101
+ }).animate({
102
+ appear: {
103
+ animation: 'fadeIn',
104
+ duration: 1000,
105
+ easing: 'easeLinear'
106
+ }
107
+ }).shape('circle').size(3).style({
108
+ stroke: 0,
109
+ fillOpacity: 1,
110
+ opacity: y_axis_show_value ? 1 : 0
111
+ });
113
112
 
114
113
  // this.chart.on('tooltip:show', () => {
115
114
  // if (line.styleOption.cfg.opacity === 0.3) return;
@@ -19,6 +19,9 @@ class Line extends ChartComponent {
19
19
  this.initChart(this.container, {
20
20
  appendPadding
21
21
  });
22
+ this.chart.on('point:click', e => {
23
+ this.props.toggleRecords(e.data.data);
24
+ });
22
25
  };
23
26
  this.clearChart = () => {
24
27
  this.chart.annotation().clear(true);
@@ -97,21 +100,17 @@ class Line extends ChartComponent {
97
100
  };
98
101
  });
99
102
  let point;
100
- if (y_axis_show_value) {
101
- point = this.chart.point().position('name*value').color(chartBarColor).animate({
102
- appear: {
103
- animation: 'fadeIn',
104
- duration: 1000,
105
- easing: 'easeLinear'
106
- }
107
- }).shape('circle').size(3).style({
108
- stroke: 0,
109
- fillOpacity: 1
110
- });
111
- this.chart.on('point:click', e => {
112
- this.props.toggleRecords(e.data.data);
113
- });
114
- }
103
+ point = this.chart.point().position('name*value').color(chartBarColor).animate({
104
+ appear: {
105
+ animation: 'fadeIn',
106
+ duration: 1000,
107
+ easing: 'easeLinear'
108
+ }
109
+ }).shape('circle').size(3).style({
110
+ stroke: 0,
111
+ fillOpacity: 1,
112
+ opacity: y_axis_show_value ? 1 : 0
113
+ });
115
114
 
116
115
  // this.chart.on('tooltip:show', () => {
117
116
  // if (line.styleOption.cfg.opacity === 0.3) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.81-alpha2",
3
+ "version": "0.0.82-alpha.0",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",