sea-chart 2.0.43 → 2.0.44

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 (302) hide show
  1. package/dist/api/index.js +4 -11
  2. package/dist/components/cell-factory/FormatterConfig.js +55 -62
  3. package/dist/components/cell-factory/SimpleCellFormatter.js +4 -11
  4. package/dist/components/cell-factory/SingleSelectOption.js +11 -18
  5. package/dist/components/cell-factory/cell-editor-factory.js +5 -12
  6. package/dist/components/cell-factory/cell-formatter-factory.js +4 -11
  7. package/dist/components/cell-factory/link-content.js +27 -35
  8. package/dist/components/chart-color-selector/color-selector.js +11 -18
  9. package/dist/components/collaborator/index.js +7 -14
  10. package/dist/components/color-picker/index.js +11 -18
  11. package/dist/components/color-popover/color-rules/color-rule.js +25 -33
  12. package/dist/components/color-popover/color-rules/index.js +6 -14
  13. package/dist/components/color-popover/color-rules/rule-filters/filter.js +27 -34
  14. package/dist/components/color-popover/color-rules/rule-filters/index.js +17 -25
  15. package/dist/components/color-popover/color-rules/rule-filters/number-input.js +10 -18
  16. package/dist/components/color-popover/color-rules-popover.js +26 -34
  17. package/dist/components/color-popover/color-selector-popover.js +10 -18
  18. package/dist/components/color-setting/color-group-selector.js +12 -20
  19. package/dist/components/common-add-tool/index.js +6 -13
  20. package/dist/components/data-process-setter/data-setting-header.js +7 -14
  21. package/dist/components/data-process-setter/hide-column-setter.js +12 -19
  22. package/dist/components/data-process-setter/index.js +4 -27
  23. package/dist/components/data-process-setter/sort-setter.js +16 -24
  24. package/dist/components/draggable/Draggable.js +7 -13
  25. package/dist/components/drill-down-settings/drill-down-fields-popover/index.js +42 -50
  26. package/dist/components/drill-down-settings/drill-down-fields-settings/index.js +10 -18
  27. package/dist/components/drill-down-settings/index.js +11 -18
  28. package/dist/components/dtable-popover/index.js +13 -20
  29. package/dist/components/dtable-search-input/index.js +13 -21
  30. package/dist/components/font-settings/index.js +14 -22
  31. package/dist/components/goal-line-setting/goal-setting-item.js +6 -14
  32. package/dist/components/goal-line-setting/index.js +12 -19
  33. package/dist/components/highlighter/highlighter.js +7 -14
  34. package/dist/components/icon/index.js +4 -11
  35. package/dist/components/index.js +7 -48
  36. package/dist/components/loading/index.js +6 -13
  37. package/dist/components/number-input/index.js +4 -11
  38. package/dist/components/pixel-editor/index.js +15 -23
  39. package/dist/components/popover/hide-column-popover/hide-column-popover-widgets/hide-column-item.js +8 -15
  40. package/dist/components/popover/hide-column-popover/hide-column-popover.js +25 -33
  41. package/dist/components/popover/sort-popover/sort-popover-widgets/sort-utils.js +9 -18
  42. package/dist/components/popover/sort-popover/sort-popover.js +54 -64
  43. package/dist/components/resize-handle/ResizeHandle.js +6 -13
  44. package/dist/components/row-card/row-card-header-cell.js +15 -22
  45. package/dist/components/row-card/row-card-header.js +14 -21
  46. package/dist/components/row-card/row-card-item.js +33 -41
  47. package/dist/components/row-card/row-card.js +15 -23
  48. package/dist/components/statistic-record-dialog/index.js +56 -64
  49. package/dist/components/tooltip/index.js +21 -21
  50. package/dist/components/types-dialog/index.js +56 -64
  51. package/dist/components/types-dialog/use-force-update.js +4 -10
  52. package/dist/constants/color-rules.js +8 -14
  53. package/dist/constants/common-constants.js +8 -14
  54. package/dist/constants/error.js +2 -8
  55. package/dist/constants/geolocation.js +9 -15
  56. package/dist/constants/index.js +149 -273
  57. package/dist/constants/key-codes.js +0 -2
  58. package/dist/constants/model.js +3 -9
  59. package/dist/constants/regions.js +3 -8
  60. package/dist/constants/style.js +6 -12
  61. package/dist/constants/table.js +1 -7
  62. package/dist/constants/type-image.js +33 -39
  63. package/dist/constants/type.js +3 -9
  64. package/dist/context.js +20 -24
  65. package/dist/editor/index.js +8 -15
  66. package/dist/index.js +13 -104
  67. package/dist/intl.js +10 -17
  68. package/dist/locale/index.js +16 -23
  69. package/dist/locale/lang/de.js +1 -7
  70. package/dist/locale/lang/en.js +1 -7
  71. package/dist/locale/lang/es.js +1 -7
  72. package/dist/locale/lang/fr.js +1 -7
  73. package/dist/locale/lang/pt.js +1 -7
  74. package/dist/locale/lang/ru.js +1 -7
  75. package/dist/locale/lang/zh_CN.js +1 -7
  76. package/dist/model/area-group.js +12 -19
  77. package/dist/model/area.js +12 -19
  78. package/dist/model/bar-custom.js +11 -18
  79. package/dist/model/bar-group.js +12 -19
  80. package/dist/model/bar-stack.js +10 -17
  81. package/dist/model/bar.js +11 -18
  82. package/dist/model/base-model.js +8 -11
  83. package/dist/model/basic-number-card.js +13 -20
  84. package/dist/model/chart.js +7 -13
  85. package/dist/model/combination.js +19 -22
  86. package/dist/model/compare-bar.js +14 -21
  87. package/dist/model/completeness-group.js +11 -18
  88. package/dist/model/completeness.js +10 -17
  89. package/dist/model/dashboard.js +7 -14
  90. package/dist/model/funnel.js +14 -21
  91. package/dist/model/generic-model.js +135 -143
  92. package/dist/model/heat-map.js +9 -16
  93. package/dist/model/horizontal-bar.js +15 -18
  94. package/dist/model/horizontal-group-bar.js +14 -17
  95. package/dist/model/index.js +69 -93
  96. package/dist/model/line-group.js +13 -20
  97. package/dist/model/line.js +12 -19
  98. package/dist/model/map-bubble.js +12 -19
  99. package/dist/model/map.js +12 -19
  100. package/dist/model/mirror.js +13 -20
  101. package/dist/model/pie.js +12 -19
  102. package/dist/model/ring.js +12 -19
  103. package/dist/model/scatter.js +10 -17
  104. package/dist/model/stacked-horizontal-bar.js +15 -18
  105. package/dist/model/table-element.js +5 -12
  106. package/dist/model/table.js +7 -14
  107. package/dist/model/tree-map.js +7 -14
  108. package/dist/model/trend.js +11 -18
  109. package/dist/model/user.js +1 -7
  110. package/dist/model/world-map-bubble.js +12 -19
  111. package/dist/model/world-map.js +12 -19
  112. package/dist/services/map-json.js +7 -13
  113. package/dist/settings/advance-bar-settings/data-settings.js +36 -44
  114. package/dist/settings/advance-bar-settings/index.js +3 -20
  115. package/dist/settings/advance-bar-settings/style-settings.js +83 -74
  116. package/dist/settings/bar-settings/data-settings.js +39 -47
  117. package/dist/settings/bar-settings/index.js +3 -20
  118. package/dist/settings/bar-settings/style-settings.js +69 -60
  119. package/dist/settings/basic-number-card/data-settings.js +49 -57
  120. package/dist/settings/basic-number-card/index.js +3 -20
  121. package/dist/settings/basic-number-card/style-settings.js +18 -26
  122. package/dist/settings/combination-settings/data-settings.js +55 -63
  123. package/dist/settings/combination-settings/index.js +3 -20
  124. package/dist/settings/combination-settings/style-settings.js +94 -77
  125. package/dist/settings/completeness-settings/callbacks/callbacks.js +16 -27
  126. package/dist/settings/completeness-settings/data-settings/completion-settings.js +21 -28
  127. package/dist/settings/completeness-settings/data-settings/data-settings.js +25 -32
  128. package/dist/settings/completeness-settings/index.js +3 -20
  129. package/dist/settings/completeness-settings/style-settings.js +19 -26
  130. package/dist/settings/dashboard-settings/data-settings.js +43 -51
  131. package/dist/settings/dashboard-settings/index.js +2 -13
  132. package/dist/settings/data-settings.js +72 -79
  133. package/dist/settings/funnel-settings/components/dnd-item/dnd-item.js +12 -19
  134. package/dist/settings/funnel-settings/components/dnd-list.js +15 -23
  135. package/dist/settings/funnel-settings/components/funnel-label-setting.js +32 -40
  136. package/dist/settings/funnel-settings/components/funnel-layer-setting.js +20 -28
  137. package/dist/settings/funnel-settings/data-settings.js +23 -31
  138. package/dist/settings/funnel-settings/index.js +3 -20
  139. package/dist/settings/funnel-settings/style-settings.js +11 -19
  140. package/dist/settings/heat-map-settings/data-settings.js +18 -26
  141. package/dist/settings/heat-map-settings/index.js +3 -20
  142. package/dist/settings/heat-map-settings/style-settings.js +18 -26
  143. package/dist/settings/horizontal-bar-settings/data-settings.js +12 -19
  144. package/dist/settings/horizontal-bar-settings/index.js +3 -20
  145. package/dist/settings/horizontal-bar-settings/style-settings.js +12 -19
  146. package/dist/settings/index.js +52 -70
  147. package/dist/settings/map-settings/components/location-field-selector.js +10 -17
  148. package/dist/settings/map-settings/components/map-level-selector.js +11 -18
  149. package/dist/settings/map-settings/components/map-province-city-selector.js +19 -26
  150. package/dist/settings/map-settings/index.js +3 -20
  151. package/dist/settings/map-settings/map-data-settings.js +23 -30
  152. package/dist/settings/map-settings/map-style-settings.js +26 -34
  153. package/dist/settings/mirror-settings/data-settings.js +26 -34
  154. package/dist/settings/mirror-settings/index.js +2 -13
  155. package/dist/settings/pie-settings/data-settings.js +33 -41
  156. package/dist/settings/pie-settings/index.js +3 -20
  157. package/dist/settings/pie-settings/style-settings.js +47 -55
  158. package/dist/settings/scatter/data-settings.js +27 -34
  159. package/dist/settings/scatter/index.js +3 -12
  160. package/dist/settings/stacks-settings/index.js +19 -27
  161. package/dist/settings/stacks-settings/stack-item-settings.js +19 -27
  162. package/dist/settings/style-settings.js +64 -72
  163. package/dist/settings/table-element-settings/components/data-filter.js +30 -38
  164. package/dist/settings/table-element-settings/data-settings.js +21 -29
  165. package/dist/settings/table-element-settings/index.js +2 -13
  166. package/dist/settings/table-settings/data-settings.js +111 -119
  167. package/dist/settings/table-settings/index.js +2 -13
  168. package/dist/settings/time-comparison-settings/data-settings.js +43 -51
  169. package/dist/settings/time-comparison-settings/index.js +3 -20
  170. package/dist/settings/time-comparison-settings/style-settings.js +62 -53
  171. package/dist/settings/trend-settings/data-settings.js +24 -32
  172. package/dist/settings/trend-settings/index.js +3 -20
  173. package/dist/settings/trend-settings/style-setting.js +17 -25
  174. package/dist/settings/widgets/axis-title-font-settings/index.js +39 -0
  175. package/dist/settings/widgets/basic-summary/index.js +55 -63
  176. package/dist/settings/widgets/chart-type/index.js +18 -26
  177. package/dist/settings/widgets/color-settings/index.js +72 -80
  178. package/dist/settings/widgets/common-data-settings.js +21 -29
  179. package/dist/settings/widgets/data-filter/index.js +35 -43
  180. package/dist/settings/widgets/data-sort.js +16 -24
  181. package/dist/settings/widgets/date-summary-item.js +24 -32
  182. package/dist/settings/widgets/display-values-settings/index.js +14 -22
  183. package/dist/settings/widgets/divider/index.js +8 -16
  184. package/dist/settings/widgets/font-settings/font-color-settings.js +11 -19
  185. package/dist/settings/widgets/font-settings/font-size-settings.js +14 -22
  186. package/dist/settings/widgets/font-settings/font-weight-settings.js +17 -25
  187. package/dist/settings/widgets/font-settings/index.js +4 -27
  188. package/dist/settings/widgets/group-by.js +51 -59
  189. package/dist/settings/widgets/min-max-setting.js +10 -18
  190. package/dist/settings/widgets/mininum-slice-percent.js +10 -18
  191. package/dist/settings/widgets/numeric-summary-item.js +23 -31
  192. package/dist/settings/widgets/select-line-type/index.js +10 -17
  193. package/dist/settings/widgets/select-table/index.js +9 -16
  194. package/dist/settings/widgets/select-view/index.js +20 -28
  195. package/dist/settings/widgets/stack.js +14 -22
  196. package/dist/settings/widgets/summary-method-setting.js +17 -25
  197. package/dist/settings/widgets/summary-settings.js +72 -80
  198. package/dist/settings/widgets/switch/index.js +8 -15
  199. package/dist/settings/widgets/text-horizontal-settings.js +15 -23
  200. package/dist/settings/widgets/time-picker.js +29 -37
  201. package/dist/settings/widgets/title-settings/index.js +29 -37
  202. package/dist/settings/widgets/title-settings/title-text.js +5 -12
  203. package/dist/settings/widgets/x-axios.js +0 -1
  204. package/dist/settings/widgets/y-axis-group-settings.js +63 -71
  205. package/dist/utils/cell-format-utils.js +18 -28
  206. package/dist/utils/cell-value-utils.js +5 -12
  207. package/dist/utils/chart-utils/base-utils.js +362 -334
  208. package/dist/utils/chart-utils/index.js +28 -41
  209. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +80 -86
  210. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +13 -20
  211. package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +45 -52
  212. package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +19 -26
  213. package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +32 -39
  214. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +16 -23
  215. package/dist/utils/chart-utils/original-data-utils/index.js +50 -57
  216. package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +21 -28
  217. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +91 -97
  218. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +19 -26
  219. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +31 -38
  220. package/dist/utils/chart-utils/sql-statistics-utils.js +284 -246
  221. package/dist/utils/chart.js +9 -17
  222. package/dist/utils/collaborator-manager.js +3 -9
  223. package/dist/utils/collaborator-utils.js +18 -30
  224. package/dist/utils/collaborator.js +4 -13
  225. package/dist/utils/color-utils.js +18 -29
  226. package/dist/utils/column-utils.js +65 -92
  227. package/dist/utils/common-utils.js +27 -52
  228. package/dist/utils/concurrency-manager.js +1 -7
  229. package/dist/utils/contexts.js +5 -12
  230. package/dist/utils/date-translate.js +11 -19
  231. package/dist/utils/digital-sign-utils.js +7 -14
  232. package/dist/utils/event-bus.js +1 -7
  233. package/dist/utils/hotkey.js +5 -11
  234. package/dist/utils/index.js +54 -221
  235. package/dist/utils/key-generator.js +2 -9
  236. package/dist/utils/map.js +22 -31
  237. package/dist/utils/object-utils.js +1 -7
  238. package/dist/utils/options-utils.js +8 -16
  239. package/dist/utils/row-record-utils.js +182 -178
  240. package/dist/utils/row-utils.js +27 -38
  241. package/dist/utils/search.js +24 -32
  242. package/dist/utils/sql/chart-data-sql.js +49 -55
  243. package/dist/utils/sql/column-2-sql-column.js +146 -154
  244. package/dist/utils/sql/index.js +3 -27
  245. package/dist/utils/trend-utils.js +39 -47
  246. package/dist/view/index.css +0 -17
  247. package/dist/view/index.js +89 -95
  248. package/dist/view/title/index.js +15 -23
  249. package/dist/view/wrapper/area-group.js +53 -72
  250. package/dist/view/wrapper/area.js +51 -72
  251. package/dist/view/wrapper/bar-compare.js +43 -56
  252. package/dist/view/wrapper/bar-custom-stack.js +50 -120
  253. package/dist/view/wrapper/bar-group.js +51 -94
  254. package/dist/view/wrapper/bar-stack.js +54 -90
  255. package/dist/view/wrapper/bar.js +45 -66
  256. package/dist/view/wrapper/basic-number-card.js +25 -26
  257. package/dist/view/wrapper/chart-component.js +539 -162
  258. package/dist/view/wrapper/combination.js +63 -83
  259. package/dist/view/wrapper/completeness-group.js +42 -96
  260. package/dist/view/wrapper/completeness.js +42 -96
  261. package/dist/view/wrapper/dashboard.js +33 -47
  262. package/dist/view/wrapper/funnel.js +36 -56
  263. package/dist/view/wrapper/heat-map.js +126 -104
  264. package/dist/view/wrapper/horizontal-bar-group.js +57 -76
  265. package/dist/view/wrapper/horizontal-bar-stack.js +56 -109
  266. package/dist/view/wrapper/horizontal-bar.js +45 -68
  267. package/dist/view/wrapper/index.js +110 -115
  268. package/dist/view/wrapper/line-group.js +48 -66
  269. package/dist/view/wrapper/line.js +47 -67
  270. package/dist/view/wrapper/map-bubble.js +46 -59
  271. package/dist/view/wrapper/map-world-bubble.js +45 -58
  272. package/dist/view/wrapper/map-world.js +47 -60
  273. package/dist/view/wrapper/map.js +48 -60
  274. package/dist/view/wrapper/mirror.js +40 -61
  275. package/dist/view/wrapper/pie.js +48 -59
  276. package/dist/view/wrapper/ring.js +52 -63
  277. package/dist/view/wrapper/scatter.js +49 -67
  278. package/dist/view/wrapper/table/index.js +13 -21
  279. package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +49 -57
  280. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +50 -58
  281. package/dist/view/wrapper/table/pivot-table-display-name.js +83 -91
  282. package/dist/view/wrapper/table/two-dimension-table.js +76 -84
  283. package/dist/view/wrapper/table-element/components/dataset-utils.js +23 -36
  284. package/dist/view/wrapper/table-element/components/formatter.js +96 -105
  285. package/dist/view/wrapper/table-element/components/formatters/FileFormatter/index.js +22 -31
  286. package/dist/view/wrapper/table-element/components/formatters/formula-formatter.js +9 -16
  287. package/dist/view/wrapper/table-element/components/formatters/link-formatter.js +73 -80
  288. package/dist/view/wrapper/table-element/components/formula-formatter.js +9 -16
  289. package/dist/view/wrapper/table-element/components/link-formatter.js +73 -80
  290. package/dist/view/wrapper/table-element/components/record.js +10 -17
  291. package/dist/view/wrapper/table-element/components/records-body.js +17 -19
  292. package/dist/view/wrapper/table-element/components/records-header/index.js +7 -15
  293. package/dist/view/wrapper/table-element/components/records-header/records-header-cell.js +8 -16
  294. package/dist/view/wrapper/table-element/components/records.js +23 -33
  295. package/dist/view/wrapper/table-element/components/resize-column-handle/resize-column-handle.js +5 -12
  296. package/dist/view/wrapper/table-element/components/utils.js +5 -15
  297. package/dist/view/wrapper/table-element/components/value-display-utils.js +4 -11
  298. package/dist/view/wrapper/table-element/components/vertical-scrollbar/index.js +6 -13
  299. package/dist/view/wrapper/table-element/index.js +18 -26
  300. package/dist/view/wrapper/treemap.js +39 -57
  301. package/dist/view/wrapper/trend.js +41 -48
  302. package/package.json +1 -1
