sea-chart 0.0.81-alpha.0 → 0.0.81-alpha2

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.
@@ -1379,4 +1379,15 @@ BaseUtils.getDateGranularityByType = chart => {
1379
1379
  }
1380
1380
  return null;
1381
1381
  };
1382
+ BaseUtils.recalculateAvg = sqlRows => {
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'));
1387
+ if (avgItemKey && sumItemKey && countItemKey) {
1388
+ item[avgItemKey] = item[sumItemKey] / item[countItemKey];
1389
+ }
1390
+ });
1391
+ return sqlRows;
1392
+ };
1382
1393
  export default BaseUtils;
@@ -1439,10 +1439,10 @@ SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMa
1439
1439
  switch (type) {
1440
1440
  case CHART_TYPE.TABLE:
1441
1441
  {
1442
+ sqlRows = BaseUtils.recalculateAvg(sqlRows);
1442
1443
  const {
1443
1444
  column_groupby_column_key
1444
1445
  } = chart.config;
1445
- // TODO
1446
1446
  if (!column_groupby_column_key) {
1447
1447
  return {
1448
1448
  result: _SQLStatisticsUtils.oneDimensionTableSQLResult2JavaScript(chart, sqlRows, chartSQLMap, columnMap, tables)
@@ -37,6 +37,9 @@ class ChartDataSQL {
37
37
  const sql_column_name = method ? "".concat(method, "(`").concat(column_name, "`)") : "`".concat(column_name, "`");
38
38
  const not_include_empty_sql = "".concat(sql_column_name, " IS NOT NULL");
39
39
  if (this.filter_sql) {
40
+ if (this.filter_sql.startsWith('WHERE')) {
41
+ this.filter_sql = this.filter_sql.slice(5);
42
+ }
40
43
  this.filter_sql = "WHERE ".concat(not_include_empty_sql, " AND ").concat(this.filter_sql);
41
44
  } else {
42
45
  this.filter_sql = "WHERE ".concat(not_include_empty_sql);
@@ -451,7 +454,7 @@ class ChartDataSQL {
451
454
  }
452
455
  return "SELECT ".concat(groupby_column_name, ", ").concat(left_summary_column_name, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(groupby_column_name, " LIMIT 0, 5000");
453
456
  };
454
- this._summary_columns_2_sql = (summary_columns, summary_column_key, groupbyColumnIsCollaborator, summary_method) => {
457
+ this._summary_columns_2_sql = (summary_columns, summary_column_key, groupby_column, summary_method) => {
455
458
  const summary_column = this._get_column_by_key(summary_column_key);
456
459
  summary_method = summary_method.toUpperCase();
457
460
  let summary_column_names = [];
@@ -473,7 +476,7 @@ class ChartDataSQL {
473
476
  });
474
477
 
475
478
  // groupby_column is COLLABORATOR , replace AVG with SUM, and add 'COUNT(*)'
476
- if (groupbyColumnIsCollaborator) {
479
+ if (groupby_column.type === CellType.COLLABORATOR) {
477
480
  summary_column_names.forEach((item, index) => {
478
481
  if (item.startsWith('AVG')) {
479
482
  summary_column_names[index] = 'SUM' + item.slice(3);
@@ -481,10 +484,13 @@ class ChartDataSQL {
481
484
  });
482
485
  summary_column_names.push('COUNT(*)');
483
486
  }
487
+ summary_column_names.forEach((item, index) => {
488
+ if (item.startsWith('AVG')) {
489
+ const group_column_name = this._summary_column_2_sql('ROW_COUNT', groupby_column);
490
+ summary_column_names[index] = item + ',SUM' + item.slice(3) + ",".concat(group_column_name);
491
+ }
492
+ });
484
493
  let summary_column_names_str = summary_column_names.join(', ');
485
- // if (summary_column_names_str) {
486
- // summary_column_names_str = `, ${summary_column_names_str}`;
487
- // }
488
494
  return summary_column_names_str;
489
495
  };
490
496
  this._one_dimension_statistic_table_2_sql = () => {
@@ -516,7 +522,7 @@ class ChartDataSQL {
516
522
  return "SELECT ".concat(groupby_column_name, ", ").concat(summary_column_name, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(groupby_column_name, " LIMIT 0, 5000");
517
523
  }
518
524
  if (summary_columns) {
519
- const summary_column_names_str = this._summary_columns_2_sql(summary_columns, summary_column_key, groupby_column.type === CellType.COLLABORATOR, summary_method);
525
+ const summary_column_names_str = this._summary_columns_2_sql(summary_columns, summary_column_key, groupby_column, summary_method);
520
526
  return "SELECT ".concat(groupby_column_name, ", ").concat(summary_column_names_str, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(groupby_column_name, " LIMIT 0, 5000");
521
527
  }
522
528
  summary_method = summary_method.toUpperCase();
@@ -578,7 +584,7 @@ class ChartDataSQL {
578
584
  return '';
579
585
  }
580
586
  summary_method = summary_method.toUpperCase();
581
- summary_column_names_str = this._summary_columns_2_sql(summary_columns, summary_column_key, groupby_column.type === CellType.COLLABORATOR, summary_method);
587
+ summary_column_names_str = this._summary_columns_2_sql(summary_columns, summary_column_key, groupby_column, summary_method);
582
588
  }
583
589
  }
584
590
  return "SELECT ".concat(groupby_column_name, ", ").concat(column_groupby_column_name, ", ").concat(summary_column_names_str, " FROM ").concat(this.table_name, " ").concat(this.filter_sql, " GROUP BY ").concat(groupby_column_name, ", ").concat(column_groupby_column_name, " LIMIT 0, 5000");
@@ -128,17 +128,18 @@ class Area extends ChartComponent {
128
128
 
129
129
  // point
130
130
  let point;
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
- });
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
+ }
142
143
  const area = this.chart.area().position('name*value').animate({
143
144
  appear: {
144
145
  animation: 'fadeIn',
@@ -165,8 +166,7 @@ class Area extends ChartComponent {
165
166
  });
166
167
  if (point) point.style({
167
168
  fillOpacity: 0.3,
168
- stroke: 0,
169
- opacity: 1
169
+ stroke: 0
170
170
  });
171
171
  this.chart.render();
172
172
  });
@@ -181,8 +181,7 @@ class Area extends ChartComponent {
181
181
  });
182
182
  if (point) point.style({
183
183
  fillOpacity: 1,
184
- stroke: 0,
185
- opacity: 0
184
+ stroke: 0
186
185
  });
187
186
  this.chart.render();
188
187
  });
@@ -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_THEME_COLOR, EMPTY_NAME } from '../../constants';
6
+ import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE, CHART_THEME_COLOR, CHART_TYPE, EMPTY_NAME } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  class LineGroup extends ChartComponent {
9
9
  constructor(props) {
@@ -19,9 +19,6 @@ 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
- });
25
22
  };
26
23
  this.clearChart = () => {
27
24
  this.chart.annotation().clear(true);
@@ -96,19 +93,23 @@ class LineGroup extends ChartComponent {
96
93
  };
97
94
  });
98
95
  let point;
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
- });
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
+ }
112
113
 
