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
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import { getTableById, getTableColumnByKey, getNumberDisplayString } from 'dtable-utils';
5
- import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, TITLE_AMOUNT, TITLE_INCREASE } from '../../constants';
5
+ import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, TITLE_AMOUNT, TITLE_INCREASE, CHART_THEME_COLOR } from '../../constants';
6
6
  import { BaseUtils } from '../../utils/chart-utils';
7
7
  import intl from '../../intl';
8
8
  import ChartComponent from './chart-component';
@@ -42,8 +42,10 @@ class Compare extends ChartComponent {
42
42
  this.draw = data => {
43
43
  const {
44
44
  chart,
45
- theme
45
+ globalTheme,
46
+ chartColorTheme
46
47
  } = this.props;
48
+ const theme = CHART_THEME_COLOR[globalTheme];
47
49
  const {
48
50
  table_id,
49
51
  y_axis_summary_type,
@@ -78,16 +80,14 @@ class Compare extends ChartComponent {
78
80
  type: 'cat'
79
81
  }
80
82
  });
81
- const currentTheme = BaseUtils.getCurrentTheme();
82
- const themeColors = this.getThemeColors(theme);
83
83
  this.chart.interval().label(display_data ? 'formatted_value' : false, {
84
84
  style: {
85
85
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
86
- fill: themeColors.textColor,
86
+ fill: theme.textColor,
87
87
  stroke: '#fff',
88
88
  lineWidth: 1
89
89
  }
90
- }).position('name*value').color('group_name', currentTheme && currentTheme.colors).tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
90
+ }).position('name*value').color('group_name', BaseUtils.getCurrentTheme(chartColorTheme).colors).tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
91
91
  const nameContent = !raw_name && typeof raw_name !== 'number' ? intl.get(EMPTY_NAME) : raw_name;
92
92
  const titleContent = y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]);
93
93
  return {
@@ -105,17 +105,17 @@ class Compare extends ChartComponent {
105
105
  this.setNameLabelAndTooltip(theme, this.labelCount);
106
106
  if (display_increase) {
107
107
  this.drawIncreaseLine({
108
- themeColors
108
+ theme
109
109
  });
110
110
  }
111
- this.setAxis(themeColors);
112
- this.setLegend('group_name', themeColors);
111
+ this.setAxis(theme);
112
+ this.setLegend('group_name', theme);
113
113
  this.chart.interaction('active-region');
114
114
  this.chart.removeInteraction('legend-filter');
115
115
  };
116
116
  this.drawIncreaseLine = _ref => {
117
117
  let {
118
- themeColors
118
+ theme
119
119
  } = _ref;
120
120
  const {
121
121
  chart
@@ -139,7 +139,7 @@ class Compare extends ChartComponent {
139
139
  format: 'percent'
140
140
  }),
141
141
  style: {
142
- fill: themeColors.textColor
142
+ fill: theme.textColor
143
143
  }
144
144
  };
145
145
  }).color(increase_line_color || '#fbd44a').position('name*increase_value').size(3).tooltip('name*increase_value', (name, value) => {
@@ -156,15 +156,15 @@ class Compare extends ChartComponent {
156
156
  grid: null
157
157
  });
158
158
  };
