sea-chart 2.0.37 → 2.0.38

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 (304) hide show
  1. package/dist/api/index.js +20 -69
  2. package/dist/assets/css/sea-chart-d3-tooltip.css +0 -1
  3. package/dist/components/cell-factory/FormatterConfig.js +55 -62
  4. package/dist/components/cell-factory/SimpleCellFormatter.js +5 -12
  5. package/dist/components/cell-factory/SingleSelectOption.js +11 -18
  6. package/dist/components/cell-factory/cell-editor-factory.js +5 -12
  7. package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
  8. package/dist/components/cell-factory/link-content.js +30 -38
  9. package/dist/components/chart-color-selector/color-selector.js +11 -18
  10. package/dist/components/collaborator/index.js +7 -14
  11. package/dist/components/color-picker/index.js +12 -19
  12. package/dist/components/color-popover/color-rules/color-rule.js +26 -34
  13. package/dist/components/color-popover/color-rules/index.js +7 -15
  14. package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
  15. package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
  16. package/dist/components/color-popover/color-rules/rule-filters/number-input.js +9 -17
  17. package/dist/components/color-popover/color-rules-popover.js +31 -37
  18. package/dist/components/color-popover/color-selector-popover.js +12 -20
  19. package/dist/components/color-setting/color-group-selector.js +13 -21
  20. package/dist/components/common-add-tool/index.js +8 -15
  21. package/dist/components/data-process-setter/data-setting-header.js +7 -14
  22. package/dist/components/data-process-setter/hide-column-setter.js +13 -20
  23. package/dist/components/data-process-setter/index.js +4 -27
  24. package/dist/components/data-process-setter/sort-setter.js +18 -26
  25. package/dist/components/draggable/Draggable.js +7 -13
  26. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +41 -48
  27. package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
  28. package/dist/components/drill-down-settings/index.js +11 -18
  29. package/dist/components/dtable-popover/index.js +13 -20
  30. package/dist/components/dtable-search-input/index.js +13 -21
  31. package/dist/components/font-settings/index.js +14 -22
  32. package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
  33. package/dist/components/goal-line-setting/index.js +12 -19
  34. package/dist/components/highlighter/highlighter.js +7 -14
  35. package/dist/components/icon/index.js +12 -23
  36. package/dist/components/index.js +7 -48
  37. package/dist/components/loading/index.js +6 -13
  38. package/dist/components/number-input/index.js +11 -24
  39. package/dist/components/pixel-editor/index.js +15 -23
  40. package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +13 -16
  41. package/dist/components/popover/hide-column-popover/hide-column-popover.css +5 -1
  42. package/dist/components/popover/hide-column-popover/hide-column-popover.js +28 -38
  43. package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
  44. package/dist/components/popover/sort-popover/sort-popover.js +58 -69
  45. package/dist/components/resize-handle/ResizeHandle.js +6 -13
  46. package/dist/components/row-card/row-card-header-cell.js +17 -24
  47. package/dist/components/row-card/row-card-header.js +15 -22
  48. package/dist/components/row-card/row-card-item.js +35 -43
  49. package/dist/components/row-card/row-card.js +17 -25
  50. package/dist/components/statistic-record-dialog/index.js +61 -68
  51. package/dist/components/tooltip/index.js +39 -28
  52. package/dist/components/types-dialog/index.js +62 -70
  53. package/dist/components/types-dialog/use-force-update.js +4 -10
  54. package/dist/constants/color-rules.js +8 -14
  55. package/dist/constants/common-constants.js +8 -14
  56. package/dist/constants/error.js +2 -8
  57. package/dist/constants/geolocation.js +9 -15
  58. package/dist/constants/index.js +142 -271
  59. package/dist/constants/key-codes.js +0 -2
  60. package/dist/constants/model.js +3 -9
  61. package/dist/constants/regions.js +3 -8
  62. package/dist/constants/style.js +6 -12
  63. package/dist/constants/table.js +1 -7
  64. package/dist/constants/type-image.js +33 -39
  65. package/dist/constants/type.js +3 -9
  66. package/dist/context.js +13 -20
  67. package/dist/editor/index.js +13 -16
  68. package/dist/index.js +13 -104
  69. package/dist/intl.js +10 -17
  70. package/dist/locale/index.js +16 -23
  71. package/dist/locale/lang/de.js +2 -7
  72. package/dist/locale/lang/en.js +2 -7
  73. package/dist/locale/lang/es.js +2 -7
  74. package/dist/locale/lang/fr.js +2 -7
  75. package/dist/locale/lang/pt.js +2 -7
  76. package/dist/locale/lang/ru.js +2 -7
  77. package/dist/locale/lang/zh_CN.js +2 -7
  78. package/dist/model/area-group.js +12 -19
  79. package/dist/model/area.js +12 -19
  80. package/dist/model/bar-custom.js +11 -18
  81. package/dist/model/bar-group.js +12 -19
  82. package/dist/model/bar-stack.js +10 -17
  83. package/dist/model/bar.js +11 -18
  84. package/dist/model/base-model.js +4 -11
  85. package/dist/model/basic-number-card.js +13 -20
  86. package/dist/model/chart.js +7 -13
  87. package/dist/model/combination.js +15 -22
  88. package/dist/model/compare-bar.js +14 -21
  89. package/dist/model/completeness-group.js +11 -18
  90. package/dist/model/completeness.js +10 -17
  91. package/dist/model/dashboard.js +7 -14
  92. package/dist/model/funnel.js +14 -21
  93. package/dist/model/generic-model.js +135 -143
  94. package/dist/model/heat-map.js +9 -16
  95. package/dist/model/horizontal-bar.js +11 -18
  96. package/dist/model/horizontal-group-bar.js +10 -17
  97. package/dist/model/index.js +69 -93
  98. package/dist/model/line-group.js +13 -20
  99. package/dist/model/line.js +12 -19
  100. package/dist/model/map-bubble.js +14 -17
  101. package/dist/model/map.js +12 -19
  102. package/dist/model/mirror.js +13 -20
  103. package/dist/model/pie.js +12 -19
  104. package/dist/model/ring.js +12 -19
  105. package/dist/model/scatter.js +10 -17
  106. package/dist/model/stacked-horizontal-bar.js +11 -18
  107. package/dist/model/table-element.js +5 -12
  108. package/dist/model/table.js +7 -14
  109. package/dist/model/tree-map.js +7 -14
  110. package/dist/model/trend.js +11 -18
  111. package/dist/model/user.js +1 -7
  112. package/dist/model/world-map-bubble.js +12 -19
  113. package/dist/model/world-map.js +12 -19
  114. package/dist/services/map-json.js +14 -17
  115. package/dist/settings/advance-bar-settings/data-settings.js +36 -44
  116. package/dist/settings/advance-bar-settings/index.js +3 -20
  117. package/dist/settings/advance-bar-settings/style-settings.js +66 -73
  118. package/dist/settings/bar-settings/data-settings.js +39 -47
  119. package/dist/settings/bar-settings/index.js +3 -20
  120. package/dist/settings/bar-settings/style-settings.js +51 -59
  121. package/dist/settings/basic-number-card/data-settings.js +50 -57
  122. package/dist/settings/basic-number-card/index.js +3 -20
  123. package/dist/settings/basic-number-card/style-settings.js +19 -27
  124. package/dist/settings/combination-settings/data-settings.js +55 -64
  125. package/dist/settings/combination-settings/index.js +3 -20
  126. package/dist/settings/combination-settings/style-settings.js +67 -75
  127. package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
  128. package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
  129. package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
  130. package/dist/settings/completeness-settings/index.js +3 -20
  131. package/dist/settings/completeness-settings/style-settings.js +19 -26
  132. package/dist/settings/dashboard-settings/data-settings.js +44 -51
  133. package/dist/settings/dashboard-settings/index.js +2 -13
  134. package/dist/settings/data-settings.js +72 -79
  135. package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
  136. package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
  137. package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
  138. package/dist/settings/funnel-settings/components/funnel-layer-setting.js +22 -30
  139. package/dist/settings/funnel-settings/data-settings.js +23 -31
  140. package/dist/settings/funnel-settings/index.js +3 -20
  141. package/dist/settings/funnel-settings/style-settings.js +11 -19
  142. package/dist/settings/heat-map-settings/data-settings.js +18 -26
  143. package/dist/settings/heat-map-settings/index.js +3 -20
  144. package/dist/settings/heat-map-settings/style-settings.js +18 -26
  145. package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
  146. package/dist/settings/horizontal-bar-settings/index.js +3 -20
  147. package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
  148. package/dist/settings/index.js +57 -70
  149. package/dist/settings/map-settings/components/location-field-selector.js +10 -17
  150. package/dist/settings/map-settings/components/map-level-selector.js +11 -18
  151. package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
  152. package/dist/settings/map-settings/index.js +3 -20
  153. package/dist/settings/map-settings/map-data-settings.js +23 -30
  154. package/dist/settings/map-settings/map-style-settings.js +27 -35
  155. package/dist/settings/mirror-settings/data-settings.js +26 -34
  156. package/dist/settings/mirror-settings/index.js +2 -13
  157. package/dist/settings/pie-settings/data-settings.js +33 -41
  158. package/dist/settings/pie-settings/index.js +3 -20
  159. package/dist/settings/pie-settings/style-settings.js +47 -55
  160. package/dist/settings/scatter/data-settings.js +27 -34
  161. package/dist/settings/scatter/index.js +3 -12
  162. package/dist/settings/stacks-settings/index.js +19 -27
  163. package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
  164. package/dist/settings/style-settings.js +65 -73
  165. package/dist/settings/table-element-settings/components/data-filter.js +49 -58
  166. package/dist/settings/table-element-settings/data-settings.js +21 -29
  167. package/dist/settings/table-element-settings/index.css +1 -31
  168. package/dist/settings/table-element-settings/index.js +2 -13
  169. package/dist/settings/table-settings/data-settings.js +113 -120
  170. package/dist/settings/table-settings/index.js +2 -13
  171. package/dist/settings/time-comparison-settings/data-settings.js +43 -51
  172. package/dist/settings/time-comparison-settings/index.js +3 -20
  173. package/dist/settings/time-comparison-settings/style-settings.js +44 -52
  174. package/dist/settings/trend-settings/data-settings.js +24 -32
  175. package/dist/settings/trend-settings/index.js +3 -20
  176. package/dist/settings/trend-settings/style-setting.js +19 -27
  177. package/dist/settings/widgets/basic-summary/index.js +59 -66
  178. package/dist/settings/widgets/chart-type/index.js +18 -26
  179. package/dist/settings/widgets/color-settings/index.js +72 -80
  180. package/dist/settings/widgets/common-data-settings.js +27 -34
  181. package/dist/settings/widgets/data-filter/index.js +59 -59
  182. package/dist/settings/widgets/data-sort.js +16 -24
  183. package/dist/settings/widgets/date-summary-item.js +26 -34
  184. package/dist/settings/widgets/display-values-settings/index.js +14 -22
  185. package/dist/settings/widgets/divider/index.js +8 -16
  186. package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
  187. package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
  188. package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
  189. package/dist/settings/widgets/font-settings/index.js +4 -27
  190. package/dist/settings/widgets/group-by.js +52 -59
  191. package/dist/settings/widgets/min-max-setting.js +10 -18
  192. package/dist/settings/widgets/mininum-slice-percent.js +10 -18
  193. package/dist/settings/widgets/numeric-summary-item.js +25 -33
  194. package/dist/settings/widgets/select-line-type/index.js +10 -17
  195. package/dist/settings/widgets/select-table/index.js +9 -16
  196. package/dist/settings/widgets/select-view/index.js +20 -28
  197. package/dist/settings/widgets/stack.js +14 -22
  198. package/dist/settings/widgets/summary-method-setting.js +17 -25
  199. package/dist/settings/widgets/summary-settings.js +75 -82
  200. package/dist/settings/widgets/switch/index.js +9 -16
  201. package/dist/settings/widgets/text-horizontal-settings.js +15 -23
  202. package/dist/settings/widgets/time-picker.js +29 -37
  203. package/dist/settings/widgets/title-settings/index.js +29 -37
  204. package/dist/settings/widgets/title-settings/title-text.js +5 -12
  205. package/dist/settings/widgets/x-axios.js +0 -1
  206. package/dist/settings/widgets/y-axis-group-settings.js +65 -72
  207. package/dist/utils/cell-format-utils.js +25 -33
  208. package/dist/utils/cell-value-utils.js +4 -11
  209. package/dist/utils/chart-utils/base-utils.js +467 -367
  210. package/dist/utils/chart-utils/index.js +29 -40
  211. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +78 -85
  212. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +20 -21
  213. package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
  214. package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +21 -28
  215. package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +33 -40
  216. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +28 -26
  217. package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
  218. package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +19 -26
  219. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +94 -97
  220. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -25
  221. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +50 -36
  222. package/dist/utils/chart-utils/sql-statistics-utils.js +385 -388
  223. package/dist/utils/chart.js +9 -17
  224. package/dist/utils/collaborator-manager.js +3 -9
  225. package/dist/utils/collaborator-utils.js +19 -31
  226. package/dist/utils/collaborator.js +6 -15
  227. package/dist/utils/color-utils.js +18 -29
  228. package/dist/utils/column-utils.js +88 -102
  229. package/dist/utils/common-utils.js +28 -53
  230. package/dist/utils/concurrency-manager.js +1 -7
  231. package/dist/utils/contexts.js +7 -11
  232. package/dist/utils/date-translate.js +12 -20
  233. package/dist/utils/digital-sign-utils.js +7 -14
  234. package/dist/utils/event-bus.js +1 -7
  235. package/dist/utils/hotkey.js +5 -11
  236. package/dist/utils/index.js +73 -219
  237. package/dist/utils/key-generator.js +2 -9
  238. package/dist/utils/map.js +22 -31
  239. package/dist/utils/object-utils.js +2 -8
  240. package/dist/utils/options-utils.js +10 -18
  241. package/dist/utils/row-record-utils.js +251 -183
  242. package/dist/utils/row-utils.js +27 -38
  243. package/dist/utils/search.js +24 -32
  244. package/dist/utils/sql/chart-data-sql.js +106 -112
  245. package/dist/utils/sql/column-2-sql-column.js +162 -172
  246. package/dist/utils/sql/index.js +3 -27
  247. package/dist/utils/trend-utils.js +50 -45
  248. package/dist/view/index.css +2 -8
  249. package/dist/view/index.js +102 -103
  250. package/dist/view/title/index.js +16 -24
  251. package/dist/view/wrapper/area-group.js +57 -57
  252. package/dist/view/wrapper/area.js +43 -51
  253. package/dist/view/wrapper/bar-compare.js +56 -48
  254. package/dist/view/wrapper/bar-custom-stack.js +73 -55
  255. package/dist/view/wrapper/bar-group.js +94 -73
  256. package/dist/view/wrapper/bar-stack.js +49 -57
  257. package/dist/view/wrapper/bar.js +40 -48
  258. package/dist/view/wrapper/basic-number-card.js +50 -34
  259. package/dist/view/wrapper/chart-component.js +164 -569
  260. package/dist/view/wrapper/combination.js +55 -63
  261. package/dist/view/wrapper/completeness-group.js +140 -93
  262. package/dist/view/wrapper/completeness.js +36 -44
  263. package/dist/view/wrapper/dashboard.js +104 -59
  264. package/dist/view/wrapper/funnel.js +40 -43
  265. package/dist/view/wrapper/heat-map.js +62 -70
  266. package/dist/view/wrapper/horizontal-bar-group.js +70 -58
  267. package/dist/view/wrapper/horizontal-bar-stack.js +48 -56
  268. package/dist/view/wrapper/horizontal-bar.js +41 -49
  269. package/dist/view/wrapper/index.js +107 -115
  270. package/dist/view/wrapper/line-group.js +49 -52
  271. package/dist/view/wrapper/line.js +42 -50
  272. package/dist/view/wrapper/map-bubble.js +40 -48
  273. package/dist/view/wrapper/map-world-bubble.js +40 -47
  274. package/dist/view/wrapper/map-world.js +42 -49
  275. package/dist/view/wrapper/map.js +42 -50
  276. package/dist/view/wrapper/mirror.js +41 -49
  277. package/dist/view/wrapper/pie.js +45 -53
  278. package/dist/view/wrapper/ring.js +50 -58
  279. package/dist/view/wrapper/scatter.js +50 -56
  280. package/dist/view/wrapper/table/index.js +14 -22
  281. package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
  282. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +53 -61
  283. package/dist/view/wrapper/table/pivot-table-display-name.js +82 -90
  284. package/dist/view/wrapper/table/two-dimension-table.js +85 -92
  285. package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
  286. package/dist/view/wrapper/table-element/components/formatter.js +90 -99
  287. package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +23 -32
  288. package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
  289. package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +90 -97
  290. package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
  291. package/dist/view/wrapper/table-element/components/link-formatter.js +90 -97
  292. package/dist/view/wrapper/table-element/components/record.js +13 -20
  293. package/dist/view/wrapper/table-element/components/records-body.js +9 -17
  294. package/dist/view/wrapper/table-element/components/records-header/index.js +7 -16
  295. package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
  296. package/dist/view/wrapper/table-element/components/records.js +25 -33
  297. package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +8 -13
  298. package/dist/view/wrapper/table-element/components/utils.js +6 -16
  299. package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
  300. package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
  301. package/dist/view/wrapper/table-element/index.js +30 -43
  302. package/dist/view/wrapper/treemap.js +38 -46
  303. package/dist/view/wrapper/trend.js +80 -65
  304. package/package.json +15 -12
