sea-chart 0.0.48 → 0.0.49

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.
Files changed (75) hide show
  1. package/dist/components/color-setting/color-group-selector.js +1 -0
  2. package/dist/components/types-dialog/index.js +2 -2
  3. package/dist/constants/common-constants.js +3 -0
  4. package/dist/constants/index.js +3 -0
  5. package/dist/context.js +9 -6
  6. package/dist/index.js +4 -1
  7. package/dist/locale/lang/en.js +1 -0
  8. package/dist/locale/lang/zh_CN.js +1 -0
  9. package/dist/model/chart.js +4 -0
  10. package/dist/settings/advance-bar-settings/style-settings.js +2 -0
  11. package/dist/settings/bar-settings/style-settings.js +2 -0
  12. package/dist/settings/basic-number-card/data-settings.js +3 -0
  13. package/dist/settings/combination-settings/style-settings.js +3 -0
  14. package/dist/settings/completeness-settings/data-settings/completion-settings.js +2 -0
  15. package/dist/settings/dashboard-settings/data-settings.js +3 -0
  16. package/dist/settings/horizontal-bar-settings/data-settings.js +2 -0
  17. package/dist/settings/index.js +3 -2
  18. package/dist/settings/map-settings/components/location-field-selector.js +1 -0
  19. package/dist/settings/map-settings/components/map-level-selector.js +1 -0
  20. package/dist/settings/map-settings/components/map-province-city-selector.js +2 -0
  21. package/dist/settings/map-settings/map-style-settings.js +1 -0
  22. package/dist/settings/pie-settings/style-settings.js +2 -0
  23. package/dist/settings/table-settings/data-settings.js +1 -0
  24. package/dist/settings/time-comparison-settings/style-settings.js +2 -0
  25. package/dist/settings/widgets/basic-summary/index.js +3 -0
  26. package/dist/settings/widgets/common-data-settings.js +1 -1
  27. package/dist/settings/widgets/date-summary-item.js +2 -0
  28. package/dist/settings/widgets/group-by.js +3 -0
  29. package/dist/settings/widgets/numeric-summary-item.js +2 -0
  30. package/dist/settings/widgets/select-table/index.js +1 -1
  31. package/dist/settings/widgets/select-view/index.js +1 -1
  32. package/dist/settings/widgets/summary-method-setting.js +2 -0
  33. package/dist/settings/widgets/summary-settings.js +4 -1
  34. package/dist/settings/widgets/y-axis-group-settings.js +1 -0
  35. package/dist/utils/chart-utils/base-utils.js +34 -9
  36. package/dist/utils/chart-utils/index.js +1 -1
  37. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +69 -16
  38. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +2 -2
  39. package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +9 -9
  40. package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
  41. package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +10 -10
  42. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +4 -4
  43. package/dist/utils/chart-utils/original-data-utils/index.js +3 -3
  44. package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +6 -6
  45. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +3 -3
  46. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +9 -9
  47. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +5 -5
  48. package/dist/utils/chart-utils/sql-statistics-utils.js +17 -6
  49. package/dist/utils/event-bus.js +28 -0
  50. package/dist/utils/row-utils.js +1 -1
  51. package/dist/utils/sql/chart-data-sql.js +17 -4
  52. package/dist/utils/sql/column-2-sql-column.js +7 -1
  53. package/dist/view/index.css +1 -1
  54. package/dist/view/index.js +49 -7
  55. package/dist/view/wrapper/area.js +16 -9
  56. package/dist/view/wrapper/bar-custom.js +8 -9
  57. package/dist/view/wrapper/bar-group.js +7 -4
  58. package/dist/view/wrapper/bar.js +8 -6
  59. package/dist/view/wrapper/basic-number-card.js +3 -2
  60. package/dist/view/wrapper/chart-component.js +6 -2
  61. package/dist/view/wrapper/combination.js +7 -7
  62. package/dist/view/wrapper/compare.js +18 -17
  63. package/dist/view/wrapper/completeness.js +8 -5
  64. package/dist/view/wrapper/dashboard.js +3 -1
  65. package/dist/view/wrapper/horizontal-bar-group.js +7 -4
  66. package/dist/view/wrapper/horizontal-bar.js +8 -6
  67. package/dist/view/wrapper/index.js +6 -3
  68. package/dist/view/wrapper/line-group.js +13 -5
  69. package/dist/view/wrapper/line.js +8 -6
  70. package/dist/view/wrapper/pie.js +12 -6
  71. package/dist/view/wrapper/ring.js +14 -7
  72. package/dist/view/wrapper/scatter.js +7 -4
  73. package/dist/view/wrapper/treemap.js +5 -2
  74. package/dist/view/wrapper/trend.js +124 -54
  75. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