@@ -1,56 +1,84 @@
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, DEFAULT_AXIS_LABEL_FONT_COLOR, DEFAULT_AXIS_LABEL_FONT_COLOR_DARK, DEFAULT_AXIS_LABEL_FONT_SIZE } 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();
34
27
  this.drawChart();
35
- if (this.needRenderAxisLabel) {
36
- this.renderAxisLabel(this.props.chart, this.props.tables);
37
- }
38
28
  }, 300);
39
29
  this.destroyChart = () => {
40
30
  this.chart && this.chart.node() && this.chart.node().remove();
31
+ this.container && this.setAxisTitlePadding(this.container, {
32
+ left: null,
33
+ bottom: null,
34
+ right: null
35
+ });
36
+ this._clipMaskByRect.clear();
37
+ this._defs = null;
38
+ };
39
+ this.toggleRecords = function (statisticRecord) {
40
+ if (!statisticRecord) return;
41
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
42
+ args[_key - 1] = arguments[_key];
43
+ }
44
+ _this.props.toggleRecords && _this.props.toggleRecords(statisticRecord, ...args);
41
45
  };
42
46
  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);
47
+ return yAxisType === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : this.getAxisLabel(tables, table_id, yAxisKey);
44
48
  };
45
49
  this.getColumn = (tables, table_id, columnKey) => {
46
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
47
- const column = (0, _dtableUtils.getTableColumnByKey)(table, columnKey) || {};
50
+ const table = getTableById(tables, table_id);
51
+ const column = getTableColumnByKey(table, columnKey) || {};
48
52
  return column;
49
53
  };