@@ -1,33 +1,26 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.default = void 0;
9
- var _react = _interopRequireWildcard(require("react"));
10
- var d3 = _interopRequireWildcard(require("d3"));
11
- var _lodashEs = require("lodash-es");
12
- var _dtableUtils = require("dtable-utils");
13
- var _utils = require("../../utils");
14
- var _constants = require("../../constants");
15
- var _style = require("../../constants/style");
16
- var _intl = _interopRequireDefault(require("../../intl"));
17
- require("../../assets/css/sea-chart-d3-tooltip.css");
18
- class ChartComponent extends _react.Component {
1
+ import React from 'react';
2
+ import { Component } from 'react';
3
+ import * as d3 from 'd3';
4
+ import { cloneDeep, debounce } from 'lodash-es';
5
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
6
+ import { BaseUtils, formatXAxisLabel } from '../../utils';
7
+ import { CHART_TYPE, CHART_SUMMARY_TYPE, LABEL_POSITION_TYPE, CHART_THEME_COLOR, EMPTY_NAME, THEME_NAME_MAP, CHART_STYLE_COLORS } from '../../constants';
8
+ import { FILL_BORDER_COLOR_MAP } from '../../constants/style';
9
+ import intl from '../../intl';
10
+ import '../../assets/css/sea-chart-d3-tooltip.css';
11
+ export default class ChartComponent extends Component {
19
12
  constructor(props) {
20
13
  var _this;
21
14
  super(props);
22
15
  _this = this;
23
16
  this.initLabelStroke = theme => {
24
- this.globalTheme = theme || _constants.THEME_NAME_MAP.LIGHT;
25
- this.labelStroke = theme === _constants.THEME_NAME_MAP.DARK ? {} : {
17
+ this.globalTheme = theme || THEME_NAME_MAP.LIGHT;
18
+ this.labelStroke = theme === THEME_NAME_MAP.DARK ? {} : {
26
19
  stroke: '#fff',
27
20
  lineWidth: 1
28
21
  };
29
22
  };
30
- this.handleResize = (0, _lodashEs.debounce)(() => {
23
+ this.handleResize = debounce(() => {
31
24
  if (!this.createChart || !this.drawChart) return;
32
25
  this.destroyChart();
33
26
  this.createChart();
@@ -37,14 +30,14 @@ class ChartComponent extends _react.Component {
37
30
  }
38
31
  }, 300);
39
32
  this.destroyChart = () => {
40
- this.chart.node() && this.chart.node().remove();
33
+ this.chart && this.chart.node() && this.chart.node().remove();
41
34
  };
42
35
  this.getTitle = (tables, table_id, yAxisType, yAxisKey) => {
43
- return yAxisType === _constants.CHART_SUMMARY_TYPE.COUNT ? _intl.default.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
36
+ return yAxisType === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
44
37
  };
45
38
  this.getColumn = (tables, table_id, columnKey) => {
46
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
47
- const column = (0, _dtableUtils.getTableColumnByKey)(table, columnKey) || {};
39
+ const table = getTableById(tables, table_id);
40
+ const column = getTableColumnByKey(table, columnKey) || {};
48
41
  return column;
49
42
  };
50
43
  this.getAxisLabel = (tables, tableId, columnKey) => {
@@ -85,7 +78,7 @@ class ChartComponent extends _react.Component {
85
78
  width,
86
79
  height
87
80
  } = this.chartBoundingClientRect;
88
- this.chart.append('defs').append('mask').attr('id', "mask-wrapper-".concat(previewType, "-").concat(this.chart.node().id)).append('rect').attr('x', 0).attr('y', 0).attr('width', width).attr('height', height - 30).attr('fill', 'white');
81
+ this.chart.append('defs').append('mask').attr('id', `mask-wrapper-${previewType}-${this.chart.node().id}`).append('rect').attr('x', 0).attr('y', 0).attr('width', width).attr('height', height - 30).attr('fill', 'white');
89
82
  }
90
83
  };
91
84
  this.getChartDisplayLabels = (containerWidth, minItemWidth, charts) => {
@@ -107,7 +100,7 @@ class ChartComponent extends _react.Component {
107
100
  if (item.group_name === 'rest' && isCompleteness) return;
108
101
  const groupData = chartGroupData.find(g => g.name === item.name);
109
102
  if (!groupData) {
110
- const newItem = (0, _lodashEs.cloneDeep)(item);
103
+ const newItem = cloneDeep(item);
111
104
  newItem.currentGroupCount = 1;
112
105
  chartGroupData.push(newItem);
113
106
  } else {
@@ -161,13 +154,13 @@ class ChartComponent extends _react.Component {
161
154
  // mark the first item in each group,but if item value is 0, mark the next item
162
155
  let targetMarkItem = item[0],
163
156
  i = 1;
164
- while (!((_targetMarkItem = targetMarkItem) !== null && _targetMarkItem !== void 0 && _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
157
+ while (!((_targetMarkItem = targetMarkItem) === null || _targetMarkItem === void 0 ? void 0 : _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
165
158
  var _targetMarkItem, _targetMarkItem2;
166
159
  targetMarkItem = item[i];
167
160
  i++;
168
161
  if (i >= item.length) break;
169
162
  }
170
- if (!((_targetMarkItem3 = targetMarkItem) !== null && _targetMarkItem3 !== void 0 && _targetMarkItem3.value)) return;
163
+ if (!((_targetMarkItem3 = targetMarkItem) === null || _targetMarkItem3 === void 0 ? void 0 : _targetMarkItem3.value)) return;
171
164
  targetMarkItem.isFirst = 1;
172
165
  } else if (position === 'last') {
173
166
  var _targetMarkItem6;
@@ -175,13 +168,13 @@ class ChartComponent extends _react.Component {
175
168
  const l = item.length;
176
169
  let targetMarkItem = item[l - 1],
177
170
  i = l - 2;
178
- while (!((_targetMarkItem4 = targetMarkItem) !== null && _targetMarkItem4 !== void 0 && _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
171
+ while (!((_targetMarkItem4 = targetMarkItem) === null || _targetMarkItem4 === void 0 ? void 0 : _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
179
172
  var _targetMarkItem4, _targetMarkItem5;
180
173
  targetMarkItem = item[i];
181
174
  i--;
182
175
  if (i < 0) break;
183
176
  }
184
- if (!((_targetMarkItem6 = targetMarkItem) !== null && _targetMarkItem6 !== void 0 && _targetMarkItem6.value)) return;
177
+ if (!((_targetMarkItem6 = targetMarkItem) === null || _targetMarkItem6 === void 0 ? void 0 : _targetMarkItem6.value)) return;
185
178
  targetMarkItem.isLast = 1;
186
179
  } else {
187
180
  console.error('on markFirstOrLast: unknown position');
@@ -213,22 +206,6 @@ class ChartComponent extends _react.Component {
213
206
  });
214
207
  });
215
208
  };
216
- this.drawLabels = function () {
217
- let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
218
- if (!_this.chart) return;
219
- const {
220
- width
221
- } = _this.chart.coordinateBBox;
222
- _this.labelCount = data.length;
223
- if (Math.floor(width / _this.labelCount) <= 20) {
224
- let displayLabels = _this.getChartDisplayLabels(width, 20, data);
225
- _this.labelCount = displayLabels.length;
226
- _this.chart.scale('name', {
227
- type: 'cat',
228
- ticks: displayLabels
229
- });
230
- }
231
- };
232
209
  this.renderAxisLabel = (chart, tables, chartContainer) => {
233
210
  if (!this.chart || !chart) return;
234
211
  let {
@@ -259,13 +236,13 @@ class ChartComponent extends _react.Component {
259
236
  if (y_axis_summary_column_key) {
260
237
  y_axis_column_key = y_axis_summary_column_key;
261
238
  }
262
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
239
+ const table = getTableById(tables, table_id);
263
240
  let textColor;
264
- this.globalTheme === _constants.THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
241
+ this.globalTheme === THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
265
242
 
266
243
  // xAxis
267
- const xAxisID = "chart-x-axis-label_".concat(chart.id);
268
- const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector("#".concat(xAxisID));
244
+ const xAxisID = `chart-x-axis-label_${chart.id}`;
245
+ const xLabel = chartContainer === null || chartContainer === void 0 ? void 0 : chartContainer.querySelector(`#${xAxisID}`);
269
246
  const {
270
247
  width: containerWidth
271
248
  } = this.chartBoundingClientRect;
@@ -273,32 +250,33 @@ class ChartComponent extends _react.Component {
273
250
  const div = document.createElement('div');
274
251
  div.id = xAxisID;
275
252
  div.className = 'chart-axis-label';
276
- const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
277
- div.innerHTML = "".concat(column ? column.name : '');
278
- div.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute; bottom: 0;"));
253
+ const column = getTableColumnByKey(table, x_axis_column_key);
254
+ div.innerHTML = `${column ? column.name : ''}`;
255
+ div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
279
256
  chartContainer.appendChild(div);
280
257
  }
281
258
  if (xLabel && x_axis_show_label) {
282
- xLabel.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(x_axis_label_position, "; position: absolute; bottom: 0;"));
259
+ xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
283
260
  }
284
261
  if (xLabel && !x_axis_show_label) {
285
262
  xLabel.parentNode.removeChild(xLabel);
286
263
  }
287
264
 
288
265
  // yAxis
289
- const yAxisID = "chart-y-axis-label_".concat(chart.id);
290
- const yLabel = chartContainer.querySelector("#".concat(yAxisID));
266
+ const yAxisID = `chart-y-axis-label_${chart.id}`;
267
+ const yLabel = chartContainer.querySelector(`#${yAxisID}`);
291
268
  const divHeight = 20;
292
269
  if (!yLabel && y_axis_show_label) {
293
270
  const div = document.createElement('div');
294
271
  div.id = yAxisID;
295
272
  div.className = 'chart-axis-label';
296
- if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
297
- div.innerHTML = _intl.default.get('Amount');
273
+ // SCATTER always has y_axis_column_key
274
+ if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT && type !== CHART_TYPE.SCATTER) {
275
+ div.innerHTML = intl.get('Amount');
298
276
  } else {
299
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
277
+ const column = getTableColumnByKey(table, y_axis_column_key) || {};
300
278
  div.innerHTML = column.name || '';
301
- if (type === _constants.CHART_TYPE.BAR_STACK) {
279
+ if (type === CHART_TYPE.BAR_STACK) {
302
280
  div.innerHTML = title_name || '';
303
281
  }
304
282
  }
@@ -306,9 +284,9 @@ class ChartComponent extends _react.Component {
306
284
  height: containerHeight
307
285
  } = this.chartBoundingClientRect;
308
286
  let textAlign = 'center';
309
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
310
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
311
- div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
287
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
288
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
289
+ div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
312
290
  chartContainer.appendChild(div);
313
291
  }
314
292
  if (yLabel && y_axis_show_label) {
@@ -316,32 +294,32 @@ class ChartComponent extends _react.Component {
316
294
  height: containerHeight
317
295
  } = this.chartBoundingClientRect;
318
296
  let textAlign = 'center';
319
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
320
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
321
- yLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
297
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
298
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
299
+ yLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
322
300
  }
323
301
  if (yLabel && !y_axis_show_label) {
324
302
  yLabel.parentNode.removeChild(yLabel);
325
303
  }
326
304
 
327
305
  // yAxis(left) - combination chart
328
- const yAxisLeftID = "chart-y-axis-left-label_".concat(chart.id);
329
- const yAxisLeftLabel = chartContainer.querySelector("#".concat(yAxisLeftID));
306
+ const yAxisLeftID = `chart-y-axis-left-label_${chart.id}`;
307
+ const yAxisLeftLabel = chartContainer.querySelector(`#${yAxisLeftID}`);
330
308
  if (!yAxisLeftLabel && show_y_axis_left_label) {
331
309
  const div = document.createElement('div');
332
310
  div.id = yAxisLeftID;
333
311
  div.className = 'chart-axis-label text-truncate';
334
- if (y_axis_left_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
335
- div.innerHTML = _intl.default.get('Amount');
312
+ if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
313
+ div.innerHTML = intl.get('Amount');
336
314
  } else {
337
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
315
+ const column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
338
316
  div.innerHTML = column.name || '';
339
317
  }
340
318
  const containerHeight = chartContainer.offsetHeight;
341
319
  let textAlign = 'center';
342
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
343
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
344
- div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
320
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
321
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
322
+ div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
345
323
  chartContainer.appendChild(div);
346
324
  }
347
325
  if (yAxisLeftLabel && show_y_axis_left_label) {
@@ -349,30 +327,30 @@ class ChartComponent extends _react.Component {
349
327
  let textAlign = 'center';
350
328
  if (y_axis_left_label_position === 'bottom') textAlign = 'left';
351
329
  if (y_axis_left_label_position === 'top') textAlign = 'right';
352
- yAxisLeftLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
330
+ yAxisLeftLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
353
331
  }
354
332
  if (yAxisLeftLabel && !show_y_axis_left_label) {
355
333
  yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
356
334
  }
357
335
 
358
336
  // yAxis(right) - combination chart
359
- const yAxisRightID = "chart-y-axis-right-label_".concat(chart.id);
360
- const yAxisRightLabel = chartContainer.querySelector("#".concat(yAxisRightID));
337
+ const yAxisRightID = `chart-y-axis-right-label_${chart.id}`;
338
+ const yAxisRightLabel = chartContainer.querySelector(`#${yAxisRightID}`);
361
339
  if (!yAxisRightLabel && show_y_axis_right_label) {
362
340
  const div = document.createElement('div');
363
341
  div.id = yAxisRightID;
364
342
  div.className = 'chart-axis-label text-truncate';
365
- if (y_axis_right_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
366
- div.innerHTML = _intl.default.get('Amount');
343
+ if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
344
+ div.innerHTML = intl.get('Amount');
367
345
  } else {
368
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
346
+ const column = getTableColumnByKey(table, y_axis_right_summary_column) || {};
369
347
  div.innerHTML = column.name || '';
370
348
  }
371
349
  const containerHeight = chartContainer.offsetHeight;
372
350
  let textAlign = 'center';
373
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
374
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
375
- div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
351
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
352
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
353
+ div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
376
354
  chartContainer.appendChild(div);
377
355
  }
378
356
  if (yAxisRightLabel && show_y_axis_right_label) {
@@ -380,7 +358,7 @@ class ChartComponent extends _react.Component {
380
358
  let textAlign = 'center';
381
359
  if (y_axis_right_label_position === 'bottom') textAlign = 'left';
382
360
  if (y_axis_right_label_position === 'top') textAlign = 'right';
383
- yAxisRightLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
361
+ yAxisRightLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: translate(${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
384
362
  }
385
363
  if (yAxisRightLabel && !show_y_axis_right_label) {
386
364
  yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
@@ -398,10 +376,10 @@ class ChartComponent extends _react.Component {
398
376
  show_vertical_axis_label,
399
377
  show_horizontal_axis_label
400
378
  } = chart.config;
401
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
379
+ const table = getTableById(tables, table_id);
402
380
  const textColor = '#999999';
403
- const xAxisID = "chart-x-axis-label_".concat(chart.id);
404
- const xLabel = chartContainer.querySelector("#".concat(xAxisID));
381
+ const xAxisID = `chart-x-axis-label_${chart.id}`;
382
+ const xLabel = chartContainer.querySelector(`#${xAxisID}`);
405
383
  const {
406
384
  width: containerWidth
407
385
  } = this.chartBoundingClientRect;
@@ -409,37 +387,37 @@ class ChartComponent extends _react.Component {
409
387
  const div = document.createElement('div');
410
388
  div.id = xAxisID;
411
389
  div.className = 'chart-axis-label';
412
- if (horizontal_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
413
- div.innerHTML = _intl.default.get('Amount');
390
+ if (horizontal_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
391
+ div.innerHTML = intl.get('Amount');
414
392
  } else {
415
- const column = (0, _dtableUtils.getTableColumnByKey)(table, horizontal_axis_column_key);
416
- div.innerHTML = "".concat(column ? column.name : '');
393
+ const column = getTableColumnByKey(table, horizontal_axis_column_key);
394
+ div.innerHTML = `${column ? column.name : ''}`;
417
395
  }
418
- div.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(horizontal_axis_label_position, "; position: absolute"));
396
+ div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
419
397
  chartContainer.appendChild(div);
420
398
  }
421
399
  if (xLabel && show_horizontal_axis_label) {
422
- xLabel.setAttribute('style', "color:".concat(textColor, "; width: ").concat(containerWidth, "px; text-align: ").concat(horizontal_axis_label_position, "; position: absolute"));
400
+ xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
423
401
  }
424
402
  if (xLabel && !show_horizontal_axis_label) {
425
403
  xLabel.parentNode.removeChild(xLabel);
426
404
  }
427
- const yAxisID = "chart-y-axis-label_".concat(chart.id);
428
- const yLabel = chartContainer.querySelector("#".concat(yAxisID));
405
+ const yAxisID = `chart-y-axis-label_${chart.id}`;
406
+ const yLabel = chartContainer.querySelector(`#${yAxisID}`);
429
407
  const divHeight = 20;
430
408
  if (!yLabel && show_vertical_axis_label) {
431
409
  const div = document.createElement('div');
432
410
  div.id = yAxisID;
433
411
  div.className = 'chart-axis-label';
434
- const column = (0, _dtableUtils.getTableColumnByKey)(table, vertical_axis_column_key) || {};
412
+ const column = getTableColumnByKey(table, vertical_axis_column_key) || {};
435
413
  div.innerHTML = column.name || '';
436
414
  const {
437
415
  height: containerHeight
438
416
  } = this.chartBoundingClientRect;
439
417
  let textAlign = 'center';
440
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
441
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
442
- div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
418
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
419
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
420
+ div.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
443
421
  chartContainer.appendChild(div);
444
422
  }
445
423
  if (yLabel && show_horizontal_axis_label) {
@@ -447,9 +425,9 @@ class ChartComponent extends _react.Component {
447
425
  height: containerHeight
448
426
  } = this.chartBoundingClientRect;
449
427
  let textAlign = 'center';
450
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
451
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
452
- yLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; height: ").concat(divHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 - divHeight / 2, "px, ").concat(containerHeight / 2 - divHeight / 2, "px) rotate(-90deg)"));
428
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
429
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
430
+ yLabel.setAttribute('style', `color:${textColor}; position: absolute; width: ${containerHeight}px; height: ${divHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: translate(-${containerHeight / 2 - divHeight / 2}px, ${containerHeight / 2 - divHeight / 2}px) rotate(-90deg)`);
453
431
  }
454
432
  if (yLabel && !show_horizontal_axis_label) {
455
433
  yLabel.parentNode.removeChild(yLabel);
@@ -461,288 +439,30 @@ class ChartComponent extends _react.Component {
461
439
  this.isShowHorizontalAxisLabel = chart => {
462
440
  return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
463
441
  };
464
- // Automatic adjustment of maximum and minimum values
465
- this.autoAdjustDataOptions = function (chart) {
466
- let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
467
- let summaryColumn = arguments.length > 2 ? arguments[2] : undefined;
468
- if (!_this.chart || !chart) return;
469
- let valueScaleOptions = {};
470
- const {
471
- config
472
- } = chart;
473
- const {
474
- y_axis_auto_range,
475
- y_axis_min,
476
- y_axis_max,
477
- y_axis_summary_method
478
- } = config;
479
- if (summaryColumn) {
480
- valueScaleOptions['formatter'] = value => {
481
- return _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
482
- };
483
- }
484
- if (y_axis_auto_range === undefined || y_axis_auto_range) {
485
- valueScaleOptions['nice'] = true;
486
- } else {
487
- valueScaleOptions['min'] = y_axis_min;
488
- valueScaleOptions['max'] = y_axis_max;
489
- // set the filter rule
490
- _this.chart.filter('value', value => {
491
- return value >= y_axis_min;
492
- });
493
- // filter the data
494
- _this.chart.filterData(data);
495
- }
496
- _this.chart.scale({
497
- name: {
498
- type: 'cat'
499
- },
500
- value: valueScaleOptions
501
- });
502
- };
503
- // set axis label and tooltip
504
- this.setNameLabelAndTooltip = function () {
505
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
506
- let labelCount = arguments.length > 1 ? arguments[1] : undefined;
507
- if (!_this.chart) return;
508
- _this.chart.axis('name', {
509
- line: {
510
- style: {
511
- stroke: theme.XAxisColor,
512
- lineWidth: 1
513
- }
514
- },
515
- tickLine: {
516
- length: 5,
517
- // color of the tick line
518
- stroke: theme.XAxisColor
519
- },
520
- label: {
521
- style: {
522
- fill: theme.textColor,
523
- fontSize: theme.fontSize
524
- },
525
- offset: 10,
526
- autoRotate: true,
527
- rotate: labelCount > 11 ? 0.3 : 0,
528
- formatter: name => {
529
- const isString = typeof name === 'string';
530
- if (!isString) name = String(name);
531
- if (name === 'undefined') {
532
- return _intl.default.get(_constants.EMPTY_NAME);
533
- }
534
- if (name.length > 10) {
535
- return (0, _utils.formatXAxisLabel)(name);
536
- }
537
- return name;
538
- }
539
- }
540
- });
541
- };
542
- // set value label
543
- this.setValueLabel = function () {
544
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
545
- if (!_this.chart) return;
546
- _this.chart.axis('value', {
547
- label: {
548
- offset: 6,
549
- style: {
550
- fontSize: theme.fontSize,
551
- fill: theme.textColor
552
- }
553
- },
554
- grid: {
555
- line: {
556
- style: {
557
- stroke: theme.gridColor,
558
- lineDash: [8, 3]
559
- }
560
- }
561
- }
562
- });
563
- };
564
- this.labelFormatter = name => {
565
- let label = name;
566
- if (name.length > 10) {
567
- label = "".concat(name.slice(0, 10), "...");
568
- }
569
- if (name === '' || name === 'undefined') {
570
- label = _intl.default.get(_constants.EMPTY_NAME);
571
- }
572
- return label;
573
- };
574
- this.getLegendConfig = function () {
575
- let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : _constants.CHART_THEME_COLOR['light'];
576
- let legendPosition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'top-right';
577
- return {
578
- // custom: true,
579
- position: legendPosition,
580
- itemName: {
581
- style: {
582
- // fill: theme.textColor,
583
- fill: theme.legendTextColor,
584
- fontSize: theme.legendFontSize
585
- },
586
- formatter: name => {
587
- if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
588
- return _intl.default.get(_constants.EMPTY_NAME);
589
- } else if (name === '_Others') {
590
- return _intl.default.get('Others');
591
- } else {
592
- return _intl.default.get(name) || name;
593
- }
594
- }
595
- },
596
- pageNavigator: {
597
- text: {
598
- style: {
599
- fill: theme.legendTextColor
600
- }
601
- },
602
- marker: {
603
- style: {
604
- fill: theme.legendPageNavigatorMarkerColor,
605
- inactiveFill: theme.legendPageNavigatorMarkerColor,
606
- inactiveOpacity: 0.45
607
- }
608
- }
609
- },
610
- itemHeight: 30,
611
- marker: {
612
- symbol:
613
- // 'square',
614
- // use cavans to custom legend,returns a path command array
615
- (x, y) => {
616
- x = x + 6;
617
- y = y - 1;
618
- // The total width of the capsule is 20px, and its height is 6px. Thus, the radius of the semi-circle is half the height, which is 3px.
619
- const r = 3;
620
- // The width of the rectangular part in the middle of the capsule is the total width minus the diameters of the two semi-circles, which is 14px.
621
- const rectWidth = 14;
622
- return [['M', x - rectWidth / 2, y - r],
623
- // Start from the left edge of the left semi-circle
624
- ['L', x + rectWidth / 2, y - r],
625
- // Draw the top line to the left edge of the right semi-circle
626
- ['A', r, r, 0, 0, 1, x + rectWidth / 2, y + r],
627
- // Draw the right semi-circle
628
- ['L', x - rectWidth / 2, y + r],
629
- // Draw the bottom line back to the right edge of the left semi-circle
630
- ['A', r, r, 0, 0, 1, x - rectWidth / 2, y - r] // Draw the left semi-circle
631
- ];
632
- },
633
- style: style => {
634
- // fill legend with stroke color
635
- if (style.stroke) {
636
- style.fill = style.stroke;
637
- }
638
- return style;
639
- },
640
- spacing: 15
641
- }
642
- };
643
- };
644
442
  this.formatterLegendName = name => {
645
443
  if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
646
- return _intl.default.get(_constants.EMPTY_NAME);
444
+ return intl.get(EMPTY_NAME);
647
445
  } else if (name === '_Others') {
648
- return _intl.default.get('Others');
446
+ return intl.get('Others');
649
447
  } else {
650
- return _intl.default.get(name) || name;
448
+ return intl.get(name) || name;
651
449
  }
652
450
  };
653
- // set legend for heat map
654
- this.setLegendForHeatMap = _ref => {
655
- let {
656
- exampleColors,
657
- themeColors
658
- } = _ref;
659
- const legendOffsetY = 3;
660
- const legendItemTextWidth = 32;
661
- const legendItemWidth = 12;
662
- const legendItemHeight = 12;
663
- const legendItemGap = 3;
664
- const legendItemRadius = 2;
665
- const legendWrapper = this.chart.append('g').attr('class', 'legend-heat-map-wrapper').attr('transform', "translate(0, ".concat(legendOffsetY, ")"));
666
-
667
- // less
668
- legendWrapper.append('text').attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('Less'));
669
- // rect
670
- exampleColors.forEach((color, index) => {
671
- legendWrapper.append('rect').attr('x', legendItemTextWidth + index * legendItemWidth + index * legendItemGap).attr('width', legendItemWidth).attr('height', legendItemHeight).attr('rx', legendItemRadius).attr('fill', color).attr('stroke', _style.FILL_BORDER_COLOR_MAP[color]).attr('stroke-width', 1);
672
- });
673
- // more
674
- legendWrapper.append('text').attr('x', 182).attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(_intl.default.get('More'));
675
- };
676
- // set continuous legend
677
- this.setContinuousLegend = _ref2 => {
678
- var _this$chart$node2;
679
- let {
680
- previewType,
681
- theme,
682
- colorRange = [],
683
- legendDirection,
684
- legendSize,
685
- legendTextRange,
686
- bubbleColor,
687
- type
688
- } = _ref2;
689
- const {
690
- width: chartWidth,
691
- height: chartHeight,
692
- insertPadding
693
- } = this.chartBoundingClientRect;
694
- const legendRectWidth = legendDirection === 'vertical' ? 12 : Math.min(legendSize * 100, chartWidth - insertPadding * 2);
695
- const legendRectHeight = legendDirection === 'vertical' ? Math.min(legendSize * 100, chartHeight - insertPadding * 2) : 12;
696
- const legendTextOffset = 2;
697
- const legendTextHeightSpace = legendDirection === 'vertical' ? 0 : 14 + legendTextOffset;
698
- if (![_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
699
- var _this$chart$node;
700
- // add linearGradient
701
- const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", "gradient-".concat((_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id, "-").concat(previewType)).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
702
- gradient.append('stop').attr('offset', '0%').attr('stop-color', "".concat(colorRange[0]));
703
- gradient.append('stop').attr('offset', '50%').attr('stop-color', "".concat(colorRange[4]));
704
- gradient.append('stop').attr('offset', '100%').attr('stop-color', "".concat(colorRange[8]));
705
- }
706
-
707
- // add legend
708
- const continuousLegendWrapper = this.chart.append('g').attr('class', 'legend-continuous-wrapper').attr('transform', "translate(0, ".concat(chartHeight - legendRectHeight - legendTextHeightSpace, ")"));
709
- continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', [_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type) ? bubbleColor : "url(#gradient-".concat((_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id, "-").concat(previewType, ")")).call(g => {
710
- if ([_constants.CHART_TYPE.MAP_BUBBLE, _constants.CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
711
- continuousLegendWrapper.append('polygon').attr('points', "0,0 ".concat(legendRectWidth - 0.5, ",0 0,").concat(legendRectHeight - 0.5)).attr('fill', '#fff').attr('stroke', '#fff');
712
- }
713
- });
714
- continuousLegendWrapper.append('text').attr('class', 'range-start').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[0]).call(g => {
715
- const {
716
- height
717
- } = g.node().getBoundingClientRect();
718
- g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendTextOffset);
719
- g.attr('y', legendDirection === 'vertical' ? height : height + legendRectHeight);
720
- });
721
- continuousLegendWrapper.append('text').attr('class', 'range-end').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).text(legendTextRange[1]).call(g => {
722
- const {
723
- width,
724
- height
725
- } = g.node().getBoundingClientRect();
726
- g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendRectWidth - width);
727
- g.attr('y', legendDirection === 'vertical' ? legendRectHeight - legendTextOffset : height + legendRectHeight);
728
- });
729
- };
730
- // set legend
731
- this.setLegend = _ref3 => {
451
+ this.setLegend = _ref => {
732
452
  var _chart$config, _chart$config2;
733
453
  let {
734
454
  legendName,
735
- theme = _constants.CHART_THEME_COLOR['light'],
455
+ theme = CHART_THEME_COLOR['light'],
736
456
  legendPosition = 'top-left',
737
457
  data,
738
458
  colorScale,
739
459
  groupColumn,
740
460
  chart
741
- } = _ref3;
461
+ } = _ref;
742
462
  if (!this.chart) return;
743
463
  this.legendConfig = {
744
- legendRectWidth: [_constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type) ? 8 : 20,
745
- legendRectHeight: [_constants.CHART_TYPE.SCATTER, _constants.CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type) ? 8 : 6,
464
+ legendRectWidth: [CHART_TYPE.SCATTER, CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config = chart.config) === null || _chart$config === void 0 ? void 0 : _chart$config.type) ? 8 : 20,
465
+ legendRectHeight: [CHART_TYPE.SCATTER, CHART_TYPE.MIRROR].includes(chart === null || chart === void 0 ? void 0 : (_chart$config2 = chart.config) === null || _chart$config2 === void 0 ? void 0 : _chart$config2.type) ? 8 : 6,
746
466
  r: this.getLegendR(chart),
747
467
  legendItemPaddingTop: 5,
748
468
  legendItemTextPaddingTop: 13,
@@ -757,7 +477,7 @@ class ChartComponent extends _react.Component {
757
477
 
758
478
  // sort legend data and format data
759
479
  data.forEach(item => item[legendName] = String(item[legendName]));
760
- const legendData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), legendName, groupColumn, chart);
480
+ const legendData = BaseUtils.sortDataByGroupName(cloneDeep(data), legendName, groupColumn, chart);
761
481
  const {
762
482
  width: chartWidth,
763
483
  height: chartHeight,
@@ -772,6 +492,7 @@ class ChartComponent extends _react.Component {
772
492
  // legend offset bottom and When there is only one line of legend, it is displayed in the center (for scatter chart)
773
493
  if (bottomLegendSpace) {
774
494
  queueMicrotask(() => {
495
+ if (!legendWrapper.node()) return;
775
496
  const {
776
497
  width,
777
498
  height
@@ -781,7 +502,7 @@ class ChartComponent extends _react.Component {
781
502
  if (groupsData.length === 1) {
782
503
  curTranslateX = (chartWidth - width - insertPadding * 2) / 2;
783
504
  }
784
- legendWrapper.attr('transform', "translate(".concat(curTranslateX, ",").concat(curTranslateY, ")"));
505
+ legendWrapper.attr('transform', `translate(${curTranslateX},${curTranslateY})`);
785
506
  });
786
507
  }
787
508
 
@@ -804,7 +525,7 @@ class ChartComponent extends _react.Component {
804
525
  const pageNavigator = legendWrapper.append('g').attr('class', 'legend-flip-page');
805
526
 
806
527
  // count
807
- pageNavigator.append('text').attr('class', 'legend-count').attr('x', 15).attr('y', legendItemTextPaddingTop).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text("".concat(curCount + 1, "/").concat(groupsData.length));
528
+ pageNavigator.append('text').attr('class', 'legend-count').attr('x', 15).attr('y', legendItemTextPaddingTop).attr('fill', theme.legendTextColor).attr('font-size', theme.legendFontSize).text(`${curCount + 1}/${groupsData.length}`);
808
529
 
809
530
  // prev page
810
531
  pageNavigator.append('polygon').attr('class', 'legend-prev-page').attr('points', this.calcEquilateralTriangle(5, 8, 12)).attr('fill', theme.legendPageNavigatorMarkerColor).attr('opacity', curCount === 0 ? 0.45 : 1).attr('style', 'cursor: pointer;').on('click', event => {
@@ -815,7 +536,7 @@ class ChartComponent extends _react.Component {
815
536
  groupData: groupsData[curCount],
816
537
  colorScale,
817
538
  theme,
818
- text: "".concat(curCount + 1, "/").concat(groupsData.length)
539
+ text: `${curCount + 1}/${groupsData.length}`
819
540
  });
820
541
  }
821
542
  });
@@ -829,7 +550,7 @@ class ChartComponent extends _react.Component {
829
550
  groupData: groupsData[curCount],
830
551
  colorScale,
831
552
  theme,
832
- text: "".concat(curCount + 1, "/").concat(groupsData.length)
553
+ text: `${curCount + 1}/${groupsData.length}`
833
554
  });
834
555
  }
835
556
  });
@@ -854,18 +575,18 @@ class ChartComponent extends _react.Component {
854
575
  } = g.node().parentNode.getBoundingClientRect();
855
576
  groupTranslateY = groupTranslateY + height + legendItemMargin;
856
577
  }
857
- g.attr('transform', "translate(".concat(groupTranslateX, ", ").concat(groupTranslateY, ")"));
578
+ g.attr('transform', `translate(${groupTranslateX},${groupTranslateY})`);
858
579
  });
859
580
  }
860
581
  };
861
- this.renderLegend = _ref4 => {
582
+ this.renderLegend = _ref2 => {
862
583
  let {
863
584
  legendWrapper,
864
585
  groupData,
865
586
  colorScale,
866
587
  theme,
867
588
  text
868
- } = _ref4;
589
+ } = _ref2;
869
590
  const {
870
591
  legendItemPaddingTop,
871
592
  legendItemTextPaddingTop,
@@ -891,15 +612,15 @@ class ChartComponent extends _react.Component {
891
612
  d3.select(item).remove();
892
613
  });
893
614
  }
894
- legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName', _ref5 => {
895
- let [groupName] = _ref5;
615
+ legendWrapper.selectAll().data(groupData).join('g').attr('data-groupName', _ref3 => {
616
+ let [groupName] = _ref3;
896
617
  return groupName;
897
- }).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref6 => {
898
- let [groupName] = _ref6;
618
+ }).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref4 => {
619
+ let [groupName] = _ref4;
899
620
  if (colorScale) return colorScale(groupName);
900
- return this.colorMap[groupName] || _constants.CHART_STYLE_COLORS[0];
901
- }).attr('data-text', _ref7 => {
902
- let [groupName] = _ref7;
621
+ return this.colorMap[groupName] || CHART_STYLE_COLORS[0];
622
+ }).attr('data-text', _ref5 => {
623
+ let [groupName] = _ref5;
903
624
  return groupName;
904
625
  }).call(g => {
905
626
  // Add text
@@ -926,7 +647,7 @@ class ChartComponent extends _react.Component {
926
647
  const prevTranslateY = Number(prevItem.getAttribute('data-translateY'));
927
648
  translateY = prevTranslateY + height + legendItemMargin;
928
649
  }
929
- d3.select(item).attr('transform', "translate(".concat(start, ",").concat(translateY, ")")).attr('data-translateY', translateY);
650
+ d3.select(item).attr('transform', `translate(${start},${translateY})`).attr('data-translateY', translateY);
930
651
  });
931
652
  } else {
932
653
  // update g translateX
@@ -940,7 +661,7 @@ class ChartComponent extends _react.Component {
940
661
  const prevTranslateX = Number(prevItem.getAttribute('data-translateX'));
941
662
  translateX = prevTranslateX + width + legendItemMargin;
942
663
  }
943
- d3.select(item).attr('transform', "translate(".concat(translateX, ",0)")).attr('data-translateX', translateX);
664
+ d3.select(item).attr('transform', `translate(${translateX},0)`).attr('data-translateX', translateX);
944
665
 
945
666
  // legend items add offset
946
667
  if (legendPosition === 'top-right') {
@@ -979,7 +700,7 @@ class ChartComponent extends _react.Component {
979
700
  if (top && bottom) {
980
701
  let allHeight = top;
981
702
  const groupsData = [];
982
- const newLegendData = (0, _lodashEs.cloneDeep)(legendData);
703
+ const newLegendData = cloneDeep(legendData);
983
704
  let lastIndex = 0;
984
705
  legendData.forEach((item, index) => {
985
706
  const virtualLegend = this.chart.append('g').attr('opacity', 0);
@@ -1004,7 +725,7 @@ class ChartComponent extends _react.Component {
1004
725
  } else {
1005
726
  let allWidth = start;
1006
727
  const groupsData = [];
1007
- const newLegendData = (0, _lodashEs.cloneDeep)(legendData);
728
+ const newLegendData = cloneDeep(legendData);
1008
729
  let lastIndex = 0;
1009
730
  legendData.forEach((item, index) => {
1010
731
  const virtualLegend = this.chart.append('g').attr('opacity', 0);
@@ -1087,20 +808,20 @@ class ChartComponent extends _react.Component {
1087
808
  const offset = end - (endTranslateX + endWidth);
1088
809
  legendItems.forEach(legendItem => {
1089
810
  const curTranslateX = Number(legendItem.getAttribute('data-translateX')) + offset;
1090
- d3.select(legendItem).attr('transform', "translate(".concat(curTranslateX, ", 0)")).attr('data-translateX', curTranslateX);
811
+ d3.select(legendItem).attr('transform', `translate(${curTranslateX}, 0)`).attr('data-translateX', curTranslateX);
1091
812
  d3.select(legendItem).attr('opacity', 1);
1092
813
  });
1093
814
  };
1094
815
  this.sortLegend = (result, groupColumn, legendName) => {
1095
816
  result.forEach(item => {
1096
817
  const option = groupColumn.data.options.find(option => option.name === item[legendName]);
1097
- if (option !== null && option !== void 0 && option.id) {
818
+ if (option === null || option === void 0 ? void 0 : option.id) {
1098
819
  item['group_name_id'] = option.id;
1099
820
  item['oldName'] = item.name;
1100
821
  item.name = item['group_name_id'];
1101
822
  }
1102
823
  });
1103
- _utils.BaseUtils.sortCharts(result, groupColumn, 'name');
824
+ BaseUtils.sortCharts(result, groupColumn, 'name');
1104
825
  result.forEach(item => {
1105
826
  item.name = item['oldName'];
1106
827
  });
@@ -1113,23 +834,10 @@ class ChartComponent extends _react.Component {
1113
834
  const {
1114
835
  type
1115
836
  } = config;
1116
- if (type === _constants.CHART_TYPE.SCATTER) return 4;
1117
- if (type === _constants.CHART_TYPE.MIRROR) return 0;
837
+ if (type === CHART_TYPE.SCATTER) return 4;
838
+ if (type === CHART_TYPE.MIRROR) return 0;
1118
839
  return 3;
1119
840
  };
1120
- // theta is pie or ring chart
1121
- this.setLegendForTheta = function (legendName) {
1122
- let theme = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _constants.CHART_THEME_COLOR['light'];
1123
- let legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
1124
- let offsetX = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
1125
- if (!_this.chart) return;
1126
- const basicLegendConfig = _this.getLegendConfig(theme, legendPosition);
1127
- if (offsetX) {
1128
- basicLegendConfig.offsetX = offsetX;
1129
- }
1130
- basicLegendConfig.itemName.style.fontSize = theme.fontSize;
1131
- _this.chart.legend(legendName, basicLegendConfig);
1132
- };
1133
841
  this.calcEquilateralTriangle = (cx, cy, size, direction) => {
1134
842
  const height = size * Math.sqrt(3) / 2;
1135
843
  if (direction === 'bottom') {
@@ -1141,12 +849,12 @@ class ChartComponent extends _react.Component {
1141
849
  let groupName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group_name';
1142
850
  let groupColumn = arguments.length > 3 ? arguments[3] : undefined;
1143
851
  let chart = arguments.length > 4 ? arguments[4] : undefined;
1144
- const newData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), groupName, groupColumn, chart);
852
+ const newData = BaseUtils.sortDataByGroupName(cloneDeep(data), groupName, groupColumn, chart);
1145
853
  let currentIdx = 0;
1146
- const defaultColors = _constants.CHART_STYLE_COLORS;
854
+ const defaultColors = CHART_STYLE_COLORS;
1147
855
  let colors = defaultColors;
1148
856
  if (chartColorTheme) {
1149
- colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
857
+ colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
1150
858
  }
1151
859
  const colorMap = newData.reduce((acc, cur) => {
1152
860
  if (cur[groupName] && !acc[cur[groupName]]) {
@@ -1245,142 +953,17 @@ class ChartComponent extends _react.Component {
1245
953
  formatted_value: item.formatted_value + ''
1246
954
  });
1247
955
  }
1248
- if (type === _constants.CHART_TYPE.WORLD_MAP_BUBBLE) {
956
+ if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
1249
957
  sum += item.value;
1250
958
  }
1251
959
  }
1252
960
  }
1253
961
  });
1254
- if (type === _constants.CHART_TYPE.WORLD_MAP_BUBBLE) {
962
+ if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
1255
963
  statisticNewData.sum = sum;
1256
964
  }
1257
965
  return statisticNewData;
1258
966
  };
1259
- this.getToolTipSettings = (isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor) => {
1260
- const obj = {
1261
- showMarkers: false,
1262
- containerTpl: "<div class=\"g2-tooltip\">\n <div class=\"g2-tooltip-title\">{title}</div>\n <ul class=\"g2-tooltip-list\"></ul>\n </div>",
1263
- itemTpl: "<li class=\"g2-tooltip-list-item\">\n <span class=\"g2-tooltip-marker\" style=\"background-color:{color};display:inline-block;\"></span>\n <span class=\"g2-tooltip-name\">{name}</span>\n <span class=\"g2-tooltip-value\">{value}</span>\n </li>",
1264
- domStyles: {
1265
- 'g2-tooltip': {
1266
- boxSizing: 'border-box',
1267
- minWidth: '178px',
1268
- borderRadius: '3px',
1269
- border: '1px solid #e2e2e2',
1270
- backgroundColor: '#fff',
1271
- padding: '16px',
1272
- paddingTop: '8px',
1273
- paddingBottom: '8px',
1274
- marginLeft: '20px',
1275
- boxShadow: '0px 0px 1px 1px rgba(0,0,0,0.1)'
1276
- },
1277
- 'g2-tooltip-title': {
1278
- color: '#333333',
1279
- fontSize: '14px',
1280
- paddingBottom: '10px',
1281
- maxWidth: '160px',
1282
- whiteSpace: 'nowrap',
1283
- overflow: 'hidden',
1284
- lineHeight: '14px',
1285
- textOverflow: 'ellipsis'
1286
- },
1287
- 'g2-tooltip-list-item': {
1288
- marginTop: '8px',
1289
- marginBottom: '8px',
1290
- display: 'flex'
1291
- },
1292
- 'g2-tooltip-marker': {
1293
- width: '12px',
1294
- height: '12px',
1295
- borderRadius: '2px',
1296
- marginRight: '8px'
1297
- },
1298
- 'g2-tooltip-name': {
1299
- display: 'inline-block',
1300
- fontSize: '12px',
1301
- minWidth: '80px',
1302
- whiteSpace: 'nowrap',
1303
- overflow: 'hidden',
1304
- lineHeight: '12px',
1305
- textOverflow: 'ellipsis'
1306
- },
1307
- 'g2-tooltip-value': {
1308
- fontSize: '12px'
1309
- }
1310
- }
1311
- };
1312
- if (isGroup) {
1313
- obj.customItems = items => {
1314
- const activeItem = items[0];
1315
- const name = activeItem.data.name;
1316
- return this.formatedDataByName[name].map(item => {
1317
- return {
1318
- color: useSingleSelectColumnColor ? item.group_color : this.colorMap[item.group_name] || _constants.CHART_STYLE_COLORS[0],
1319
- data: item,
1320
- name: !item.group_name && typeof item.group_name !== 'number' ? _intl.default.get(_constants.EMPTY_NAME) : item.group_name,
1321
- title: item.name,
1322
- value: _utils.BaseUtils.getSummaryValueDisplayString(summaryColumn, item.value, y_axis_summary_method)
1323
- };
1324
- });
1325
- };
1326
- }
1327
- return obj;
1328
- };
1329
- this.setToolTip = (isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor) => {
1330
- const settings = this.getToolTipSettings(isGroup, summaryColumn, y_axis_summary_method, useSingleSelectColumnColor);
1331
- this.chart.tooltip(settings);
1332
- };
1333
- this.setToolTipForLine = () => {
1334
- const settings = this.getToolTipSettings();
1335
- const lineToolTipSettings = {
1336
- showCrosshairs: true,
1337
- showTitle: true,
1338
- shared: true,
1339
- showMarkers: true,
1340
- marker: {
1341
- strokeOpacity: 0,
1342
- r: 5
1343
- },
1344
- crosshairs: {
1345
- line: {
1346
- fill: '#F3F3F3'
1347
- }
1348
- }
1349
- };
1350
- this.chart.tooltip({
1351
- ...settings,
1352
- ...lineToolTipSettings
1353
- });
1354
- };
1355
- this.setToolTipForArea = () => {
1356
- const settings = this.getToolTipSettings();
1357
- const lineToolTipSettings = {
1358
- showCrosshairs: true,
1359
- showTitle: true,
1360
- shared: true,
1361
- showMarkers: true,
1362
- marker: {
1363
- strokeOpacity: 0,
1364
- r: 6
1365
- },
1366
- crosshairs: {
1367
- line: {
1368
- fill: '#F3F3F3'
1369
- }
1370
- }
1371
- };
1372
- this.chart.tooltip({
1373
- ...settings,
1374
- ...lineToolTipSettings
1375
- });
1376
- };
1377
- // theta is pie or ring chart
1378
- this.setToolTipForTheta = () => {
1379
- const settings = this.getToolTipSettings();
1380
- settings.showTitle = false;
1381
- settings.containerTpl = "<div class=\"g2-tooltip\">\n <ul class=\"g2-tooltip-list\"></ul>\n </div>";
1382
- this.chart.tooltip(settings);
1383
- };
1384
967
  this.isShowXAxisLabel = chart => {
1385
968
  return !!(chart && chart.config && chart.config.x_axis_show_label);
1386
969
  };
@@ -1397,21 +980,21 @@ class ChartComponent extends _react.Component {
1397
980
  let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1398
981
  let theme = arguments.length > 1 ? arguments[1] : undefined;
1399
982
  // dark->custom->light
1400
- if (theme === _constants.THEME_NAME_MAP.DARK) {
1401
- themeColors = _constants.CHART_THEME_COLOR.dark;
983
+ if (theme === THEME_NAME_MAP.DARK) {
984
+ themeColors = CHART_THEME_COLOR.dark;
1402
985
  }
1403
- return themeColors || _constants.CHART_THEME_COLOR[_constants.THEME_NAME_MAP.LIGHT];
986
+ return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
1404
987
  };
1405
988
  this.setDispalyGoalLine = (goal_label, goal_value, insertPadding, yScale) => {
1406
989
  const {
1407
990
  width: chartWidth
1408
991
  } = this.chartBoundingClientRect;
1409
- const annotationWrapper = this.chart.append('g').attr('class', "annotation-wrapper");
992
+ const annotationWrapper = this.chart.append('g').attr('class', `annotation-wrapper`);
1410
993
  annotationWrapper.append('line').attr('stroke', '#aaa').attr('x1', insertPadding).attr('y1', yScale(goal_value)).attr('x2', chartWidth - insertPadding).attr('y2', yScale(goal_value)).attr('stroke-dasharray', '8,3').call(g => {
1411
994
  annotationWrapper.append('text').attr('x', chartWidth - insertPadding - 30).attr('y', yScale(goal_value) - 10).attr('fill', '#666').text(goal_label);
1412
995
  });
1413
996
  };
1414
- this.addLabelToRectTop = _ref8 => {
997
+ this.addLabelToRectTop = _ref6 => {
1415
998
  let {
1416
999
  container,
1417
1000
  x,
@@ -1420,15 +1003,16 @@ class ChartComponent extends _react.Component {
1420
1003
  theme,
1421
1004
  label_font_size,
1422
1005
  text
1423
- } = _ref8;
1424
- d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1006
+ } = _ref6;
1007
+ d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('y', Number(y) - 10).attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1008
+ if (!g.node()) return;
1425
1009
  const {
1426
1010
  width
1427
1011
  } = g.node().getBoundingClientRect();
1428
1012
  g.attr('x', Number(x) + Number(xWidth) / 2 - width / 2);
1429
1013
  });
1430
1014
  };
1431
- this.addLabelToRectRight = _ref9 => {
1015
+ this.addLabelToRectRight = _ref7 => {
1432
1016
  let {
1433
1017
  container,
1434
1018
  x,
@@ -1438,8 +1022,8 @@ class ChartComponent extends _react.Component {
1438
1022
  theme,
1439
1023
  label_font_size,
1440
1024
  text
1441
- } = _ref9;
1442
- d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1025
+ } = _ref7;
1026
+ d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('x', Number(x) + Number(xWidth) + 10).attr('y', Number(y)).attr('fill', theme.labelColor).attr('dominant-baseline', 'hanging').attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1443
1027
  if (g.node()) {
1444
1028
  var _g$node;
1445
1029
  const {
@@ -1449,7 +1033,7 @@ class ChartComponent extends _react.Component {
1449
1033
  }
1450
1034
  });
1451
1035
  };
1452
- this.addLabelToRectCenter = _ref10 => {
1036
+ this.addLabelToRectCenter = _ref8 => {
1453
1037
  let {
1454
1038
  chartType,
1455
1039
  container,
@@ -1460,18 +1044,19 @@ class ChartComponent extends _react.Component {
1460
1044
  theme,
1461
1045
  label_font_size,
1462
1046
  text
1463
- } = _ref10;
1464
- d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', _utils.BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1047
+ } = _ref8;
1048
+ d3.select(container).append('text').attr('stroke', '#fff').attr('stroke-width', 1).attr('paint-order', 'stroke').attr('fill', theme.labelColor).attr('font-size', BaseUtils.getLabelFontSize(label_font_size)).text(text).call(g => {
1049
+ if (!g.node()) return;
1465
1050
  const {
1466
1051
  width,
1467
1052
  height
1468
1053
  } = g.node().getBoundingClientRect();
1469
1054
  const translateX = Number(x) + xWidth / 2 - width / 2;
1470
1055
  let translateY = Number(y) + Number(yheight / 2) + height / 2;
1471
- if (chartType === _constants.CHART_TYPE.BAR_STACK) {
1056
+ if (chartType === CHART_TYPE.BAR_STACK) {
1472
1057
  translateY = translateY;
1473
1058
  }
1474
- g.attr('transform', "translate(".concat(translateX, ", ").concat(translateY, ")"));
1059
+ g.attr('transform', `translate(${translateX}, ${translateY})`);
1475
1060
  });
1476
1061
  };
1477
1062
  this.setActiveAndInActiveState = (state, allGroup, curGroupName, chartType) => {
@@ -1480,7 +1065,7 @@ class ChartComponent extends _react.Component {
1480
1065
  const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
1481
1066
  rects.forEach(item => {
1482
1067
  d3.select(item).transition().duration(this.transitionDuration).attr('opacity', 1);
1483
- if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
1068
+ if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
1484
1069
  d3.select(item).attr('stroke-width', 2);
1485
1070
  }
1486
1071
  });
@@ -1493,7 +1078,7 @@ class ChartComponent extends _react.Component {
1493
1078
  if (item.getAttribute('data-groupName') !== curGroupName) {
1494
1079
  d3.selectAll([item]).transition().duration(this.transitionDuration).attr('opacity', 0.3);
1495
1080
  } else {
1496
- if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
1081
+ if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
1497
1082
  d3.select(item).attr('stroke-width', 0.5);
1498
1083
  }
1499
1084
  }
@@ -1502,29 +1087,36 @@ class ChartComponent extends _react.Component {
1502
1087
  }
1503
1088
  };
1504
1089
  // Use clipPath to make rectangle rounded corners
1505
- this.addClipPath = _ref11 => {
1090
+ this.addClipPath = _ref9 => {
1506
1091
  let {
1507
1092
  rect,
1508
1093
  parentNode,
1509
1094
  attr,
1510
- rectId
1511
- } = _ref11;
1095
+ rectId,
1096
+ borderRadiusVal
1097
+ } = _ref9;
1512
1098
  const {
1513
1099
  borderRadius
1514
1100
  } = this.chartBoundingClientRect;
1515
1101
  const clipRect = d3.select(rect.cloneNode());
1516
1102
  if (attr === 'x') {
1517
- const borderRadiusVal = Number(rect.getAttribute('height')) * borderRadius;
1518
- clipRect.attr('rx', borderRadiusVal);
1519
- clipRect.attr('x', Number(rect.getAttribute('x')) - borderRadiusVal).attr('width', Number(rect.getAttribute('width')) + borderRadiusVal);
1103
+ const rectHeight = Number(rect.getAttribute('height'));
1104
+ const rectWidth = Number(rect.getAttribute('width'));
1105
+ const computedBorderRadius = Math.min(rectHeight * borderRadius, rectWidth / 2);
1106
+ const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1107
+ clipRect.attr('rx', safeBorderRadius);
1108
+ clipRect.attr('x', Number(rect.getAttribute('x')) - safeBorderRadius).attr('width', rectWidth + safeBorderRadius);
1520
1109
  } else {
1521
- const borderRadiusVal = Number(rect.getAttribute('width')) * borderRadius;
1522
- clipRect.attr('rx', borderRadiusVal);
1523
- clipRect.attr('height', Number(rect.getAttribute('height')) + borderRadiusVal);
1110
+ const rectWidth = Number(rect.getAttribute('width'));
1111
+ const rectHeight = Number(rect.getAttribute('height'));
1112
+ const computedBorderRadius = Math.min(rectWidth * borderRadius, rectHeight / 2);
1113
+ const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1114
+ clipRect.attr('rx', safeBorderRadius);
1115
+ clipRect.attr('height', rectHeight + safeBorderRadius);
1524
1116
  }
1525
1117
  const clipPath = d3.select(parentNode).append('clipPath').attr('opacity', 1).attr('id', rectId);
1526
1118
  clipPath.node().appendChild(clipRect.node());
1527
- d3.select(rect).attr('clip-path', "url(#".concat(rectId, ")"));
1119
+ d3.select(rect).attr('clip-path', `url(#${rectId})`);
1528
1120
  };
1529
1121
  this.drawYaxis = function (g, theme) {
1530
1122
  let rightAxisOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
@@ -1545,7 +1137,7 @@ class ChartComponent extends _react.Component {
1545
1137
  g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2 - _this.horizontalOverflowOffset - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
1546
1138
 
1547
1139
  // update g translateX
1548
- g.attr('transform', "translate(".concat(insertPadding + _this.horizontalOverflowOffset, ", 0)"));
1140
+ g.attr('transform', `translate(${insertPadding + _this.horizontalOverflowOffset}, 0)`);
1549
1141
  };
1550
1142
  this.checkTextOverflow = allTextEl => {
1551
1143
  const {
@@ -1574,6 +1166,7 @@ class ChartComponent extends _react.Component {
1574
1166
  // Hide overlapping ticks
1575
1167
  for (let i = 0; i < allTicks.length; i++) {
1576
1168
  const curText = d3.select(allTicks[i]).select('text').node();
1169
+ if (!curText) continue;
1577
1170
  const {
1578
1171
  right: curRight,
1579
1172
  bottom: curBottom
@@ -1635,9 +1228,10 @@ class ChartComponent extends _react.Component {
1635
1228
  } = g.node().getBoundingClientRect();
1636
1229
  if (isRoateText && width > insertPadding) {
1637
1230
  const viewWidth = viewBox[viewBox.length - 2];
1638
- viewBox[0] = "-".concat(width - insertPadding);
1639
- viewBox[viewBox.length - 2] = "".concat(Number(viewWidth) + (width - insertPadding));
1231
+ viewBox[0] = `-${width - insertPadding}`;
1232
+ viewBox[viewBox.length - 2] = `${Number(viewWidth) + (width - insertPadding)}`;
1640
1233
  queueMicrotask(() => {
1234
+ if (!this.chart) return;
1641
1235
  this.chart.attr('viewBox', viewBox.join(','));
1642
1236
  });
1643
1237
  }
@@ -1668,8 +1262,9 @@ class ChartComponent extends _react.Component {
1668
1262
  } = g.node().getBoundingClientRect();
1669
1263
  if (height > insertPadding) {
1670
1264
  const viewHeight = viewBox[viewBox.length - 1];
1671
- viewBox[viewBox.length - 1] = "".concat(Number(viewHeight) + (height - insertPadding));
1265
+ viewBox[viewBox.length - 1] = `${Number(viewHeight) + (height - insertPadding)}`;
1672
1266
  queueMicrotask(() => {
1267
+ if (!this.chart) return;
1673
1268
  this.chart.attr('viewBox', viewBox.join(','));
1674
1269
  });
1675
1270
  }
@@ -1681,6 +1276,7 @@ class ChartComponent extends _react.Component {
1681
1276
  ticks.forEach(tick => {
1682
1277
  var _d3$select$select;
1683
1278
  const text = (_d3$select$select = d3.select(tick).select('text')) === null || _d3$select$select === void 0 ? void 0 : _d3$select$select.node();
1279
+ if (!text) return;
1684
1280
  d3.select(tick).select('line').attr('data-name', text.innerHTML);
1685
1281
  });
1686
1282
  }
@@ -1728,5 +1324,4 @@ class ChartComponent extends _react.Component {
1728
1324
  componentWillUnmount() {
1729
1325
  window.removeEventListener('resize', this.handleResize);
1730
1326
  }
1731
- }
1732
- exports.default = ChartComponent;
1327
+ }