1
  var _SQLStatisticsUtils;
2
2
  import dayjs from 'dayjs';
3
- import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber } from 'dtable-utils';
3
+ import { CellType, MULTIPLE_CELL_VALUE_COLUMN_TYPE_MAP, getFormulaDisplayString, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, DateUtils } from 'dtable-utils';
4
4
  import { isObject } from 'lodash';
5
- import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, LABEL_COLORS, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS } from '../../constants';
5
+ import { CHART_SUMMARY_TYPE, CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES, TABLE_DIMENSIONS, Y_AXIS_TYPE_PREFIX, STYLE_COLORS } from '../../constants';
6
6
  import { chartColumn2SqlColumn, summaryMethodColumn2SqlColumn } from '../sql';
7
7
  import { getClientLinkDisplayString } from '../cell-format-utils';
8
8
  import context from '../../context';
@@ -14,7 +14,7 @@ import BaseUtils from './base-utils';
14
14
  class SQLStatisticsUtils {}
15
15
  _SQLStatisticsUtils = SQLStatisticsUtils;
16
16
  SQLStatisticsUtils.dataSources = 'sql_statistics';
17
- SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables) => {
17
+ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables, dateGranularity) => {
18
18
  const collaborators = context.getCollaboratorsFromCache();
19
19
  const {
20
20
  type,
@@ -22,11 +22,21 @@ SQLStatisticsUtils.getGroupLabelFromDB = (cellValue, column, tables) => {
22
22
  } = column;
23
23
  switch (type) {
24
24
  case CellType.TEXT:
25
+ {
26
+ return cellValue || null;
27
+ }
25
28
  case CellType.DATE:
26
29
  case CellType.CTIME:
27
30
  case CellType.MTIME:
28
31
  {
29
- return cellValue || null;
32
+ if (!dateGranularity) {
33
+ return cellValue || null;
34
+ }
35
+ if (dateGranularity.toUpperCase() === 'QUARTER') {
36
+ // TODO: fix the unknown word 'QUARTAR'
37
+ return DateUtils.getDateByGranularity(cellValue, 'QUARTAR');
38
+ }
39
+ return DateUtils.getDateByGranularity(cellValue, dateGranularity);
30
40
  }
31
41
  case CellType.NUMBER:
32
42
  {
@@ -830,7 +840,8 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
830
840
  x_axis_compared_date_range_end,
831
841
  y_axis_summary_type,
832
842
  y_axis_summary_method,
833
- display_increase
843
+ display_increase,
844
+ x_axis_date_granularity
834
845
  } = config;
835
846
  const groupName1 = "".concat(x_axis_date_range_start, " - ").concat(x_axis_date_range_end);
836
847
  const groupName2 = "".concat(x_axis_compared_date_range_start, " - ").concat(x_axis_compared_date_range_end);
@@ -839,7 +850,7 @@ SQLStatisticsUtils.compareSQLResult2Javascript = (chart, sqlRows, chartSQLMap, c
839
850
  const isAdvanced = y_axis_summary_type === CHART_SUMMARY_TYPE.ADVANCED;
840
851
  sqlRows.forEach(item => {
841
852
  const name = item[sqlGroupbyColumnKey];
842
- const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, tables);
853
+ const label = _SQLStatisticsUtils.getGroupLabelFromDB(name, groupbyColumn, tables, x_axis_date_granularity);
843
854
  const value = item[sqlSummaryColumnKey];
844
855
  if (name >= x_axis_date_range_start && name <= x_axis_date_range_end) {
845
856
  const currentValue = dateRangeResult.get(label);
@@ -0,0 +1,28 @@
1
+ class EventBus {
2
+ constructor() {
3
+ this.subscribers = {};
4
+ }
5
+ subscribe(type, handler) {
6
+ if (!this.subscribers[type]) {
7
+ this.subscribers[type] = [];
8
+ }
9
+ const handlers = this.subscribers[type];
10
+ handlers.push(handler);
11
+ return () => {
12
+ const index = handlers.indexOf(handler);
13
+ if (index > -1) {
14
+ handlers.splice(index, 1);
15
+ }
16
+ };
17
+ }
18
+ dispatch(type) {
19
+ for (var _len = arguments.length, data = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
20
+ data[_key - 1] = arguments[_key];
21
+ }
22
+ const handlers = this.subscribers[type];
23
+ if (Array.isArray(handlers)) {
24
+ handlers.forEach(handler => handler(...data));
25
+ }
26
+ }
27
+ }
28
+ export default new EventBus();
@@ -32,7 +32,7 @@ export const getFormattedLabel = (column, name, collaborators) => {
32
32
  let {
33
33
  type: columnType,
34
34
  data: columnData
35
- } = column;
35
+ } = column || {};
36
36
  if (columnType === CellType.SINGLE_SELECT || columnType === CellType.MULTIPLE_SELECT) {
37
37
  let options = columnData ? columnData.options : [];
38
38
  let selectedOption = options.find(o => {
@@ -1,4 +1,5 @@
1
1
  import { CellType, filter2SqlCondition, isNumericColumn, isDateColumn } from 'dtable-utils';
2
+ import dayjs from 'dayjs';
2
3
  import { getSqlGroup } from '../column-utils';
3
4
  import { CHART_TYPE, DTABLE_DB_SUMMARY_METHOD, CHART_SUMMARY_TYPE, CHART_Y_GROUP_TYPE } from '../../constants';
4
5
  import { fixGeoGranularity } from '../map';
@@ -311,11 +312,14 @@ class ChartDataSQL {
311
312
  this._compare_chart_statistic_2_sql = () => {
312
313
  const {
313
314
  x_axis_column_key,
314
- x_axis_date_granularity,
315
315
  x_axis_geolocation_granularity,
316
316
  y_axis_summary_type,
317
317
  y_axis_summary_column_key,
318
- y_axis_summary_method
318
+ y_axis_summary_method,
319
+ x_axis_date_range_start,
320
+ x_axis_date_range_end,
321
+ x_axis_compared_date_range_start,
322
+ x_axis_compared_date_range_end
319
323
  } = this.chart;
320
324
  const groupby_column = this._get_column_by_key(x_axis_column_key);
321
325
  if (!groupby_column) {
@@ -324,7 +328,7 @@ class ChartDataSQL {
324
328
  }
325
329
  this._update_filter_sql(true, groupby_column);
326
330
  const groupby_column_name = this._chart_column_name_to_sql(groupby_column, {
327
- 'date_granularity': x_axis_date_granularity,
331
+ 'date_granularity': 'day',
328
332
  'geolocation_granularity': x_axis_geolocation_granularity
329
333
  });
330
334
  let summary_column_name = this._summary_column_2_sql('COUNT', groupby_column);
@@ -336,7 +340,16 @@ class ChartDataSQL {
336
340
  }
337
341
  summary_column_name = this._summary_column_2_sql(y_axis_summary_method.toUpperCase(), summary_column);
338
342
  }
339
- 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");
343
+
344
+ // filter
345
+ let filter_sql = this.filter_sql;
346
+ if (x_axis_date_range_start && x_axis_date_range_end && x_axis_compared_date_range_start && x_axis_compared_date_range_end) {
347
+ filter_sql = this.filter_sql.length === 0 ? 'where ' : this.filter_sql + ' AND';
348
+ const formattedXAxisDateRangeEnd = dayjs(x_axis_date_range_end).add(1, 'days').format('YYYY-MM-DD');
349
+ const formattedXAxisComparedDateRangeEnd = dayjs(x_axis_compared_date_range_end).add(1, 'days').format('YYYY-MM-DD');
350
+ filter_sql = filter_sql + " ((".concat(groupby_column.name, " >= '").concat(x_axis_date_range_start, "' AND ").concat(groupby_column.name, " < '").concat(formattedXAxisDateRangeEnd, "') Or (").concat(groupby_column.name, " >= '").concat(x_axis_compared_date_range_start, "' AND ").concat(groupby_column.name, " < '").concat(formattedXAxisComparedDateRangeEnd, "'))");
351
+ }
352
+ return "SELECT ".concat(groupby_column_name, ", ").concat(summary_column_name, " FROM ").concat(this.table_name, " ").concat(filter_sql, " GROUP BY ").concat(groupby_column_name, " LIMIT 0, 5000");
340
353
  };
341
354
  this._combination_chart_statistic_2_sql = () => {
342
355
  const x_axis_column_key = this.chart['x_axis_column_key'] || '';
@@ -281,16 +281,22 @@ const pieChartStatisticColumn2sqlColumn = (chart, table) => {
281
281
  };
282
282
  };
283
283
  const basicChartStatisticColumn2sqlColumn = (chart, table) => {
284
+ let {
285
+ x_axis_date_granularity
286
+ } = chart;
284
287
  const {
288
+ type,
285
289
  x_axis_column_key,
286
290
  y_axis_summary_type,
287
291
  y_axis_summary_method,
288
292
  y_axis_summary_column_key,
289
- x_axis_date_granularity,
290
293
  x_axis_geolocation_granularity
291
294
  } = chart;
292
295
  const groupbyColumn = getTableColumnByKey(table, x_axis_column_key);
293
296
  if (!groupbyColumn) return {};
297
+ if (type === CHART_TYPE.COMPARE_BAR) {
298
+ x_axis_date_granularity = 'DAY';
299
+ }
294
300
  const {
295
301
  key: sqlGroupbyColumnKey
296
302
  } = column2SqlColumn(groupbyColumn, {
@@ -86,7 +86,7 @@
86
86
 
87
87
  .sea-chart-formatter .statistic-chart-loading-container {
88
88
  position: absolute;
89
- width: calc(100% - 318px);
89
+ width: 100%;
90
90
  height: 100%;
91
91
  z-index: 101;
92
92
  display: flex;
@@ -6,6 +6,7 @@ import context from '../context';
6
6
  import intl from '../intl';
7
7
  import { Loading } from '../components';
8
8
  import { ChartUtils, BaseUtils } from '../utils/chart-utils';
9
+ import { THEME_NAME_MAP } from '../constants';
9
10
  import Title from './title';
10
11
  import Wrapper from './wrapper';
11
12
  import './index.css';
@@ -51,19 +52,41 @@ class View extends React.PureComponent {
51
52
  };
52
53
  this.calculateStatistic = function () {
53
54
  let isNeedRequestData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
55
+ let data_sources = arguments.length > 1 ? arguments[1] : undefined;
54
56
  const {
55
57
  tables,
56
- chart
58
+ chart,
59
+ isCalculateByView
57
60
  } = _this.props;
58
61
  const {
59
62
  data
60
63
  } = _this.state;
61
64
  const collaborators = context.getCollaboratorsFromCache();
65
+ if (isCalculateByView) {
66
+ if (BaseUtils.isArchiveView(chart.config, tables)) {
67
+ ChartUtils.calculateChart(chart, {
68
+ tables,
69
+ collaborators
70
+ }, _this.callback);
71
+ } else {
72
+ ChartUtils.calculateStaticChart(chart, {
73
+ tables,
74
+ collaborators
75
+ }, {
76
+ ...data,
77
+ data_sources: 'original_data'
78
+ }, _this.callback);
79
+ }
80
+ return;
81
+ }
62
82
  if (!isNeedRequestData) {
63
83
  ChartUtils.calculateStaticChart(chart, {
64
84
  tables,
65
85
  collaborators
66
- }, data, _this.callback);
86
+ }, {
87
+ ...data,
88
+ data_sources
89
+ }, _this.callback);
67
90
  return;
68
91
  }
69
92
  ChartUtils.calculateChart(chart, {
@@ -78,6 +101,7 @@ class View extends React.PureComponent {
78
101
  tipMessage: ''
79
102
  };
80
103
  context.init(props);
104
+ props.onViewRef && props.onViewRef(this);
81
105
  const lang = context.getSetting('lang') || 'zh-cn';
82
106
  intl.setLang(lang);
83
107
  }
@@ -99,6 +123,10 @@ class View extends React.PureComponent {
99
123
  this.calculateStatistic();
100
124
  return;
101
125
  }
126
+ if (BaseUtils.isChartViewChange(chart, oldChart)) {
127
+ this.calculateStatistic();
128
+ return;
129
+ }
102
130
  if (BaseUtils.isChartStyleChange(chart, oldChart)) {
103
131
  this.setState({
104
132
  isCalculated: true
@@ -119,7 +147,10 @@ class View extends React.PureComponent {
119
147
  className,
120
148
  tables,
121
149
  canvasStyle,
122
- render
150
+ render,
151
+ hideTitle = false,
152
+ globalTheme,
153
+ chartColorTheme
123
154
  } = this.props;
124
155
  const {
125
156
  data,
@@ -154,7 +185,7 @@ class View extends React.PureComponent {
154
185
  className: validClassName
155
186
  }, /*#__PURE__*/React.createElement("div", {
156
187
  className: classnames('sea-chart-formatter-container', "sea-chart-".concat(chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type, "-formatter-container"))
157
- }, /*#__PURE__*/React.createElement(Title, {
188
+ }, !hideTitle && /*#__PURE__*/React.createElement(Title, {
158
189
  chart: chart
159
190
  }), /*#__PURE__*/React.createElement("div", {
160
191
  className: "sea-chart-cavans-container"
@@ -163,7 +194,9 @@ class View extends React.PureComponent {
163
194
  data: data,
164
195
  tables: tables,
165
196
  canvasStyle: canvasStyle,
166
- customRender: render
197
+ customRender: render,
198
+ globalTheme: globalTheme ? globalTheme : THEME_NAME_MAP.LIGHT,
199
+ chartColorTheme: chartColorTheme
167
200
  }))));
168
201
  }
169
202
  }
@@ -175,7 +208,14 @@ const propTypes = {
175
208
  tables: PropTypes.array.isRequired,
176
209
  className: PropTypes.string,
177
210
  collaboratorManager: PropTypes.object,
178
- render: PropTypes.func // User-defined rendering content
211
+ hideTitle: PropTypes.bool,
212
+ globalTheme: PropTypes.string,
213
+ // light or dark
214
+ chartColorTheme: PropTypes.string,
215
+ isCalculateByView: PropTypes.bool,
216
+ render: PropTypes.func,
217
+ // User-defined rendering content
218
+ onViewRef: PropTypes.func
179
219
  };
180
220
  const defaultProps = {
181
221
  canvasStyle: {},
@@ -185,7 +225,9 @@ const defaultProps = {
185
225
  config: {},
186
226
  style_config: {}
187
227
  },
188
- collaborators: []
228
+ collaborators: [],
229
+ globalTheme: THEME_NAME_MAP.LIGHT,
230
+ isCalculateByView: false
189
231
  };
190
232
  View.defaultProps = defaultProps;
191
233
  export default View;
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
3
  import classNames from 'classnames';
4
- import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
4
+ import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE, CHART_THEME_COLOR } from '../../constants';
5
5
  import intl from '../../intl';
6
6
  import { BaseUtils, isFunction } from '../../utils';
7
7
  import ChartComponent from './chart-component';
@@ -57,10 +57,11 @@ class Area extends ChartComponent {
57
57
  const {
58
58
  chart,
59
59
  summaryColumn,
60
- theme,
60
+ globalTheme,
61
61
  customRender,
62
- themeName
62
+ chartColorTheme
63
63
  } = this.props;
64
+ const theme = CHART_THEME_COLOR[globalTheme];
64
65
  const {
65
66
  y_axis_summary_type,
66
67
  y_axis_summary_method,
@@ -72,12 +73,17 @@ class Area extends ChartComponent {
72
73
  const newData = this.getChartGroupData(data);
73
74
  const isSmooth = line_type === CHART_LINE_TYPES[1];
74
75
  let chartBarColor;
76
+ let colorCallBack = null;
75
77
  if (this.isGroupChart) {
78
+ this.setColorMap(data, chartColorTheme);
76
79
  chartBarColor = this.groupName;
80
+ colorCallBack = group_name => {
81
+ return this.colorMap[group_name];
82
+ };
77
83
  this.drawLabels(newData);
78
84
  } else {
79
- if (themeName) {
80
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
85
+ if (chartColorTheme) {
86
+ chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
81
87
  } else {
82
88
  chartBarColor = y_axis_label_color || '#5B8FF9';
83
89
  }
@@ -111,7 +117,7 @@ class Area extends ChartComponent {
111
117
  duration: 1000,
112
118
  easing: 'easeLinear'
113
119
  }
114
- }).color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').tooltip(false).style({
120
+ }).color(chartBarColor, colorCallBack).shape(isSmooth ? 'smooth' : 'line').tooltip(false).style({
115
121
  lineWidth: 2,
116
122
  opacity: 1
117
123
  });
@@ -125,7 +131,7 @@ class Area extends ChartComponent {
125
131
  duration: 1000,
126
132
  easing: 'easeLinear'
127
133
  }
128
- }).position('name*value').color(chartBarColor).shape('circle').size(4).style({
134
+ }).position('name*value').color(chartBarColor, colorCallBack).shape('circle').size(4).style({
129
135
  stroke: 0,
130
136
  fillOpacity: 1
131
137
  });
@@ -136,7 +142,7 @@ class Area extends ChartComponent {
136
142
  duration: 1000,
137
143
  easing: 'easeLinear'
138
144
  }
139
- }).shape(isSmooth ? 'smooth' : 'area').color(chartBarColor).tooltip('group_name*name*value', (group_name, name, value) => {
145
+ }).shape(isSmooth ? 'smooth' : 'area').color(chartBarColor, colorCallBack).tooltip('group_name*name*value', (group_name, name, value) => {
140
146
  return {
141
147
  title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
142
148
  value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
@@ -229,7 +235,8 @@ Area.propTypes = {
229
235
  summaryColumn: PropTypes.object,
230
236
  result: PropTypes.array,
231
237
  tables: PropTypes.array,
232
- theme: PropTypes.object,
238
+ globalTheme: PropTypes.string,
239
+ chartColorTheme: PropTypes.string,
233
240
  toggleRecords: PropTypes.func,
234
241
  customRender: PropTypes.func
235
242
  };
@@ -5,7 +5,7 @@ import { debounce, maxBy } from 'lodash-es';
5
5
  import classNames from 'classnames';
6
6
  import intl from '../../intl';
7
7
  import { BaseUtils } from '../../utils/chart-utils';
8
- import { EMPTY_NAME } from '../../constants';
8
+ import { EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
9
9
  import ChartComponent from './chart-component';
10
10
  class BarCustom extends ChartComponent {
11
11
  constructor(props) {
@@ -71,9 +71,10 @@ class BarCustom extends ChartComponent {
71
71
  this.draw = data => {
72
72
  const {
73
73
  chart,
74
- theme,
75
- themeName
74
+ globalTheme,
75
+ chartColorTheme
76
76
  } = this.props;
77
+ const theme = CHART_THEME_COLOR[globalTheme];
77
78
  const {
78
79
  label_font_size,
79
80
  display_each_block_data
@@ -120,12 +121,10 @@ class BarCustom extends ChartComponent {
120
121
  type: 'cat'
121
122
  }
122
123
  });
123
- const currentTheme = BaseUtils.getCurrentTheme(themeName);
124
- const themeColors = this.getThemeColors();
125
124
  let labelCfg = {
126
125
  style: {
127
126
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
128
- fill: themeColors.labelColor,
127
+ fill: theme.labelColor,
129
128
  stroke: '#fff',
130
129
  lineWidth: 1
131
130
  }
@@ -133,8 +132,7 @@ class BarCustom extends ChartComponent {
133
132
  if (displayData) {
134
133
  labelCfg.position = 'middle';
135
134
  }
136
- const groupColorCallback = currentTheme && currentTheme.colors;
137
- this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', groupColorCallback).size(singleBarWidth).tooltip('name*formatted_value*group_name*raw_name', (name, value, group_name, raw_name) => {
135
+ this.chart.interval().label(displayData ? 'formatted_value' : false, labelCfg).position('name*value').color('group_name', BaseUtils.getCurrentTheme(chartColorTheme).colors).size(singleBarWidth).tooltip('name*formatted_value*group_name*raw_name', (name, value, group_name, raw_name) => {
138
136
  let nameContent = group_name;
139
137
  if (!group_name && typeof group_name !== 'number') {
140
138
  nameContent = intl.get(EMPTY_NAME);
@@ -214,7 +212,8 @@ BarCustom.propTypes = {
214
212
  summaryColumn: PropTypes.object,
215
213
  result: PropTypes.array,
216
214
  tables: PropTypes.array,
217
- theme: PropTypes.object,
215
+ globalTheme: PropTypes.string,
216
+ chartColorTheme: PropTypes.string,
218
217
  toggleRecords: PropTypes.func
219
218
  };
220
219
  export default BarCustom;
@@ -6,7 +6,7 @@ import { debounce, maxBy, throttle } from 'lodash-es';
6
6
  import classNames from 'classnames';
7
7
  import intl from '../../intl';
8
8
  import { sortDataByGroupSum } from '../../utils/column-utils';
9
- import { EMPTY_NAME, CHART_TYPE, CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT } from '../../constants';
9
+ import { EMPTY_NAME, CHART_TYPE, CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT, CHART_THEME_COLOR } from '../../constants';
10
10
  import { BaseUtils, isFunction } from '../../utils';
11
11
  import ChartComponent from './chart-component';
12
12
  class BarGroup extends ChartComponent {
@@ -64,7 +64,8 @@ class BarGroup extends ChartComponent {
64
64
  const {
65
65
  chart,
66
66
  summaryColumn,
67
- theme,
67
+ globalTheme,
68
+ chartColorTheme,
68
69
  customRender
69
70
  } = this.props;
70
71
  const {
@@ -75,6 +76,7 @@ class BarGroup extends ChartComponent {
75
76
  display_each_block_data,
76
77
  y_axis_summary_type
77
78
  } = chart.config;
79
+ const theme = CHART_THEME_COLOR[globalTheme];
78
80
  const isGroup = type === CHART_TYPE.BAR_GROUP;
79
81
  const chartBarColor = this.groupName;
80
82
  const newData = this.getChartGroupData(data);
@@ -137,7 +139,7 @@ class BarGroup extends ChartComponent {
137
139
  type: 'dodge',
138
140
  marginRatio: 0
139
141
  };
140
- this.setColorMap(data);
142
+ this.setColorMap(data, chartColorTheme);
141
143
  this.chart.interval().animate({
142
144
  // custom update animation
143
145
  update: {
@@ -257,7 +259,8 @@ BarGroup.propTypes = {
257
259
  summaryColumn: PropTypes.object,
258
260
  result: PropTypes.array,
259
261
  tables: PropTypes.array,
260
- theme: PropTypes.object,
262
+ globalTheme: PropTypes.string,
263
+ chartColorTheme: PropTypes.string,
261
264
  toggleRecords: PropTypes.func,
262
265
  customRender: PropTypes.func
263
266
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { debounce } from 'lodash-es';
4
4
  import classNames from 'classnames';
5
- import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, TYPE_COLOR_USING, CHART_STYLE_COLORS } from '../../constants';
5
+ import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, TYPE_COLOR_USING, CHART_STYLE_COLORS, CHART_THEME_COLOR } from '../../constants';
6
6
  import { BaseUtils, isFunction } from '../../utils';
7
7
  import { getLabelColor, getConvertedColorRules } from '../../utils/color-utils';
8
8
  import intl from '../../intl';
@@ -49,10 +49,11 @@ class Bar extends ChartComponent {
49
49
  const {
50
50
  chart,
51
51
  summaryColumn,
52
- theme,
52
+ globalTheme,
53
53
  customRender,
54
- themeName
54
+ chartColorTheme
55
55
  } = this.props;
56
+ const theme = CHART_THEME_COLOR[globalTheme];
56
57
  const {
57
58
  y_axis_summary_type,
58
59
  y_axis_summary_method,
@@ -67,8 +68,8 @@ class Bar extends ChartComponent {
67
68
  const singleBarWidth = Math.round(chartWidth / (2 * data.length));
68
69
  const singleBarRadius = Math.min(singleBarWidth / 5, 10);
69
70
  let chartBarColor = y_axis_label_color || CHART_STYLE_COLORS[0];
70
- if (themeName) {
71
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
71
+ if (chartColorTheme) {
72
+ chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
72
73
  }
73
74
  const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && getConvertedColorRules(y_axis_label_color_rules);
74
75
  this.drawLabels(data);
@@ -153,7 +154,8 @@ Bar.propTypes = {
153
154
  summaryColumn: PropTypes.object,
154
155
  result: PropTypes.array,
155
156
  tables: PropTypes.array,
156
- theme: PropTypes.object,
157
+ globalTheme: PropTypes.string,
158
+ chartColorTheme: PropTypes.string,
157
159
  toggleRecords: PropTypes.func,
158
160
  customRender: PropTypes.func
159
161
  };
@@ -3,7 +3,7 @@ import { isNumber } from 'dtable-utils';
3
3
  import { Chart } from '../../utils/custom-g2';
4
4
  import { BaseUtils, isFunction } from '../../utils';
5
5
  import intl from '../../intl';
6
- import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME } from '../../constants';
6
+ import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
7
7
  class BasicNumericCard extends Component {
8
8
  constructor() {
9
9
  super(...arguments);
@@ -12,11 +12,12 @@ class BasicNumericCard extends Component {
12
12
  };
13
13
  this.drawChart = () => {
14
14
  const {
15
- theme,
15
+ globalTheme,
16
16
  chart,
17
17
  result,
18
18
  customRender
19
19
  } = this.props;
20
+ const theme = CHART_THEME_COLOR[globalTheme];
20
21
  this.chart = new Chart({
21
22
  container: this.container,
22
23
  autoFit: true,
@@ -438,11 +438,15 @@ export default class ChartComponent extends Component {
438
438
  basicLegendConfig.itemName.style.fontSize = theme.fontSize;
439
439
  _this.chart.legend(legendName, basicLegendConfig);
440
440
  };
441
- this.setColorMap = data => {
441
+ this.setColorMap = (data, chartColorTheme) => {
442
442
  let currentIdx = 0;
443
+ let colors = CHART_STYLE_COLORS;
444
+ if (chartColorTheme) {
445
+ colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
446
+ }
443
447
  const colorMap = data.reduce((acc, cur) => {
444
448
  if (cur.group_name && !acc[cur.group_name]) {
445
- acc[cur.group_name] = CHART_STYLE_COLORS[currentIdx++ % CHART_STYLE_COLORS.length];
449
+ acc[cur.group_name] = colors[currentIdx++ % colors.length];
446
450
  }
447
451
  return acc;
448
452
  }, {});
@@ -5,7 +5,7 @@ import { getTableById, getTableColumnByKey } from 'dtable-utils';
5
5
  import { throttle } from 'lodash-es';
6
6
  import { Chart } from '../../utils/custom-g2';
7
7
  import { BaseUtils, isFunction } from '../../utils';
8
- import { CHART_SUMMARY_TYPE, LABEL_COLORS, CHART_SUMMARY_SHOW, LABEL_POSITION_TYPE, EMPTY_NAME, CHART_LINE_TYPES, CHART_STYLE_COLORS } from '../../constants';
8
+ import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, LABEL_POSITION_TYPE, EMPTY_NAME, CHART_LINE_TYPES, CHART_STYLE_COLORS, CHART_THEME_COLOR } from '../../constants';
9
9
  import intl from '../../intl';
10
10
  import ChartComponent from './chart-component';
11
11
  class Combination extends ChartComponent {
@@ -25,11 +25,12 @@ class Combination extends ChartComponent {
25
25
  if (!Array.isArray(data)) return;
26
26
  const {
27
27
  chart,
28
- theme,
28
+ globalTheme,
29
29
  tables,
30
- themeName,
30
+ chartColorTheme,
31
31
  customRender
32
32
  } = this.props;
33
+ const theme = CHART_THEME_COLOR[globalTheme];
33
34
  const {
34
35
  table_id,
35
36
  y_axis_left_summary_column,
@@ -45,7 +46,6 @@ class Combination extends ChartComponent {
45
46
  y_axis_auto_range_right,
46
47
  y_axis_min_right,
47
48
  y_axis_max_right,
48
- x_axis_column_key,
49
49
  display_data,
50
50
  label_font_size,
51
51
  line_type
@@ -79,7 +79,7 @@ class Combination extends ChartComponent {
79
79
  }, ['', -Infinity])[0];
80
80
  const singleBarWidth = Math.round(chartWidth / (2 * nameNums * mostCommonCount));
81
81
  const singleBarRadius = Math.min(singleBarWidth / 5, 10);
82
- const currentTheme = BaseUtils.getCurrentTheme(themeName);
82
+ const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
83
83
  this.colorMap = data.reduce((acc, cur, index) => {
84
84
  if (!acc[cur.group_name]) {
85
85
  acc[cur.group_name] = cur.color;
@@ -675,13 +675,13 @@ class Combination extends ChartComponent {
675
675
  }
676
676
  }
677
677
  Combination.propTypes = {
678
- themeName: PropTypes.string,
679
678
  canvasStyle: PropTypes.object,
680
679
  chart: PropTypes.object,
681
680
  summaryColumn: PropTypes.object,
682
681
  result: PropTypes.array,
683
682
  tables: PropTypes.array,
684
- theme: PropTypes.object,
683
+ globalTheme: PropTypes.string,
684
+ chartColorTheme: PropTypes.string,
685
685
  toggleRecords: PropTypes.func,
686
686
  customRender: PropTypes.func
687
687
  };