50
54
  this.getAxisLabel = (tables, tableId, columnKey) => {
51
55
  const column = this.getColumn(tables, tableId, columnKey);
52
56
  return column.name || '';
53
57
  };
58
+ this.getAxisTitleHeight = fontSize => {
59
+ const safeFontSize = Number(fontSize) || DEFAULT_AXIS_LABEL_FONT_SIZE;
60
+ return Math.max(this.axisTitleMinHeight, safeFontSize + 4);
61
+ };
62
+ this.setAxisTitlePadding = function (chartContainer) {
63
+ let {
64
+ left = null,
65
+ bottom = null,
66
+ right = null
67
+ } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
68
+ if (!chartContainer) return;
69
+ chartContainer.style.paddingLeft = left != null ? `${left}px` : '';
70
+ chartContainer.style.paddingBottom = bottom != null ? `${bottom}px` : '';
71
+ chartContainer.style.paddingRight = right != null ? `${right}px` : '';
72
+ };
73
+ this.getRotatedAxisTitleTransform = function (containerHeight, titleHeight) {
74
+ let placement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
75
+ const translateX = containerHeight / 2 - titleHeight / 2;
76
+ const translateY = containerHeight / 2 - titleHeight / 2;
77
+ if (placement === 'right') {
78
+ return `translate(${translateX}px, ${translateY}px) rotate(-90deg)`;
79
+ }
80
+ return `translate(-${translateX}px, ${translateY}px) rotate(-90deg)`;
81
+ };
54
82
  this.initChart = function (container, id) {
55
83
  let initConfig = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
56
84
  const {
@@ -68,6 +96,8 @@ class ChartComponent extends _react.Component {
68
96
  const height = customHeight ? customHeight : containerHeight - marginBottom;
69
97
  _this.chart = d3.create('svg').attr('id', id).attr('width', width).attr('height', height).attr('viewBox', [0, 0, width, height]);
70
98
  _this.container.appendChild(_this.chart.node());
99
+ _this._defs = null;
100
+ _this._clipMaskByRect = new Map();
71
101
  _this.chartBoundingClientRect = {
72
102
  ...JSON.parse(JSON.stringify(_this.chart.node().getBoundingClientRect())),
73
103
  ...initConfig,
@@ -75,6 +105,12 @@ class ChartComponent extends _react.Component {
75
105
  height
76
106
  };
77
107
  };
108
+ this.getDefs = () => {
109
+ if (!this._defs || !this._defs.node() || !this._defs.node().isConnected) {
110
+ this._defs = this.chart.append('defs').attr('class', 'sea-chart-defs');
111
+ }
112
+ return this._defs;
113
+ };
78
114
  this.initDefs = () => {
79
115
  if (this.container) {
80
116
  // add Mask
@@ -107,7 +143,7 @@ class ChartComponent extends _react.Component {
107
143
  if (item.group_name === 'rest' && isCompleteness) return;
108
144
  const groupData = chartGroupData.find(g => g.name === item.name);
109
145
  if (!groupData) {
110
- const newItem = (0, _lodashEs.cloneDeep)(item);
146
+ const newItem = cloneDeep(item);
111
147
  newItem.currentGroupCount = 1;
112
148
  chartGroupData.push(newItem);
113
149
  } else {
@@ -161,13 +197,13 @@ class ChartComponent extends _react.Component {
161
197
  // mark the first item in each group,but if item value is 0, mark the next item
162
198
  let targetMarkItem = item[0],
163
199
  i = 1;
164
- while (!((_targetMarkItem = targetMarkItem) !== null && _targetMarkItem !== void 0 && _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
200
+ while (!((_targetMarkItem = targetMarkItem) === null || _targetMarkItem === void 0 ? void 0 : _targetMarkItem.value) && !Number.isNaN((_targetMarkItem2 = targetMarkItem) === null || _targetMarkItem2 === void 0 ? void 0 : _targetMarkItem2.value)) {
165
201
  var _targetMarkItem, _targetMarkItem2;
166
202
  targetMarkItem = item[i];
167
203
  i++;
168
204
  if (i >= item.length) break;
169
205
  }
170
- if (!((_targetMarkItem3 = targetMarkItem) !== null && _targetMarkItem3 !== void 0 && _targetMarkItem3.value)) return;
206
+ if (!((_targetMarkItem3 = targetMarkItem) === null || _targetMarkItem3 === void 0 ? void 0 : _targetMarkItem3.value)) return;
171
207
  targetMarkItem.isFirst = 1;
172
208
  } else if (position === 'last') {
173
209
  var _targetMarkItem6;
@@ -175,13 +211,13 @@ class ChartComponent extends _react.Component {
175
211
  const l = item.length;
176
212
  let targetMarkItem = item[l - 1],
177
213
  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)) {
214
+ while (!((_targetMarkItem4 = targetMarkItem) === null || _targetMarkItem4 === void 0 ? void 0 : _targetMarkItem4.value) && !Number.isNaN((_targetMarkItem5 = targetMarkItem) === null || _targetMarkItem5 === void 0 ? void 0 : _targetMarkItem5.value)) {
179
215
  var _targetMarkItem4, _targetMarkItem5;
180
216
  targetMarkItem = item[i];
181
217
  i--;
182
218
  if (i < 0) break;
183
219
  }
184
- if (!((_targetMarkItem6 = targetMarkItem) !== null && _targetMarkItem6 !== void 0 && _targetMarkItem6.value)) return;
220
+ if (!((_targetMarkItem6 = targetMarkItem) === null || _targetMarkItem6 === void 0 ? void 0 : _targetMarkItem6.value)) return;
185
221
  targetMarkItem.isLast = 1;
186
222
  } else {
187
223
  console.error('on markFirstOrLast: unknown position');
@@ -229,23 +265,38 @@ class ChartComponent extends _react.Component {
229
265
  y_axis_summary_type,
230
266
  type,
231
267
  title_name,
268
+ x_axis_label_font_size,
269
+ x_axis_label_font_color,
270
+ y_axis_label_font_size,
271
+ y_axis_label_font_color,
232
272
  // left axis - combination chart
233
273
  show_y_axis_left_label,
234
274
  y_axis_left_label_position,
235
275
  y_axis_left_summary_type,
236
276
  y_axis_left_summary_column,
277
+ y_axis_left_label_font_size,
278
+ y_axis_left_label_font_color,
237
279
  // right axis - combination chart
238
280
  show_y_axis_right_label,
239
281
  y_axis_right_label_position,
240
282
  y_axis_right_summary_type,
241
- y_axis_right_summary_column
283
+ y_axis_right_summary_column,
284
+ y_axis_right_label_font_size,
285
+ y_axis_right_label_font_color
242
286
  } = chart.config;
243
287
  if (y_axis_summary_column_key) {
244
288
  y_axis_column_key = y_axis_summary_column_key;
245
289
  }
246
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
247
- let textColor;
248
- this.globalTheme === _constants.THEME_NAME_MAP.DARK ? textColor = '#fff' : textColor = '#999';
290
+ const table = getTableById(tables, table_id);
291
+ const defaultTextColor = this.globalTheme === THEME_NAME_MAP.DARK ? DEFAULT_AXIS_LABEL_FONT_COLOR_DARK : DEFAULT_AXIS_LABEL_FONT_COLOR;
292
+ const xColor = x_axis_label_font_color || defaultTextColor;
293
+ const xFontSize = x_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
294
+ const yColor = y_axis_label_font_color || defaultTextColor;
295
+ const yFontSize = y_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
296
+ const yLeftColor = y_axis_left_label_font_color || defaultTextColor;
297
+ const yLeftFontSize = y_axis_left_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
298
+ const yRightColor = y_axis_right_label_font_color || defaultTextColor;
299
+ const yRightFontSize = y_axis_right_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
249
300
 
250
301
  // xAxis
251
302
  const xAxisID = `chart-x-axis-label_${chart.id}`;
@@ -253,17 +304,18 @@ class ChartComponent extends _react.Component {
253
304
  const {
254
305
  width: containerWidth
255
306
  } = this.chartBoundingClientRect;
307
+ const xTitleHeight = this.getAxisTitleHeight(xFontSize);
256
308
  if (!xLabel && x_axis_show_label) {
257
309
  const div = document.createElement('div');
258
310
  div.id = xAxisID;
259
311
  div.className = 'chart-axis-label';
260
- const column = (0, _dtableUtils.getTableColumnByKey)(table, x_axis_column_key);
312
+ const column = getTableColumnByKey(table, x_axis_column_key);
261
313
  div.innerHTML = `${column ? column.name : ''}`;
262
- div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
314
+ div.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
263
315
  chartContainer.appendChild(div);
264
316
  }
265
317
  if (xLabel && x_axis_show_label) {
266
- xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
318
+ xLabel.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${x_axis_label_position}; position: absolute; bottom: 0;`);
267
319
  }
268
320
  if (xLabel && !x_axis_show_label) {
269
321
  xLabel.parentNode.removeChild(xLabel);
@@ -272,18 +324,18 @@ class ChartComponent extends _react.Component {
272
324
  // yAxis
273
325
  const yAxisID = `chart-y-axis-label_${chart.id}`;
274
326
  const yLabel = chartContainer.querySelector(`#${yAxisID}`);
275
- const divHeight = 20;
327
+ const yTitleHeight = this.getAxisTitleHeight(yFontSize);
276
328
  if (!yLabel && y_axis_show_label) {
277
329
  const div = document.createElement('div');
278
330
  div.id = yAxisID;
279
331
  div.className = 'chart-axis-label';
280
332
  // SCATTER always has y_axis_column_key
281
- if (y_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT && type !== _constants.CHART_TYPE.SCATTER) {
282
- div.innerHTML = _intl.default.get('Amount');
333
+ if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT && type !== CHART_TYPE.SCATTER) {
334
+ div.innerHTML = intl.get('Amount');
283
335
  } else {
284
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_column_key) || {};
336
+ const column = getTableColumnByKey(table, y_axis_column_key) || {};
285
337
  div.innerHTML = column.name || '';
286
- if (type === _constants.CHART_TYPE.BAR_STACK) {
338
+ if (type === CHART_TYPE.BAR_STACK) {
287
339
  div.innerHTML = title_name || '';
288
340
  }
289
341
  }
@@ -291,9 +343,9 @@ class ChartComponent extends _react.Component {
291
343
  height: containerHeight
292
344
  } = this.chartBoundingClientRect;
293
345
  let textAlign = 'center';
294
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
295
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
296
- 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)`);
346
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
347
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
348
+ div.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
297
349
  chartContainer.appendChild(div);
298
350
  }
299
351
  if (yLabel && y_axis_show_label) {
@@ -301,9 +353,9 @@ class ChartComponent extends _react.Component {
301
353
  height: containerHeight
302
354
  } = this.chartBoundingClientRect;
303
355
  let textAlign = 'center';
304
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
305
- if (y_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
306
- 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)`);
356
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
357
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
358
+ yLabel.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
307
359
  }
308
360
  if (yLabel && !y_axis_show_label) {
309
361
  yLabel.parentNode.removeChild(yLabel);
@@ -312,21 +364,22 @@ class ChartComponent extends _react.Component {
312
364
  // yAxis(left) - combination chart
313
365
  const yAxisLeftID = `chart-y-axis-left-label_${chart.id}`;
314
366
  const yAxisLeftLabel = chartContainer.querySelector(`#${yAxisLeftID}`);
367
+ const yLeftTitleHeight = this.getAxisTitleHeight(yLeftFontSize);
315
368
  if (!yAxisLeftLabel && show_y_axis_left_label) {
316
369
  const div = document.createElement('div');
317
370
  div.id = yAxisLeftID;
318
371
  div.className = 'chart-axis-label text-truncate';
319
- if (y_axis_left_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
320
- div.innerHTML = _intl.default.get('Amount');
372
+ if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
373
+ div.innerHTML = intl.get('Amount');
321
374
  } else {
322
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_left_summary_column) || {};
375
+ const column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
323
376
  div.innerHTML = column.name || '';
324
377
  }
325
378
  const containerHeight = chartContainer.offsetHeight;
326
379
  let textAlign = 'center';
327
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
328
- if (y_axis_left_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
329
- 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)`);
380
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
381
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
382
+ div.setAttribute('style', `color:${yLeftColor}; font-size:${yLeftFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yLeftTitleHeight}px; line-height: ${yLeftTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yLeftTitleHeight)}`);
330
383
  chartContainer.appendChild(div);
331
384
  }
332
385
  if (yAxisLeftLabel && show_y_axis_left_label) {
@@ -334,7 +387,7 @@ class ChartComponent extends _react.Component {
334
387
  let textAlign = 'center';
335
388
  if (y_axis_left_label_position === 'bottom') textAlign = 'left';
336
389
  if (y_axis_left_label_position === 'top') textAlign = 'right';
337
- 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)`);
390
+ yAxisLeftLabel.setAttribute('style', `color:${yLeftColor}; font-size:${yLeftFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yLeftTitleHeight}px; line-height: ${yLeftTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yLeftTitleHeight)}`);
338
391
  }
339
392
  if (yAxisLeftLabel && !show_y_axis_left_label) {
340
393
  yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
@@ -343,21 +396,22 @@ class ChartComponent extends _react.Component {
343
396
  // yAxis(right) - combination chart
344
397
  const yAxisRightID = `chart-y-axis-right-label_${chart.id}`;
345
398
  const yAxisRightLabel = chartContainer.querySelector(`#${yAxisRightID}`);
399
+ const yRightTitleHeight = this.getAxisTitleHeight(yRightFontSize);
346
400
  if (!yAxisRightLabel && show_y_axis_right_label) {
347
401
  const div = document.createElement('div');
348
402
  div.id = yAxisRightID;
349
403
  div.className = 'chart-axis-label text-truncate';
350
- if (y_axis_right_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
351
- div.innerHTML = _intl.default.get('Amount');
404
+ if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
405
+ div.innerHTML = intl.get('Amount');
352
406
  } else {
353
- const column = (0, _dtableUtils.getTableColumnByKey)(table, y_axis_right_summary_column) || {};
407
+ const column = getTableColumnByKey(table, y_axis_right_summary_column) || {};
354
408
  div.innerHTML = column.name || '';
355
409
  }
356
410
  const containerHeight = chartContainer.offsetHeight;
357
411
  let textAlign = 'center';
358
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
359
- if (y_axis_right_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
360
- 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)`);
412
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
413
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
414
+ div.setAttribute('style', `color:${yRightColor}; font-size:${yRightFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yRightTitleHeight}px; line-height: ${yRightTitleHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yRightTitleHeight, 'right')}`);
361
415
  chartContainer.appendChild(div);
362
416
  }
363
417
  if (yAxisRightLabel && show_y_axis_right_label) {
@@ -365,11 +419,16 @@ class ChartComponent extends _react.Component {
365
419
  let textAlign = 'center';
366
420
  if (y_axis_right_label_position === 'bottom') textAlign = 'left';
367
421
  if (y_axis_right_label_position === 'top') textAlign = 'right';
368
- 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)`);
422
+ yAxisRightLabel.setAttribute('style', `color:${yRightColor}; font-size:${yRightFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yRightTitleHeight}px; line-height: ${yRightTitleHeight}px; text-align: ${textAlign}; top: 0; right: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yRightTitleHeight, 'right')}`);
369
423
  }
370
424
  if (yAxisRightLabel && !show_y_axis_right_label) {
371
425
  yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
372
426
  }
427
+ this.setAxisTitlePadding(chartContainer, {
428
+ left: y_axis_show_label ? yTitleHeight : show_y_axis_left_label ? yLeftTitleHeight : null,
429
+ right: show_y_axis_right_label ? yRightTitleHeight : null,
430
+ bottom: x_axis_show_label ? xTitleHeight : null
431
+ });
373
432
  };
374
433
  this.renderHorizontalLabel = (chart, tables, chartContainer) => {
375
434
  if (!this.chart || !chart) return;
@@ -381,85 +440,97 @@ class ChartComponent extends _react.Component {
381
440
  horizontal_axis_label_position,
382
441
  vertical_axis_label_position,
383
442
  show_vertical_axis_label,
384
- show_horizontal_axis_label
443
+ show_horizontal_axis_label,
444
+ horizontal_axis_label_font_size,
445
+ horizontal_axis_label_font_color,
446
+ vertical_axis_label_font_size,
447
+ vertical_axis_label_font_color
385
448
  } = chart.config;
386
- const table = (0, _dtableUtils.getTableById)(tables, table_id);
387
- const textColor = '#999999';
449
+ const table = getTableById(tables, table_id);
450
+ const defaultTextColor = this.globalTheme === THEME_NAME_MAP.DARK ? DEFAULT_AXIS_LABEL_FONT_COLOR_DARK : DEFAULT_AXIS_LABEL_FONT_COLOR;
451
+ const xColor = horizontal_axis_label_font_color || defaultTextColor;
452
+ const xFontSize = horizontal_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
453
+ const yColor = vertical_axis_label_font_color || defaultTextColor;
454
+ const yFontSize = vertical_axis_label_font_size || DEFAULT_AXIS_LABEL_FONT_SIZE;
388
455
  const xAxisID = `chart-x-axis-label_${chart.id}`;
389
456
  const xLabel = chartContainer.querySelector(`#${xAxisID}`);
390
457
  const {
391
458
  width: containerWidth
392
459
  } = this.chartBoundingClientRect;
460
+ const xTitleHeight = this.getAxisTitleHeight(xFontSize);
393
461
  if (!xLabel && show_horizontal_axis_label) {
394
462
  const div = document.createElement('div');
395
463
  div.id = xAxisID;
396
464
  div.className = 'chart-axis-label';
397
- if (horizontal_axis_summary_type === _constants.CHART_SUMMARY_TYPE.COUNT) {
398
- div.innerHTML = _intl.default.get('Amount');
465
+ if (horizontal_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
466
+ div.innerHTML = intl.get('Amount');
399
467
  } else {
400
- const column = (0, _dtableUtils.getTableColumnByKey)(table, horizontal_axis_column_key);
468
+ const column = getTableColumnByKey(table, horizontal_axis_column_key);
401
469
  div.innerHTML = `${column ? column.name : ''}`;
402
470
  }
403
- div.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
471
+ div.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
404
472
  chartContainer.appendChild(div);
405
473
  }
406
474
  if (xLabel && show_horizontal_axis_label) {
407
- xLabel.setAttribute('style', `color:${textColor}; width: ${containerWidth}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
475
+ xLabel.setAttribute('style', `color:${xColor}; font-size:${xFontSize}px; width: ${containerWidth}px; height: ${xTitleHeight}px; line-height: ${xTitleHeight}px; text-align: ${horizontal_axis_label_position}; position: absolute`);
408
476
  }
409
477
  if (xLabel && !show_horizontal_axis_label) {
410
478
  xLabel.parentNode.removeChild(xLabel);
411
479
  }
412
480
  const yAxisID = `chart-y-axis-label_${chart.id}`;
413
481
  const yLabel = chartContainer.querySelector(`#${yAxisID}`);
414
- const divHeight = 20;
482
+ const yTitleHeight = this.getAxisTitleHeight(yFontSize);
415
483
  if (!yLabel && show_vertical_axis_label) {
416
484
  const div = document.createElement('div');
417
485
  div.id = yAxisID;
418
486
  div.className = 'chart-axis-label';
419
- const column = (0, _dtableUtils.getTableColumnByKey)(table, vertical_axis_column_key) || {};
487
+ const column = getTableColumnByKey(table, vertical_axis_column_key) || {};
420
488
  div.innerHTML = column.name || '';
421
489
  const {
422
490
  height: containerHeight
423
491
  } = this.chartBoundingClientRect;
424
492
  let textAlign = 'center';
425
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
426
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
427
- 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)`);
493
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
494
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
495
+ div.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
428
496
  chartContainer.appendChild(div);
429
497
  }
430
- if (yLabel && show_horizontal_axis_label) {
498
+ if (yLabel && show_vertical_axis_label) {
431
499
  const {
432
500
  height: containerHeight
433
501
  } = this.chartBoundingClientRect;
434
502
  let textAlign = 'center';
435
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
436
- if (vertical_axis_label_position === _constants.LABEL_POSITION_TYPE.TOP) textAlign = 'right';
437
- 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)`);
503
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
504
+ if (vertical_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
505
+ yLabel.setAttribute('style', `color:${yColor}; font-size:${yFontSize}px; position: absolute; width: ${containerHeight}px; height: ${yTitleHeight}px; line-height: ${yTitleHeight}px; text-align: ${textAlign}; top: 0; left: 0; transform: ${this.getRotatedAxisTitleTransform(containerHeight, yTitleHeight)}`);
438
506
  }
439
- if (yLabel && !show_horizontal_axis_label) {
507
+ if (yLabel && !show_vertical_axis_label) {
440
508
  yLabel.parentNode.removeChild(yLabel);
441
509
  }
442
- };
443
- this.isShowVerticalAxisLabel = chart => {
444
- return !!(chart && chart.config && chart.config.show_vertical_axis_label);
445
- };
446
- this.isShowHorizontalAxisLabel = chart => {
447
- return !!(chart && chart.config && chart.config.show_horizontal_axis_label);
510
+ this.setAxisTitlePadding(chartContainer, {
511
+ left: show_vertical_axis_label ? yTitleHeight : null,
512
+ bottom: show_horizontal_axis_label ? xTitleHeight : null,
513
+ right: null
514
+ });
448
515
  };
449
516
  this.formatterLegendName = name => {
450
- if (!name && typeof name !== 'number' || name.trim() === 'undefined' || name.trim() === 'null') {
451
- return _intl.default.get(_constants.EMPTY_NAME);
517
+ if (typeof name !== 'string') {
518
+ if (!name && typeof name !== 'number') return intl.get(EMPTY_NAME);
519
+ return intl.get(String(name)) || String(name);
520
+ }
521
+ if (name.trim() === 'undefined' || name.trim() === 'null' || name.trim() === '') {
522
+ return intl.get(EMPTY_NAME);
452
523
  } else if (name === '_Others') {
453
- return _intl.default.get('Others');
524
+ return intl.get('Others');
454
525
  } else {
455
- return _intl.default.get(name) || name;
526
+ return intl.get(name) || name;
456
527
  }
457
528
  };
458
529
  this.setLegend = _ref => {
459
530
  var _chart$config, _chart$config2;
460
531
  let {
461
532
  legendName,
462
- theme = _constants.CHART_THEME_COLOR['light'],
533
+ theme = CHART_THEME_COLOR['light'],
463
534
  legendPosition = 'top-left',
464
535
  data,
465
536
  colorScale,
@@ -468,8 +539,8 @@ class ChartComponent extends _react.Component {
468
539
  } = _ref;
469
540
  if (!this.chart) return;
470
541
  this.legendConfig = {
471
- 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,
472
- 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,
542
+ 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,
543
+ 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,
473
544
  r: this.getLegendR(chart),
474
545
  legendItemPaddingTop: 5,
475
546
  legendItemTextPaddingTop: 13,
@@ -483,8 +554,9 @@ class ChartComponent extends _react.Component {
483
554
  };
484
555
 
485
556
  // sort legend data and format data
486
- data.forEach(item => item[legendName] = String(item[legendName]));
487
- const legendData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), legendName, groupColumn, chart);
557
+ const clonedData = cloneDeep(data);
558
+ clonedData.forEach(item => item[legendName] = String(item[legendName]));
559
+ const legendData = BaseUtils.sortDataByGroupName(clonedData, legendName, groupColumn, chart);
488
560
  const {
489
561
  width: chartWidth,
490
562
  height: chartHeight,
@@ -625,7 +697,7 @@ class ChartComponent extends _react.Component {
625
697
  }).append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('y', legendItemPaddingTop).attr('rx', r).attr('fill', _ref4 => {
626
698
  let [groupName] = _ref4;
627
699
  if (colorScale) return colorScale(groupName);
628
- return this.colorMap[groupName] || _constants.CHART_STYLE_COLORS[0];
700
+ return this.colorMap[groupName] || CHART_STYLE_COLORS[0];
629
701
  }).attr('data-text', _ref5 => {
630
702
  let [groupName] = _ref5;
631
703
  return groupName;
@@ -707,7 +779,7 @@ class ChartComponent extends _react.Component {
707
779
  if (top && bottom) {
708
780
  let allHeight = top;
709
781
  const groupsData = [];
710
- const newLegendData = (0, _lodashEs.cloneDeep)(legendData);
782
+ const newLegendData = cloneDeep(legendData);
711
783
  let lastIndex = 0;
712
784
  legendData.forEach((item, index) => {
713
785
  const virtualLegend = this.chart.append('g').attr('opacity', 0);
@@ -732,7 +804,7 @@ class ChartComponent extends _react.Component {
732
804
  } else {
733
805
  let allWidth = start;
734
806
  const groupsData = [];
735
- const newLegendData = (0, _lodashEs.cloneDeep)(legendData);
807
+ const newLegendData = cloneDeep(legendData);
736
808
  let lastIndex = 0;
737
809
  legendData.forEach((item, index) => {
738
810
  const virtualLegend = this.chart.append('g').attr('opacity', 0);
@@ -822,13 +894,13 @@ class ChartComponent extends _react.Component {
822
894
  this.sortLegend = (result, groupColumn, legendName) => {
823
895
  result.forEach(item => {
824
896
  const option = groupColumn.data.options.find(option => option.name === item[legendName]);
825
- if (option !== null && option !== void 0 && option.id) {
897
+ if (option === null || option === void 0 ? void 0 : option.id) {
826
898
  item['group_name_id'] = option.id;
827
899
  item['oldName'] = item.name;
828
900
  item.name = item['group_name_id'];
829
901
  }
830
902
  });
831
- _utils.BaseUtils.sortCharts(result, groupColumn, 'name');
903
+ BaseUtils.sortCharts(result, groupColumn, 'name');
832
904
  result.forEach(item => {
833
905
  item.name = item['oldName'];
834
906
  });
@@ -841,8 +913,8 @@ class ChartComponent extends _react.Component {
841
913
  const {
842
914
  type
843
915
  } = config;
844
- if (type === _constants.CHART_TYPE.SCATTER) return 4;
845
- if (type === _constants.CHART_TYPE.MIRROR) return 0;
916
+ if (type === CHART_TYPE.SCATTER) return 4;
917
+ if (type === CHART_TYPE.MIRROR) return 0;
846
918
  return 3;
847
919
  };
848
920
  this.calcEquilateralTriangle = (cx, cy, size, direction) => {
@@ -856,12 +928,12 @@ class ChartComponent extends _react.Component {
856
928
  let groupName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'group_name';
857
929
  let groupColumn = arguments.length > 3 ? arguments[3] : undefined;
858
930
  let chart = arguments.length > 4 ? arguments[4] : undefined;
859
- const newData = _utils.BaseUtils.sortDataByGroupName((0, _lodashEs.cloneDeep)(data), groupName, groupColumn, chart);
931
+ const newData = BaseUtils.sortDataByGroupName(cloneDeep(data), groupName, groupColumn, chart);
860
932
  let currentIdx = 0;
861
- const defaultColors = _constants.CHART_STYLE_COLORS;
933
+ const defaultColors = CHART_STYLE_COLORS;
862
934
  let colors = defaultColors;
863
935
  if (chartColorTheme) {
864
- colors = _utils.BaseUtils.getCurrentTheme(chartColorTheme).colors;
936
+ colors = BaseUtils.getCurrentTheme(chartColorTheme).colors;
865
937
  }
866
938
  const colorMap = newData.reduce((acc, cur) => {
867
939
  const key = cur[groupName] || cur[groupName] === 0 ? cur[groupName] : '';
@@ -961,37 +1033,25 @@ class ChartComponent extends _react.Component {
961
1033
  formatted_value: item.formatted_value + ''
962
1034
  });
963
1035
  }
964
- if (type === _constants.CHART_TYPE.WORLD_MAP_BUBBLE) {
1036
+ if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
965
1037
  sum += item.value;
966
1038
  }
967
1039
  }
968
1040
  }
969
1041
  });
970
- if (type === _constants.CHART_TYPE.WORLD_MAP_BUBBLE) {
1042
+ if (type === CHART_TYPE.WORLD_MAP_BUBBLE) {
971
1043
  statisticNewData.sum = sum;
972
1044
  }
973
1045
  return statisticNewData;
974
1046
  };
975
- this.isShowXAxisLabel = chart => {
976
- return !!(chart && chart.config && chart.config.x_axis_show_label);
977
- };
978
- this.isShowYAxisLabel = chart => {
979
- return !!(chart && chart.config && chart.config.y_axis_show_label);
980
- };
981
- this.isShowYAxisLeftLabel = chart => {
982
- return !!(chart && chart.config && chart.config.show_y_axis_left_label);
983
- };
984
- this.isShowYAxisRightLabel = chart => {
985
- return !!(chart && chart.config && chart.config.show_y_axis_right_label);
986
- };
987
1047
  this.getThemeColors = function () {
988
1048
  let themeColors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
989
1049
  let theme = arguments.length > 1 ? arguments[1] : undefined;
990
1050
  // dark->custom->light
991
- if (theme === _constants.THEME_NAME_MAP.DARK) {
992
- themeColors = _constants.CHART_THEME_COLOR.dark;
1051
+ if (theme === THEME_NAME_MAP.DARK) {
1052
+ themeColors = CHART_THEME_COLOR.dark;
993
1053
  }
994
- return themeColors || _constants.CHART_THEME_COLOR[_constants.THEME_NAME_MAP.LIGHT];
1054
+ return themeColors || CHART_THEME_COLOR[THEME_NAME_MAP.LIGHT];
995
1055
  };
996
1056
  this.setDispalyGoalLine = (goal_label, goal_value, insertPadding, yScale) => {
997
1057
  const {
@@ -1012,7 +1072,7 @@ class ChartComponent extends _react.Component {
1012
1072
  label_font_size,
1013
1073
  text
1014
1074
  } = _ref6;
1015
- 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 => {
1075
+ 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 => {
1016
1076
  if (!g.node()) return;
1017
1077
  const {
1018
1078
  width
@@ -1031,7 +1091,7 @@ class ChartComponent extends _react.Component {
1031
1091
  label_font_size,
1032
1092
  text
1033
1093
  } = _ref7;
1034
- 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 => {
1094
+ 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 => {
1035
1095
  if (g.node()) {
1036
1096
  var _g$node;
1037
1097
  const {
@@ -1053,7 +1113,7 @@ class ChartComponent extends _react.Component {
1053
1113
  label_font_size,
1054
1114
  text
1055
1115
  } = _ref8;
1056
- 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 => {
1116
+ 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 => {
1057
1117
  if (!g.node()) return;
1058
1118
  const {
1059
1119
  width,
@@ -1061,7 +1121,7 @@ class ChartComponent extends _react.Component {
1061
1121
  } = g.node().getBoundingClientRect();
1062
1122
  const translateX = Number(x) + xWidth / 2 - width / 2;
1063
1123
  let translateY = Number(y) + Number(yheight / 2) + height / 2;
1064
- if (chartType === _constants.CHART_TYPE.BAR_STACK) {
1124
+ if (chartType === CHART_TYPE.BAR_STACK) {
1065
1125
  translateY = translateY;
1066
1126
  }
1067
1127
  g.attr('transform', `translate(${translateX}, ${translateY})`);
@@ -1072,8 +1132,8 @@ class ChartComponent extends _react.Component {
1072
1132
  allGroup.forEach(g => {
1073
1133
  const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
1074
1134
  rects.forEach(item => {
1075
- d3.select(item).transition().duration(this.transitionDuration).attr('opacity', 1);
1076
- if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
1135
+ d3.select(item).transition().duration(this.interactionDuration).attr('opacity', 1);
1136
+ if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
1077
1137
  d3.select(item).attr('stroke-width', 2);
1078
1138
  }
1079
1139
  });
@@ -1084,9 +1144,9 @@ class ChartComponent extends _react.Component {
1084
1144
  const rects = Array.from(g.children).filter(item => item.tagName !== 'text');
1085
1145
  rects.forEach(item => {
1086
1146
  if (item.getAttribute('data-groupName') !== curGroupName) {
1087
- d3.selectAll([item]).transition().duration(this.transitionDuration).attr('opacity', 0.3);
1147
+ d3.selectAll([item]).transition().duration(this.interactionDuration).attr('opacity', 0.3);
1088
1148
  } else {
1089
- if ([_constants.CHART_TYPE.PIE, _constants.CHART_TYPE.RING].includes(chartType)) {
1149
+ if ([CHART_TYPE.PIE, CHART_TYPE.RING].includes(chartType)) {
1090
1150
  d3.select(item).attr('stroke-width', 0.5);
1091
1151
  }
1092
1152
  }
@@ -1094,37 +1154,222 @@ class ChartComponent extends _react.Component {
1094
1154
  });
1095
1155
  }
1096
1156
  };
1097
- // Use clipPath to make rectangle rounded corners
1098
1157
  this.addClipPath = _ref9 => {
1099
1158
  let {
1100
1159
  rect,
1101
- parentNode,
1102
1160
  attr,
1103
- rectId,
1104
1161
  borderRadiusVal
1105
1162
  } = _ref9;
1163
+ return this.addRoundedClip(rect, attr === 'x' ? 'x' : 'y', null, borderRadiusVal);
1164
+ };
1165
+ this.addRoundedClip = function (rect, orient) {
1166
+ let width = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
1167
+ let radiusOverride = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1106
1168
  const {
1107
1169
  borderRadius
1108
- } = this.chartBoundingClientRect;
1109
- const clipRect = d3.select(rect.cloneNode());
1110
- if (attr === 'x') {
1111
- const rectHeight = Number(rect.getAttribute('height'));
1112
- const rectWidth = Number(rect.getAttribute('width'));
1113
- const computedBorderRadius = Math.min(rectHeight * borderRadius, rectWidth / 2);
1114
- const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1115
- clipRect.attr('rx', safeBorderRadius);
1116
- clipRect.attr('x', Number(rect.getAttribute('x')) - safeBorderRadius).attr('width', rectWidth + safeBorderRadius);
1170
+ } = _this.chartBoundingClientRect;
1171
+ const x = Number(rect.getAttribute('x'));
1172
+ const y = Number(rect.getAttribute('y'));
1173
+ const w = width != null ? width : Number(rect.getAttribute('width'));
1174
+ const h = Number(rect.getAttribute('height'));
1175
+ const computedRadius = orient === 'x' ? Math.min(h * borderRadius, h / 2, w / 2) : Math.min(w * borderRadius, w / 2, h / 2);
1176
+ const radius = radiusOverride != null ? Math.min(radiusOverride, w / 2, h / 2) : computedRadius;
1177
+ const d = orient === 'x' ? _this.getRightRoundedRectPath(x, y, w, h, radius) : _this.getTopRoundedRectPath(x, y, w, h, radius);
1178
+ const clipId = `rounded-clip-${Math.random().toString(36).slice(2)}`;
1179
+ const path = _this.getDefs().append('clipPath').attr('id', clipId).append('path').attr('class', 'rounded-clip-path').attr('data-x', x).attr('data-y', y).attr('data-width', w).attr('data-height', h).attr('data-radius', radius).attr('data-orient', orient).attr('d', d);
1180
+ d3.select(rect).attr('clip-path', `url(#${clipId})`);
1181
+ _this._clipMaskByRect.set(rect, path.node());
1182
+ return path.node();
1183
+ };
1184
+ this.animateMaskForRect = (rect, orient, baseline, t) => {
1185
+ const path = this._clipMaskByRect && this._clipMaskByRect.get(rect);
1186
+ if (!path) return;
1187
+ const x = Number(path.getAttribute('data-x'));
1188
+ const y = Number(path.getAttribute('data-y'));
1189
+ const width = Number(path.getAttribute('data-width'));
1190
+ const height = Number(path.getAttribute('data-height'));
1191
+ const radius = Number(path.getAttribute('data-radius'));
1192
+ const el = d3.select(path);
1193
+ if (orient === 'x') {
1194
+ const interpX = d3.interpolateNumber(baseline, x);
1195
+ const interpW = d3.interpolateNumber(0, width);
1196
+ el.attr('d', this.getRightRoundedRectPath(baseline, y, 0, height, radius)).transition(t).attrTween('d', () => tt => this.getRightRoundedRectPath(interpX(tt), y, interpW(tt), height, radius));
1117
1197
  } else {
1118
- const rectWidth = Number(rect.getAttribute('width'));
1119
- const rectHeight = Number(rect.getAttribute('height'));
1120
- const computedBorderRadius = Math.min(rectWidth * borderRadius, rectHeight / 2);
1121
- const safeBorderRadius = Math.min(borderRadiusVal !== null && borderRadiusVal !== void 0 ? borderRadiusVal : computedBorderRadius, rectWidth / 2, rectHeight / 2);
1122
- clipRect.attr('rx', safeBorderRadius);
1123
- clipRect.attr('height', rectHeight + safeBorderRadius);
1198
+ const interpY = d3.interpolateNumber(baseline, y);
1199
+ const interpH = d3.interpolateNumber(0, height);
1200
+ el.attr('d', this.getTopRoundedRectPath(x, baseline, width, 0, radius)).transition(t).attrTween('d', () => tt => this.getTopRoundedRectPath(x, interpY(tt), width, interpH(tt), radius));
1124
1201
  }
1125
- const clipPath = d3.select(parentNode).append('clipPath').attr('opacity', 1).attr('id', rectId);
1126
- clipPath.node().appendChild(clipRect.node());
1127
- d3.select(rect).attr('clip-path', `url(#${rectId})`);
1202
+ };
1203
+ this.getTopRoundedRectPath = (x, y, width, height, radius) => {
1204
+ const r = Math.min(radius, width / 2, height / 2);
1205
+ if (height <= 0) return `M${x},${y} L${x + width},${y} L${x + width},${y} L${x},${y} Z`;
1206
+ return `M${x},${y + r} Q${x},${y} ${x + r},${y} L${x + width - r},${y} Q${x + width},${y} ${x + width},${y + r} L${x + width},${y + height} L${x},${y + height} Z`;
1207
+ };
1208
+ this.getRightRoundedRectPath = (x, y, width, height, radius) => {
1209
+ const r = Math.min(radius, width / 2, height / 2);
1210
+ if (width <= 0) return `M${x},${y} L${x},${y + height} L${x},${y + height} L${x},${y} Z`;
1211
+ return `M${x},${y} L${x + width - r},${y} Q${x + width},${y} ${x + width},${y + r} L${x + width},${y + height - r} Q${x + width},${y + height} ${x + width - r},${y + height} L${x},${y + height} Z`;
1212
+ };
1213
+ this.animateRectGrowInY = function (selection) {
1214
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
1215
+ if (!selection || selection.empty()) return;
1216
+ const self = _this;
1217
+ selection.each(function () {
1218
+ const finalY = Number(this.getAttribute('y'));
1219
+ const finalHeight = Number(this.getAttribute('height'));
1220
+ if (!(finalHeight > 0)) return;
1221
+ const baseline = finalY + finalHeight;
1222
+ const t = d3.transition(self.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
1223
+ d3.select(this).attr('y', baseline).attr('height', 0).transition(t).attr('y', finalY).attr('height', finalHeight);
1224
+ self.animateMaskForRect(this, 'y', baseline, t);
1225
+ });
1226
+ };
1227
+ this.animateStackGrowInY = function (selection) {
1228
+ let groupKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node => node.getAttribute('x');
1229
+ let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
1230
+ if (!selection || selection.empty()) return null;
1231
+ const columns = new Map();
1232
+ selection.each(function () {
1233
+ if (!(Number(this.getAttribute('height')) > 0)) return;
1234
+ const key = groupKey(this);
1235
+ if (!columns.has(key)) columns.set(key, []);
1236
+ columns.get(key).push(this);
1237
+ });
1238
+ if (columns.size === 0) return null;
1239
+ const t = d3.transition(_this.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
1240
+ columns.forEach(rects => {
1241
+ let baselineY = -Infinity;
1242
+ rects.forEach(rect => {
1243
+ baselineY = Math.max(baselineY, Number(rect.getAttribute('y')) + Number(rect.getAttribute('height')));
1244
+ });
1245
+ rects.forEach(rect => {
1246
+ const finalY = Number(rect.getAttribute('y'));
1247
+ const finalHeight = Number(rect.getAttribute('height'));
1248
+ d3.select(rect).attr('y', baselineY).attr('height', 0).transition(t).attr('y', finalY).attr('height', finalHeight);
1249
+ _this.animateMaskForRect(rect, 'y', baselineY, t);
1250
+ });
1251
+ });
1252
+ return t;
1253
+ };
1254
+ this.animateRectGrowInX = function (selection) {
1255
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
1256
+ if (!selection || selection.empty()) return;
1257
+ const self = _this;
1258
+ selection.each(function () {
1259
+ const finalX = Number(this.getAttribute('x'));
1260
+ const finalWidth = Number(this.getAttribute('width'));
1261
+ if (!(finalWidth > 0)) return;
1262
+ const t = d3.transition(self.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
1263
+ d3.select(this).attr('width', 0).transition(t).attr('width', finalWidth);
1264
+ self.animateMaskForRect(this, 'x', finalX, t);
1265
+ });
1266
+ };
1267
+ this.animateStackGrowInX = function (selection) {
1268
+ let groupKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : node => node.getAttribute('y');
1269
+ let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
1270
+ if (!selection || selection.empty()) return null;
1271
+ const rows = new Map();
1272
+ selection.each(function () {
1273
+ if (!(Number(this.getAttribute('width')) > 0)) return;
1274
+ const key = groupKey(this);
1275
+ if (!rows.has(key)) rows.set(key, []);
1276
+ rows.get(key).push(this);
1277
+ });
1278
+ if (rows.size === 0) return null;
1279
+ const t = d3.transition(_this.enterTransitionName).duration(duration).ease(d3.easeCubicOut);
1280
+ rows.forEach(rects => {
1281
+ let baselineX = Infinity;
1282
+ rects.forEach(rect => {
1283
+ baselineX = Math.min(baselineX, Number(rect.getAttribute('x')));
1284
+ });
1285
+ rects.forEach(rect => {
1286
+ const finalX = Number(rect.getAttribute('x'));
1287
+ const finalWidth = Number(rect.getAttribute('width'));
1288
+ d3.select(rect).attr('x', baselineX).attr('width', 0).transition(t).attr('x', finalX).attr('width', finalWidth);
1289
+ _this.animateMaskForRect(rect, 'x', baselineX, t);
1290
+ });
1291
+ });
1292
+ return t;
1293
+ };
1294
+ this.animateArcGrowIn = function (selection, arc) {
1295
+ let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
1296
+ if (!selection || selection.empty()) return;
1297
+ const transitionName = _this.enterTransitionName;
1298
+ selection.each(function (d) {
1299
+ const path = d3.select(this);
1300
+ const interpolate = d3.interpolate({
1301
+ startAngle: d.startAngle,
1302
+ endAngle: d.startAngle,
1303
+ padAngle: d.padAngle
1304
+ }, {
1305
+ startAngle: d.startAngle,
1306
+ endAngle: d.endAngle,
1307
+ padAngle: d.padAngle
1308
+ });
1309
+ path.attr('d', arc(interpolate(0))).transition(transitionName).duration(duration).ease(d3.easeCubicOut).attrTween('d', () => t => arc(interpolate(t)));
1310
+ });
1311
+ };
1312
+ this.animatePathDrawIn = function (selection) {
1313
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
1314
+ if (!selection || selection.empty()) return;
1315
+ const transitionName = _this.enterTransitionName;
1316
+ selection.each(function () {
1317
+ const path = d3.select(this);
1318
+ let totalLength = 0;
1319
+ try {
1320
+ totalLength = this.getTotalLength();
1321
+ } catch (e) {
1322
+ totalLength = 0;
1323
+ }
1324
+ if (!(totalLength > 0)) return;
1325
+ path.attr('stroke-dasharray', `${totalLength} ${totalLength}`).attr('stroke-dashoffset', totalLength).transition(transitionName).duration(duration).ease(d3.easeLinear).attr('stroke-dashoffset', 0).on('end', function () {
1326
+ d3.select(this).attr('stroke-dasharray', null).attr('stroke-dashoffset', null);
1327
+ });
1328
+ });
1329
+ };
1330
+ this.animateRevealInX = function (selection, width) {
1331
+ let duration = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _this.transitionDuration;
1332
+ if (!selection || selection.empty()) return;
1333
+ const {
1334
+ height: chartHeight
1335
+ } = _this.chartBoundingClientRect;
1336
+ const clipId = `reveal-clip-${Math.random().toString(36).slice(2)}`;
1337
+ const clipPath = _this.getDefs().append('clipPath').attr('id', clipId);
1338
+ const clipRect = clipPath.append('rect').attr('x', 0).attr('y', 0).attr('width', 0).attr('height', chartHeight);
1339
+ selection.attr('clip-path', `url(#${clipId})`);
1340
+ clipRect.transition(_this.enterTransitionName).duration(duration).ease(d3.easeLinear).attr('width', width).on('end', () => {
1341
+ selection.attr('clip-path', null);
1342
+ clipPath.remove();
1343
+ });
1344
+ };
1345
+ this.animateFadeIn = function (selection) {
1346
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
1347
+ let delay = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
1348
+ let finalOpacity = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
1349
+ if (!selection || selection.empty()) return;
1350
+ const transitionName = _this.enterTransitionName;
1351
+ selection.each(function () {
1352
+ const el = d3.select(this);
1353
+ let target = finalOpacity;
1354
+ if (target == null) {
1355
+ const orig = this.getAttribute('opacity');
1356
+ const parsed = orig === null || orig === '' ? 1 : Number(orig);
1357
+ target = Number.isNaN(parsed) ? 1 : parsed;
1358
+ }
1359
+ if (!(target > 0)) return;
1360
+ el.attr('opacity', 0).transition(transitionName).duration(duration).delay(delay).ease(d3.easeLinear).attr('opacity', target);
1361
+ });
1362
+ };
1363
+ this.animateCircleZoomIn = function (selection) {
1364
+ let duration = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _this.transitionDuration;
1365
+ if (!selection || selection.empty()) return;
1366
+ const transitionName = _this.enterTransitionName;
1367
+ selection.each(function () {
1368
+ const circle = d3.select(this);
1369
+ const finalR = Number(this.getAttribute('r')) || 0;
1370
+ if (!(finalR > 0)) return;
1371
+ circle.attr('r', 0).transition(transitionName).duration(duration).ease(d3.easeCubicOut).attr('r', finalR);
1372
+ });
1128
1373
  };
1129
1374
  this.drawYaxis = function (g, theme) {
1130
1375
  let rightAxisOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
@@ -1138,33 +1383,92 @@ class ChartComponent extends _react.Component {
1138
1383
  // add text
1139
1384
  g.selectAll('text').attr('font-size', theme.fontSize);
1140
1385
  g.selectAll('text').attr('fill', theme.textColor);
1386
+ _this.thinYAxisTicks(g);
1141
1387
  _this.checkTextOverflow(g.selectAll('text').nodes());
1142
1388
 
1143
1389
  // line
1144
1390
  g.selectAll('line').node() && g.selectAll('line').node().remove(); // delete the first line
1145
- g.selectAll('.tick line').clone().attr('x2', chartWidth - insertPadding * 2 - _this.horizontalOverflowOffset - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
1391
+ g.selectAll('.tick line').clone().attr('x2', chartWidth - _this.getYAxisTranslateX() - insertPadding - rightAxisOffset).attr('stroke', theme.gridColor).attr('stroke-dasharray', '8,3');
1146
1392
 
1147
1393
  // update g translateX
1148
- g.attr('transform', `translate(${insertPadding + _this.horizontalOverflowOffset}, 0)`);
1394
+ g.attr('transform', `translate(${_this.getYAxisTranslateX()}, 0)`);
1395
+ };
1396
+ this.thinYAxisTicks = g => {
1397
+ const ticks = g.selectAll('.tick').nodes();
1398
+ if (ticks.length <= 2) return;
1399
+ const visibleTicks = ticks.map((tick, index) => {
1400
+ const text = d3.select(tick).select('text').node();
1401
+ if (!text) return null;
1402
+ const {
1403
+ top,
1404
+ bottom
1405
+ } = text.getBoundingClientRect();
1406
+ return {
1407
+ tick,
1408
+ index,
1409
+ top,
1410
+ bottom
1411
+ };
1412
+ }).filter(Boolean).sort((a, b) => a.top - b.top);
1413
+ const keptTicks = [];
1414
+ let prevBottom = -Infinity;
1415
+ visibleTicks.forEach(_ref10 => {
1416
+ let {
1417
+ tick,
1418
+ index,
1419
+ top,
1420
+ bottom
1421
+ } = _ref10;
1422
+ const shouldKeepFirstTick = index === 0;
1423
+ const shouldKeepLastTick = index === ticks.length - 1;
1424
+ const hasEnoughSpace = top > prevBottom + this.yAxisTickLabelGap;
1425
+ if (shouldKeepLastTick) {
1426
+ keptTicks.forEach(keptTick => {
1427
+ if (keptTick.bottom + this.yAxisTickLabelGap >= top) {
1428
+ d3.select(keptTick.tick).attr('opacity', 0);
1429
+ }
1430
+ });
1431
+ d3.select(tick).attr('opacity', 1);
1432
+ return;
1433
+ }
1434
+ if (shouldKeepFirstTick || hasEnoughSpace) {
1435
+ d3.select(tick).attr('opacity', 1);
1436
+ keptTicks.push({
1437
+ tick,
1438
+ bottom
1439
+ });
1440
+ prevBottom = bottom;
1441
+ return;
1442
+ }
1443
+ d3.select(tick).attr('opacity', 0);
1444
+ });
1149
1445
  };
1150
1446
  this.checkTextOverflow = allTextEl => {
1151
1447
  const {
1152
1448
  insertPadding
1153
1449
  } = this.chartBoundingClientRect;
1154
1450
  const allTextWidth = allTextEl.map(item => {
1451
+ const tick = item.parentNode;
1452
+ if (tick && Number(tick.getAttribute('opacity')) === 0) return 0;
1155
1453
  const {
1156
1454
  width
1157
1455
  } = item.getBoundingClientRect();
1158
1456
  return width;
1159
1457
  });
1160
- const maxTextWidth = Math.max(...allTextWidth);
1458
+ const maxTextWidth = Math.max(...allTextWidth, 0);
1161
1459
  this.horizontalOverflowOffset = 0;
1162
- if (maxTextWidth + 3 > insertPadding) {
1163
- // horizontal overflow
1164
- const offset = maxTextWidth + 3 - insertPadding; // 3 is text and line default spacing
1460
+ const requiredLeftSpace = maxTextWidth + 3;
1461
+ if (requiredLeftSpace > insertPadding) {
1462
+ const offset = requiredLeftSpace - insertPadding;
1165
1463
  this.horizontalOverflowOffset = offset;
1166
1464
  }
1167
1465
  };
1466
+ this.getYAxisTranslateX = () => {
1467
+ const {
1468
+ insertPadding
1469
+ } = this.chartBoundingClientRect;
1470
+ return insertPadding + this.horizontalOverflowOffset;
1471
+ };
1168
1472
  this.checkTickOverlap = (g, axis) => {
1169
1473
  const allTicks = g.selectAll('.tick').nodes();
1170
1474
  if (axis === 'yAxis') {
@@ -1316,10 +1620,84 @@ class ChartComponent extends _react.Component {
1316
1620
  const annotationWrapper = contentWrapper.insert('g', ':first-child').attr('class', 'vertical-annotation-wrapper');
1317
1621
  annotationWrapper.append('line').attr('x1', x).attr('y1', insertPadding + marginTop).attr('x2', x).attr('y2', chartHeight - insertPadding).attr('stroke', theme.XAxisColor);
1318
1622
  };
1623
+ this.setLegendForHeatMap = _ref11 => {
1624
+ let {
1625
+ exampleColors,
1626
+ themeColors
1627
+ } = _ref11;
1628
+ const legendOffsetY = 3;
1629
+ const legendItemTextWidth = 32;
1630
+ const legendItemWidth = 12;
1631
+ const legendItemHeight = 12;
1632
+ const legendItemGap = 3;
1633
+ const legendItemRadius = 2;
1634
+ const legendWrapper = this.chart.append('g').attr('class', 'legend-heat-map-wrapper').attr('transform', `translate(0, ${legendOffsetY})`);
1635
+ legendWrapper.append('text').attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(intl.get('Less'));
1636
+ exampleColors.forEach((color, index) => {
1637
+ legendWrapper.append('rect').attr('x', legendItemTextWidth + index * legendItemWidth + index * legendItemGap).attr('width', legendItemWidth).attr('height', legendItemHeight).attr('rx', legendItemRadius).attr('fill', color).attr('stroke', FILL_BORDER_COLOR_MAP[color]).attr('stroke-width', 1);
1638
+ });
1639
+ legendWrapper.append('text').attr('x', 182).attr('y', 10).attr('fill', themeColors.textColor).attr('font-size', 12).attr('font-weight', 'bold').text(intl.get('More'));
1640
+ };
1641
+ this.setContinuousLegend = _ref12 => {
1642
+ var _this$chart$node2;
1643
+ let {
1644
+ previewType,
1645
+ theme,
1646
+ colorRange = [],
1647
+ legendDirection,
1648
+ legendSize,
1649
+ legendTextRange,
1650
+ bubbleColor,
1651
+ type
1652
+ } = _ref12;
1653
+ const {
1654
+ width: chartWidth,
1655
+ height: chartHeight,
1656
+ insertPadding
1657
+ } = this.chartBoundingClientRect;
1658
+ const legendRectWidth = legendDirection === 'vertical' ? 12 : Math.min(legendSize * 100, chartWidth - insertPadding * 2);
1659
+ const legendRectHeight = legendDirection === 'vertical' ? Math.min(legendSize * 100, chartHeight - insertPadding * 2) : 12;
1660
+ const legendTextOffset = 2;
1661
+ const legendTextHeightSpace = legendDirection === 'vertical' ? 0 : 14 + legendTextOffset;
1662
+ if (![CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
1663
+ var _this$chart$node;
1664
+ const gradient = this.chart.append('defs').attr('class', 'linear-gradient-wrapper').append('linearGradient').attr("id", `gradient-${(_this$chart$node = this.chart.node()) === null || _this$chart$node === void 0 ? void 0 : _this$chart$node.id}-${previewType}`).attr("x1", '0%').attr("y1", '0%').attr("x2", legendDirection === 'vertical' ? '0%' : '100%').attr("y2", legendDirection === 'vertical' ? '100%' : '0%');
1665
+ gradient.append('stop').attr('offset', '0%').attr('stop-color', `${colorRange[0]}`);
1666
+ gradient.append('stop').attr('offset', '50%').attr('stop-color', `${colorRange[4]}`);
1667
+ gradient.append('stop').attr('offset', '100%').attr('stop-color', `${colorRange[8]}`);
1668
+ }
1669
+ const continuousLegendWrapper = this.chart.append('g').attr('class', 'legend-continuous-wrapper').attr('transform', `translate(0, ${chartHeight - legendRectHeight - legendTextHeightSpace})`);
1670
+ continuousLegendWrapper.append('rect').attr('width', legendRectWidth).attr('height', legendRectHeight).attr('fill', [CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type) ? bubbleColor : `url(#gradient-${(_this$chart$node2 = this.chart.node()) === null || _this$chart$node2 === void 0 ? void 0 : _this$chart$node2.id}-${previewType})`).call(g => {
1671
+ if ([CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP_BUBBLE].includes(type)) {
1672
+ continuousLegendWrapper.append('polygon').attr('points', `0,0 ${legendRectWidth - 0.5},0 0,${legendRectHeight - 0.5}`).attr('fill', '#fff').attr('stroke', '#fff');
1673
+ }
1674
+ });
1675
+ 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 => {
1676
+ const {
1677
+ height
1678
+ } = g.node().getBoundingClientRect();
1679
+ g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendTextOffset);
1680
+ g.attr('y', legendDirection === 'vertical' ? height : height + legendRectHeight);
1681
+ });
1682
+ 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 => {
1683
+ const {
1684
+ width,
1685
+ height
1686
+ } = g.node().getBoundingClientRect();
1687
+ g.attr('x', legendDirection === 'vertical' ? legendRectWidth + legendTextOffset : legendRectWidth - width);
1688
+ g.attr('y', legendDirection === 'vertical' ? legendRectHeight - legendTextOffset : height + legendRectHeight);
1689
+ });
1690
+ };
1319
1691
  this.initLabelStroke(props === null || props === void 0 ? void 0 : props.globalTheme);
1320
1692
  this.chartBoundingClientRect = {};
1321
- this.transitionDuration = 500;
1693
+ this.transitionDuration = 450;
1694
+ this.interactionDuration = 150;
1322
1695
  this.areaTransitionDuration = 200;
1696
+ this.yAxisTickLabelGap = 4;
1697
+ this.axisTitleMinHeight = 20;
1698
+ this.enterTransitionName = 'enter';
1699
+ this._defs = null;
1700
+ this._clipMaskByRect = new Map();
1323
1701
  }
1324
1702
  componentDidMount() {
1325
1703
  window.addEventListener('resize', this.handleResize);
@@ -1332,5 +1710,4 @@ class ChartComponent extends _react.Component {
1332
1710
  componentWillUnmount() {
1333
1711
  window.removeEventListener('resize', this.handleResize);
1334
1712
  }
1335
- }
1336
- exports.default = ChartComponent;
1713
+ }