159
- this.setAxis = themeColors => {
159
+ this.setAxis = theme => {
160
160
  this.chart.axis('name', {
161
161
  line: {
162
- style: themeColors.gridColor
162
+ style: theme.gridColor
163
163
  },
164
164
  label: {
165
165
  autoRotate: true,
166
166
  style: {
167
- fill: themeColors.textColor
167
+ fill: theme.textColor
168
168
  },
169
169
  formatter: this.labelFormatter
170
170
  }
@@ -172,13 +172,13 @@ class Compare extends ChartComponent {
172
172
  this.chart.axis('value', {
173
173
  label: {
174
174
  style: {
175
- fill: themeColors.textColor
175
+ fill: theme.textColor
176
176
  }
177
177
  },
178
178
  grid: {
179
179
  line: {
180
180
  style: {
181
- stroke: themeColors.gridColor
181
+ stroke: theme.gridColor
182
182
  }
183
183
  }
184
184
  }
@@ -269,7 +269,8 @@ Compare.propTypes = {
269
269
  summaryColumn: PropTypes.object,
270
270
  result: PropTypes.array,
271
271
  tables: PropTypes.array,
272
- theme: PropTypes.object,
272
+ globalTheme: PropTypes.string,
273
+ chartColorTheme: PropTypes.string,
273
274
  toggleRecords: PropTypes.func
274
275
  };
275
276
  export default Compare;
@@ -3,7 +3,7 @@ import React, { useEffect, useRef } from 'react';
3
3
  import { maxBy } from 'lodash-es';
4
4
  import { BaseUtils, isBoolean } from '../../utils';
5
5
  import intl from '../../intl';
6
- import { CHART_STYLE_COLORS, CHART_TYPE } from '../../constants';
6
+ import { CHART_STYLE_COLORS, CHART_TYPE, CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  export default function Completeness(props) {
9
9
  var _chartRef$current, _chartRef$current2;
@@ -50,8 +50,10 @@ export default function Completeness(props) {
50
50
  const {
51
51
  chart,
52
52
  summaryColumn,
53
- theme
53
+ globalTheme,
54
+ chartColorTheme
54
55
  } = props;
56
+ const theme = CHART_THEME_COLOR[globalTheme];
55
57
  const {
56
58
  label_font_size,
57
59
  column_groupby_column_key,
@@ -59,14 +61,15 @@ export default function Completeness(props) {
59
61
  } = chart.config;
60
62
  const isGroup = type === CHART_TYPE.COMPLETENESS_GROUP ? true : false;
61
63
  let currentIdx = 0;
64
+ const colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
62
65
  const colorMap = data.reduce((acc, cur) => {
63
66
  if (cur.groupby && !acc[cur.groupby]) {
64
- acc[cur.groupby] = CHART_STYLE_COLORS[currentIdx++ % CHART_STYLE_COLORS.length];
67
+ acc[cur.groupby] = colors[currentIdx++ % colors.length];
65
68
  }
66
69
  return acc;
67
70
  }, {});
68
71
  const cb1 = group_name => {
69
- return group_name === 'rest' ? '#bdbdbd' : undefined;
72
+ return group_name === 'rest' ? '#bdbdbd' : colors[0];
70
73
  };
71
74
  const cb2 = (groupby, group_name) => {
72
75
  if (group_name === 'rest') {
@@ -75,7 +78,7 @@ export default function Completeness(props) {
75
78
  if (isGroup && column_groupby_column_key) {
76
79
  return colorMap[groupby];
77
80
  }
78
- return CHART_STYLE_COLORS[0];
81
+ return colors[0];
79
82
  };
80
83
  const colorField = isGroup ? 'groupby*group_name' : 'group_name';
81
84
  const colorFieldCb = isGroup ? cb2 : cb1;
@@ -2,6 +2,7 @@ import React, { Component } from 'react';
2
2
  import { isNumber } from 'dtable-utils';
3
3
  import { Chart, registerShape } from '../../utils/custom-g2';
4
4
  import { BaseUtils, isFunction } from '../../utils';
5
+ import { CHART_THEME_COLOR } from '../../constants';
5
6
  class Dashboard extends Component {
6
7
  constructor() {
7
8
  super(...arguments);
@@ -11,11 +12,12 @@ class Dashboard extends Component {
11
12
  this.drawChart = () => {
12
13
  const {
13
14
  chart,
14
- theme,
15
+ globalTheme,
15
16
  canvasStyle,
16
17
  result,
17
18
  customRender
18
19
  } = this.props;
20
+ const theme = CHART_THEME_COLOR[globalTheme];
19
21
  const value = isNumber(result) ? result : 0;
20
22
  const {
21
23
  config
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { debounce, maxBy, throttle } from 'lodash-es';
4
4
  import classNames from 'classnames';
5
- import { CHART_TYPE, EMPTY_NAME } from '../../constants';
5
+ import { CHART_TYPE, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
6
6
  import { BaseUtils, isFunction } from '../../utils';
7
7
  import intl from '../../intl';
8
8
  import HorizontalComponent from './horizontal-component';
@@ -54,8 +54,10 @@ class HorizontalBarGroup extends HorizontalComponent {
54
54
  const {
55
55
  chart,
56
56
  summaryColumn,
57
- theme
57
+ globalTheme,
58
+ chartColorTheme
58
59
  } = this.props;
60
+ const theme = CHART_THEME_COLOR[globalTheme];
59
61
  const {
60
62
  horizontal_axis_summary_method,
61
63
  display_data,
@@ -88,7 +90,7 @@ class HorizontalBarGroup extends HorizontalComponent {
88
90
  type: 'dodge',
89
91
  marginRatio: 0
90
92
  };
91
- this.setColorMap(data);
93
+ this.setColorMap(data, chartColorTheme);
92
94
  this.chart.interval().animate({
93
95
  // custom update animation
94
96
  update: {
@@ -206,7 +208,8 @@ HorizontalBarGroup.propTypes = {
206
208
  summaryColumn: PropTypes.object,
207
209
  result: PropTypes.array,
208
210
  tables: PropTypes.array,
209
- theme: PropTypes.object,
211
+ globalTheme: PropTypes.string,
212
+ chartColorTheme: PropTypes.string,
210
213
  toggleRecords: PropTypes.func,
211
214
  customRender: PropTypes.func
212
215
  };
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, TYPE_COLOR_USING, CHART_STYLE_COLORS } from '../../constants';
4
+ import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, TYPE_COLOR_USING, CHART_STYLE_COLORS, CHART_THEME_COLOR } from '../../constants';
5
5
  import { BaseUtils, isFunction } from '../../utils';
6
6
  import { getLabelColor, getConvertedColorRules } from '../../utils/color-utils';
7
7
  import intl from '../../intl';
@@ -45,9 +45,10 @@ class HorizontalBar extends HorizontalComponent {
45
45
  const {
46
46
  chart,
47
47
  summaryColumn,
48
- theme,
49
- themeName
48
+ globalTheme,
49
+ chartColorTheme
50
50
  } = this.props;
51
+ const theme = CHART_THEME_COLOR[globalTheme];
51
52
  const {
52
53
  horizontal_axis_summary_type,
53
54
  horizontal_axis_summary_method,
@@ -63,8 +64,8 @@ class HorizontalBar extends HorizontalComponent {
63
64
  const singleBarWidth = Math.round(chartHeight / (2 * data.length));
64
65
  const singleBarRadius = Math.min(singleBarWidth / 5, 10);
65
66
  let chartBarColor = horizontal_axis_label_color || CHART_STYLE_COLORS[0];
66
- if (themeName) {
67
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
67
+ if (chartColorTheme) {
68
+ chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
68
69
  }
69
70
  const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && horizontal_axis_label_color_rules && getConvertedColorRules(horizontal_axis_label_color_rules);
70
71
  data.reverse();
@@ -150,7 +151,8 @@ HorizontalBar.propTypes = {
150
151
  summaryColumn: PropTypes.object,
151
152
  result: PropTypes.array,
152
153
  tables: PropTypes.array,
153
- theme: PropTypes.object,
154
+ globalTheme: PropTypes.string,
155
+ chartColorTheme: PropTypes.string,
154
156
  toggleRecords: PropTypes.func
155
157
  };
156
158
  export default HorizontalBar;
@@ -1,5 +1,5 @@
1
1
  import React, { useCallback } from 'react';
2
- import { CHART_TYPE, CHART_THEME_COLOR } from '../../constants';
2
+ import { CHART_TYPE, THEME_NAME_MAP } from '../../constants';
3
3
  import { BaseUtils } from '../../utils';
4
4
  import Table from './table';
5
5
  import Bar from './bar';
@@ -30,7 +30,9 @@ const Wrapper = _ref => {
30
30
  chart,
31
31
  tables,
32
32
  customRender,
33
- canvasStyle
33
+ canvasStyle,
34
+ globalTheme,
35
+ chartColorTheme
34
36
  } = _ref;
35
37
  // const [statisticRecords, setStatisticRecords] = useState({});
36
38
  // const [isStatisticRecordsDialogShow, setIsStatisticRecordsDialogShow] = useState(false);
@@ -61,7 +63,8 @@ const Wrapper = _ref => {
61
63
  groupbyColumn,
62
64
  columnGroupbyColumn,
63
65
  summaryColumn,
64
- theme: CHART_THEME_COLOR['light'],
66
+ globalTheme,
67
+ chartColorTheme,
65
68
  toggleRecords: toggleStatisticRecordsDialog
66
69
  };
67
70
  switch (type) {
@@ -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 } from '../../constants';
6
+ import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE, CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  class LineGroup extends ChartComponent {
9
9
  constructor(props) {
@@ -46,8 +46,10 @@ class LineGroup extends ChartComponent {
46
46
  const {
47
47
  chart,
48
48
  summaryColumn,
49
- theme
49
+ globalTheme,
50
+ chartColorTheme
50
51
  } = this.props;
52
+ const theme = CHART_THEME_COLOR[globalTheme];
51
53
  const {
52
54
  y_axis_show_value,
53
55
  label_font_size,
@@ -58,6 +60,7 @@ class LineGroup extends ChartComponent {
58
60
  const chartBarColor = this.groupName;
59
61
  const newData = this.getChartGroupData(data);
60
62
  this.drawLabels(newData);
63
+ this.setColorMap(data, chartColorTheme);
61
64
  const isSmooth = line_type === CHART_LINE_TYPES[1];
62
65
 
63
66
  // set Coord type
@@ -81,7 +84,9 @@ class LineGroup extends ChartComponent {
81
84
  duration: 1000,
82
85
  easing: 'easeLinear'
83
86
  }
84
- }).position('name*value').color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').style({
87
+ }).position('name*value').color(chartBarColor, group_name => {
88
+ return this.colorMap[group_name];
89
+ }).shape(isSmooth ? 'smooth' : 'line').style({
85
90
  lineWidth: 2,
86
91
  opacity: 1
87
92
  }).tooltip('group_name*name*value', (group_name, name, value) => {
@@ -93,7 +98,9 @@ class LineGroup extends ChartComponent {
93
98
  });
94
99
  let point;
95
100
  if (y_axis_show_value) {
96
- point = this.chart.point().position('name*value').color(chartBarColor).animate({
101
+ point = this.chart.point().position('name*value').color(chartBarColor, group_name => {
102
+ return this.colorMap[group_name];
103
+ }).animate({
97
104
  appear: {
98
105
  animation: 'fadeIn',
99
106
  duration: 1000,
@@ -179,7 +186,8 @@ LineGroup.propTypes = {
179
186
  summaryColumn: PropTypes.object,
180
187
  result: PropTypes.array,
181
188
  tables: PropTypes.array,
182
- theme: PropTypes.object,
189
+ globalTheme: PropTypes.string,
190
+ chartColorTheme: PropTypes.string,
183
191
  toggleRecords: PropTypes.func,
184
192
  customRender: PropTypes.func
185
193
  };
@@ -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 } from '../../constants';
6
+ import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE, CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  class Line extends ChartComponent {
9
9
  constructor(props) {
@@ -45,10 +45,11 @@ class Line extends ChartComponent {
45
45
  this.draw = data => {
46
46
  const {
47
47
  chart,
48
- theme,
49
- themeName,
48
+ globalTheme,
49
+ chartColorTheme,
50
50
  summaryColumn
51
51
  } = this.props;
52
+ const theme = CHART_THEME_COLOR[globalTheme];
52
53
  const {
53
54
  y_axis_label_color,
54
55
  y_axis_show_value,
@@ -58,8 +59,8 @@ class Line extends ChartComponent {
58
59
  y_axis_summary_method
59
60
  } = chart.config;
60
61
  let chartBarColor = y_axis_label_color || '#5B8FF9';
61
- if (themeName) {
62
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
62
+ if (chartColorTheme) {
63
+ chartBarColor = BaseUtils.getCurrentTheme(chartColorTheme).colors[0];
63
64
  }
64
65
  this.drawLabels(data);
65
66
  const isSmooth = line_type === CHART_LINE_TYPES[1];
@@ -176,7 +177,8 @@ Line.propTypes = {
176
177
  summaryColumn: PropTypes.object,
177
178
  result: PropTypes.array,
178
179
  tables: PropTypes.array,
179
- theme: PropTypes.object,
180
+ globalTheme: PropTypes.string,
181
+ chartColorTheme: PropTypes.string,
180
182
  toggleRecords: PropTypes.func,
181
183
  customRender: PropTypes.func
182
184
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS } from '../../constants';
3
+ import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS, CHART_THEME_COLOR } from '../../constants';
4
4
  import { BaseUtils, isFunction } from '../../utils';
5
5
  import intl from '../../intl';
6
6
  import ChartComponent from './chart-component';
@@ -31,10 +31,12 @@ class Pie extends ChartComponent {
31
31
  result: data,
32
32
  chart,
33
33
  tables,
34
- theme,
34
+ globalTheme,
35
+ chartColorTheme,
35
36
  summaryColumn,
36
37
  customRender
37
38
  } = this.props;
39
+ const theme = CHART_THEME_COLOR[globalTheme];
38
40
  if (data.length === 0) return;
39
41
  this.chart.coordinate('theta', {
40
42
  radius: 0.7
@@ -46,10 +48,11 @@ class Pie extends ChartComponent {
46
48
  label_font_size,
47
49
  summary_method
48
50
  } = chart.config;
51
+ const currentTheme = BaseUtils.getCurrentTheme(chartColorTheme);
49
52
  const {
50
53
  data: newData,
51
54
  colorSet
52
- } = BaseUtils.formatPieChartData(data, chart, tables);
55
+ } = BaseUtils.formatPieChartData(data, chart, tables, currentTheme);
53
56
  if (!Array.isArray(newData)) return;
54
57
  this.loadData(newData);
55
58
  this.chart.on('interval:click', e => {
@@ -131,8 +134,9 @@ class Pie extends ChartComponent {
131
134
  label_font_size
132
135
  } = this.props.chart.config;
133
136
  const {
134
- theme
137
+ globalTheme
135
138
  } = this.props;
139
+ const theme = CHART_THEME_COLOR[globalTheme];
136
140
  const item = evt.data.data;
137
141
  this.currentChart.label('name*value*percent', (name, value, percent) => {
138
142
  let displayValue;
@@ -165,8 +169,9 @@ class Pie extends ChartComponent {
165
169
  label_font_size
166
170
  } = this.props.chart.config;
167
171
  const {
168
- theme
172
+ globalTheme
169
173
  } = this.props;
174
+ const theme = CHART_THEME_COLOR[globalTheme];
170
175
  this.currentChart.label('value*percent', (value, percent) => {
171
176
  let displayValue = BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
172
177
  return {
@@ -232,7 +237,8 @@ Pie.propTypes = {
232
237
  summaryColumn: PropTypes.object,
233
238
  result: PropTypes.array,
234
239
  tables: PropTypes.array,
235
- theme: PropTypes.object,
240
+ globalTheme: PropTypes.string,
241
+ chartColorTheme: PropTypes.string,
236
242
  toggleRecords: PropTypes.func,
237
243
  customRender: PropTypes.func
238
244
  };
@@ -28,10 +28,12 @@ class Ring extends ChartComponent {
28
28
  result: data,
29
29
  chart,
30
30
  tables,
31
- theme,
31
+ globalTheme,
32
+ chartColorTheme,
32
33
  summaryColumn,
33
34
  customRender
34
35
  } = this.props;
36
+ const theme = CHART_THEME_COLOR[globalTheme];
35
37
  const radius = 0.7;
36
38
  const innerRadius = 0.8;
37
39
  if (data.length === 0) return;
@@ -48,11 +50,12 @@ class Ring extends ChartComponent {
48
50
  summary_method,
49
51
  label_format
50
52
  } = chart.config;
53
+ const colorTheme = BaseUtils.getCurrentTheme(chartColorTheme);
51
54
  const {
52
55
  data: newData,
53
56
  colorSet,
54
57
  total
55
- } = BaseUtils.formatPieChartData(data, chart, tables);
58
+ } = BaseUtils.formatPieChartData(data, chart, tables, colorTheme);
56
59
  if (!Array.isArray(newData)) return;
57
60
  this.sum = total;
58
61
  this.loadData(newData);
@@ -135,7 +138,7 @@ class Ring extends ChartComponent {
135
138
  this.setAnnotation({
136
139
  name: intl.get('Total'),
137
140
  value: BaseUtils.getSummaryValueDisplayString(summaryColumn, this.sum, summary_method)
138
- });
141
+ }, '', theme);
139
142
  this.chart.on('interval:mouseenter', evt => this.onEnterRingChart(evt, {
140
143
  summaryColumn,
141
144
  summaryMethod: summary_method
@@ -209,8 +212,9 @@ class Ring extends ChartComponent {
209
212
  label_font_size
210
213
  } = this.props.chart.config;
211
214
  const {
212
- theme
215
+ globalTheme
213
216
  } = this.props;
217
+ const theme = CHART_THEME_COLOR[globalTheme];
214
218
  const item = evt.data.data;
215
219
  this.chart.annotation().clear(true);
216
220
  this.currentChart.label('name*value*percent', (name, value, percent) => {
@@ -235,7 +239,7 @@ class Ring extends ChartComponent {
235
239
  this.setAnnotation(item, {
236
240
  summaryColumn,
237
241
  summaryMethod
238
- });
242
+ }, theme);
239
243
  this.chart.render(true);
240
244
  };
241
245
  this.onLeaveRingChart = (evt, _ref2) => {
@@ -248,8 +252,9 @@ class Ring extends ChartComponent {
248
252
  label_font_size
249
253
  } = this.props.chart.config;
250
254
  const {
251
- theme
255
+ globalTheme
252
256
  } = this.props;
257
+ const theme = CHART_THEME_COLOR[globalTheme];
253
258
  this.chart.annotation().clear(true);
254
259
  this.currentChart.label('value*percent', (value, percent) => {
255
260
  let displayValue = BaseUtils.getSummaryValueDisplayString(summaryColumn, value, summary_method);
@@ -271,7 +276,7 @@ class Ring extends ChartComponent {
271
276
  }, {
272
277
  summaryColumn,
273
278
  summaryMethod
274
- });
279
+ }, theme);
275
280
  this.chart.render(true);
276
281
  };
277
282
  this.sum = 0;
@@ -307,6 +312,8 @@ Ring.propTypes = {
307
312
  summaryColumn: PropTypes.object,
308
313
  result: PropTypes.array,
309
314
  tables: PropTypes.array,
315
+ globalTheme: PropTypes.string,
316
+ chartColorTheme: PropTypes.string,
310
317
  toggleRecords: PropTypes.func,
311
318
  customRender: PropTypes.func
312
319
  };
@@ -3,7 +3,7 @@ import React, { useEffect, useRef } from 'react';
3
3
  import { getTableById, getTableColumnByKey } from 'dtable-utils';
4
4
  import { BaseUtils } from '../../utils';
5
5
  import intl from '../../intl';
6
- import { CHART_STYLE_COLORS } from '../../constants';
6
+ import { CHART_THEME_COLOR } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  const chartComponent = new ChartComponent();
9
9
  export function Scatter(props) {
@@ -38,9 +38,11 @@ export function Scatter(props) {
38
38
  function draw(data) {
39
39
  const {
40
40
  chart,
41
- theme,
41
+ globalTheme,
42
+ chartColorTheme,
42
43
  tables
43
44
  } = props;
45
+ const theme = CHART_THEME_COLOR[globalTheme];
44
46
  const {
45
47
  label_font_size,
46
48
  x_axis_column_key,
@@ -53,9 +55,10 @@ export function Scatter(props) {
53
55
  const selectedYAxisColumn = getTableColumnByKey(selectedTable, y_axis_column_key);
54
56
  currentChart.drawLabels(data);
55
57
  let currentIdx = 0;
58
+ let colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
56
59
  const colorMap = data.reduce((acc, cur) => {
57
60
  if (cur.groupby && !acc[cur.groupby]) {
58
- acc[cur.groupby] = CHART_STYLE_COLORS[currentIdx++ % CHART_STYLE_COLORS.length];
61
+ acc[cur.groupby] = colors[currentIdx++ % colors.length];
59
62
  }
60
63
  return acc;
61
64
  }, {});
@@ -89,7 +92,7 @@ export function Scatter(props) {
89
92
  }
90
93
  }).color('groupby', groupby => {
91
94
  if (groupby && groupby[0] === 'groupby') {
92
- return CHART_STYLE_COLORS[0];
95
+ return colors[0];
93
96
  }
94
97
  return colorMap[groupby];
95
98
  }).shape('circle').tooltip('groupby*name*value', (groupby, name, value) => {
@@ -47,6 +47,7 @@ class Treemap extends ChartComponent {
47
47
  result: data,
48
48
  chart,
49
49
  tables,
50
+ chartColorTheme,
50
51
  summaryColumn,
51
52
  customRender
52
53
  } = this.props;
@@ -54,10 +55,11 @@ class Treemap extends ChartComponent {
54
55
  summary_type,
55
56
  summary_method
56
57
  } = chart.config;
58
+ let colorsTheme = BaseUtils.getCurrentTheme(chartColorTheme);
57
59
  const {
58
60
  data: newData,
59
61
  colorSet
60
- } = BaseUtils.formatPieChartData(data, chart, tables);
62
+ } = BaseUtils.formatPieChartData(data, chart, tables, colorsTheme);
61
63
  if (!Array.isArray(newData)) return;
62
64
  const {
63
65
  DataView
@@ -183,7 +185,8 @@ Treemap.propTypes = {
183
185
  summaryColumn: PropTypes.object,
184
186
  result: PropTypes.array,
185
187
  tables: PropTypes.array,
186
- theme: PropTypes.object,
188
+ globalTheme: PropTypes.string,
189
+ chartColorTheme: PropTypes.string,
187
190
  customRender: PropTypes.func
188
191
  };
189
192
  export default Treemap;