113
114
  // this.chart.on('tooltip:show', () => {
114
115
  // if (line.styleOption.cfg.opacity === 0.3) return;
@@ -19,9 +19,6 @@ 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
- });
25
22
  };
26
23
  this.clearChart = () => {
27
24
  this.chart.annotation().clear(true);
@@ -100,17 +97,21 @@ class Line extends ChartComponent {
100
97
  };
101
98
  });
102
99
  let point;
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
- });
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
+ }
114
115
 
115
116
  // this.chart.on('tooltip:show', () => {
116
117
  // if (line.styleOption.cfg.opacity === 0.3) return;
@@ -117,8 +117,16 @@ class PivotTableDisplayName extends React.Component {
117
117
  }
118
118
  case CellType.MULTIPLE_SELECT:
119
119
  {
120
+ const {
121
+ rowData
122
+ } = this.props;
123
+ const {
124
+ original_name,
125
+ name
126
+ } = rowData;
127
+ const newValue = original_name || name;
120
128
  const options = getColumnOptions(column);
121
- const validValue = Array.isArray(value) && value.length !== 0 ? value : [];
129
+ const validValue = Array.isArray(newValue) && newValue.length !== 0 ? newValue : [newValue];
122
130
  displayName = /*#__PURE__*/React.createElement("div", {
123
131
  className: "pivot-table-display-name-row"
124
132
  }, validValue.map(item => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.81-alpha.0",
3
+ "version": "0.0.81-alpha2",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",