sea-chart 0.0.1 → 0.0.2

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 (330) hide show
  1. package/README.md +117 -1
  2. package/dist/api/index.js +101 -0
  3. package/{lib → dist}/components/collaborator/index.js +8 -6
  4. package/{lib → dist}/components/icon/index.css +1 -1
  5. package/{lib → dist}/components/icon/index.js +7 -5
  6. package/dist/components/index.js +8 -0
  7. package/{lib → dist}/components/loading/index.js +4 -2
  8. package/dist/components/number-input/index.js +31 -0
  9. package/{lib → dist}/components/pixel-editor/index.css +4 -4
  10. package/{lib → dist}/components/pixel-editor/index.js +11 -15
  11. package/{lib → dist}/components/select-group/index.css +10 -10
  12. package/dist/components/select-group/index.js +52 -0
  13. package/dist/components/types-dialog/index.css +97 -0
  14. package/dist/components/types-dialog/index.js +117 -0
  15. package/{lib → dist}/constants/geolocation.js +3 -3
  16. package/dist/constants/index.js +184 -0
  17. package/{lib → dist}/constants/model.js +25 -5
  18. package/dist/constants/style.js +15 -0
  19. package/dist/constants/type-image.js +59 -0
  20. package/dist/constants/type.js +124 -0
  21. package/dist/context.js +83 -0
  22. package/dist/editor/index.js +41 -0
  23. package/dist/index.js +9 -0
  24. package/dist/intl.js +37 -0
  25. package/dist/locale/index.js +18 -0
  26. package/{lib → dist}/locale/lang/de.js +1 -1
  27. package/{lib → dist}/locale/lang/en.js +1 -1
  28. package/{lib → dist}/locale/lang/es.js +1 -1
  29. package/{lib → dist}/locale/lang/fr.js +1 -1
  30. package/{lib → dist}/locale/lang/pt.js +1 -1
  31. package/{lib → dist}/locale/lang/ru.js +1 -1
  32. package/{lib → dist}/locale/lang/zh_CN.js +1 -1
  33. package/dist/model/area-group.js +41 -0
  34. package/dist/model/area.js +32 -0
  35. package/dist/model/bar-group.js +44 -0
  36. package/dist/model/bar-stack.js +41 -0
  37. package/dist/model/bar.js +38 -0
  38. package/dist/model/base-model.js +9 -0
  39. package/dist/model/basic-number-card.js +22 -0
  40. package/dist/model/chart.js +23 -0
  41. package/dist/model/combination.js +38 -0
  42. package/dist/model/compare-bar.js +39 -0
  43. package/dist/model/completeness-group.js +24 -0
  44. package/dist/model/completeness.js +18 -0
  45. package/dist/model/dashboard.js +16 -0
  46. package/dist/model/generic-model.js +224 -0
  47. package/dist/model/heat-map.js +23 -0
  48. package/dist/model/horizontal-bar.js +38 -0
  49. package/dist/model/horizontal-group-bar.js +43 -0
  50. package/dist/model/index.js +63 -0
  51. package/dist/model/line-group.js +44 -0
  52. package/dist/model/line.js +38 -0
  53. package/dist/model/map-bubble.js +27 -0
  54. package/dist/model/map.js +27 -0
  55. package/dist/model/mirror.js +26 -0
  56. package/dist/model/pie.js +26 -0
  57. package/dist/model/ring.js +26 -0
  58. package/dist/model/scatter.js +19 -0
  59. package/dist/model/stacked-horizontal-bar.js +32 -0
  60. package/dist/model/table.js +23 -0
  61. package/dist/model/tree-map.js +20 -0
  62. package/dist/model/trend.js +24 -0
  63. package/dist/model/user.js +15 -0
  64. package/dist/model/world-map-bubble.js +26 -0
  65. package/dist/model/world-map.js +26 -0
  66. package/{lib/components → dist}/settings/advance-bar-settings/data-settings.js +68 -45
  67. package/dist/settings/advance-bar-settings/style-settings.js +161 -0
  68. package/{lib/components → dist}/settings/bar-settings/data-settings.js +76 -51
  69. package/dist/settings/bar-settings/style-settings.js +179 -0
  70. package/dist/settings/basic-number-card/data-settings.js +126 -0
  71. package/dist/settings/basic-number-card/style-settings.js +42 -0
  72. package/dist/settings/combination-settings/data-settings.js +279 -0
  73. package/dist/settings/combination-settings/style-settings.js +174 -0
  74. package/dist/settings/dashboard-settings/data-settings.js +179 -0
  75. package/{lib/components → dist}/settings/data-settings.js +28 -22
  76. package/dist/settings/horizontal-bar-settings/data-settings.js +55 -0
  77. package/dist/settings/horizontal-bar-settings/style-settings.js +46 -0
  78. package/dist/settings/index.css +85 -0
  79. package/dist/settings/index.js +76 -0
  80. package/{lib/components → dist}/settings/pie-settings/data-settings.js +67 -44
  81. package/{lib/components → dist}/settings/pie-settings/style-settings.js +67 -49
  82. package/dist/settings/style-settings.js +118 -0
  83. package/{lib/components → dist}/settings/table-settings/data-settings.js +269 -208
  84. package/{lib/components → dist}/settings/time-comparison-settings/data-settings.js +82 -67
  85. package/dist/settings/time-comparison-settings/style-settings.js +213 -0
  86. package/dist/settings/widgets/basic-summary/index.css +12 -0
  87. package/dist/settings/widgets/basic-summary/index.js +176 -0
  88. package/{lib/components/settings/widgets/statistic-type → dist/settings/widgets/chart-type}/index.css +5 -5
  89. package/dist/settings/widgets/chart-type/index.js +59 -0
  90. package/{lib/components → dist}/settings/widgets/common-data-settings.js +24 -18
  91. package/dist/settings/widgets/data-filter/index.css +17 -0
  92. package/{lib/components → dist}/settings/widgets/data-filter/index.js +51 -37
  93. package/dist/settings/widgets/data-sort.js +44 -0
  94. package/dist/settings/widgets/date-summary-item.js +111 -0
  95. package/dist/settings/widgets/display-values-settings/index.css +13 -0
  96. package/{lib/components → dist}/settings/widgets/display-values-settings/index.js +19 -14
  97. package/{lib/components → dist}/settings/widgets/divider/index.css +1 -1
  98. package/dist/settings/widgets/divider/index.js +12 -0
  99. package/{lib/components → dist}/settings/widgets/font-settings/font-size-settings.js +14 -12
  100. package/{lib/components → dist}/settings/widgets/font-settings/font-weight-settings.js +14 -16
  101. package/dist/settings/widgets/group-by.js +160 -0
  102. package/{lib/components → dist}/settings/widgets/label-color.js +10 -10
  103. package/dist/settings/widgets/min-max-setting.js +52 -0
  104. package/dist/settings/widgets/mininum-slice-percent.js +63 -0
  105. package/dist/settings/widgets/numeric-summary-item.js +90 -0
  106. package/dist/settings/widgets/select-table/index.js +38 -0
  107. package/dist/settings/widgets/stack.js +50 -0
  108. package/dist/settings/widgets/summary-method-setting.js +66 -0
  109. package/dist/settings/widgets/summary-settings.js +411 -0
  110. package/dist/settings/widgets/switch/index.css +37 -0
  111. package/{lib/components → dist}/settings/widgets/switch/index.js +11 -8
  112. package/{lib/components → dist}/settings/widgets/text-horizontal-settings.js +12 -10
  113. package/dist/settings/widgets/time-picker.js +174 -0
  114. package/{lib/components → dist}/settings/widgets/title-settings/index.js +15 -13
  115. package/dist/settings/widgets/title-settings/title-text.js +25 -0
  116. package/dist/settings/widgets/x-axios.js +0 -0
  117. package/dist/settings/widgets/y-axis-group-settings.js +438 -0
  118. package/dist/utils/cell-format-utils.js +42 -0
  119. package/dist/utils/chart-data-sql.js +606 -0
  120. package/dist/utils/chart-utils.js +1803 -0
  121. package/dist/utils/chart.js +6 -0
  122. package/dist/utils/collaborator-manager.js +24 -0
  123. package/dist/utils/collaborator-utils.js +40 -0
  124. package/dist/utils/column-2-sql-column.js +551 -0
  125. package/dist/utils/column-utils.js +208 -0
  126. package/{lib → dist}/utils/custom-g2.js +11 -11
  127. package/{lib → dist}/utils/date-translate.js +11 -11
  128. package/dist/utils/index.js +48 -0
  129. package/dist/utils/key-generator.js +13 -0
  130. package/dist/utils/object-utils.js +45 -0
  131. package/{lib → dist}/utils/options-utils.js +17 -18
  132. package/dist/view/index.css +53 -0
  133. package/dist/view/index.js +169 -0
  134. package/{lib/layout → dist/view}/title/index.css +1 -1
  135. package/dist/view/title/index.js +46 -0
  136. package/dist/view/wrapper/area.js +150 -0
  137. package/dist/view/wrapper/bar-group.js +148 -0
  138. package/dist/view/wrapper/bar.js +138 -0
  139. package/dist/view/wrapper/basic-number-card.js +127 -0
  140. package/dist/view/wrapper/chart-component.js +261 -0
  141. package/dist/view/wrapper/combination.js +399 -0
  142. package/dist/view/wrapper/dashboard.js +164 -0
  143. package/dist/view/wrapper/horizontal-bar-group.js +149 -0
  144. package/dist/view/wrapper/horizontal-bar.js +140 -0
  145. package/dist/view/wrapper/horizontal-component.js +78 -0
  146. package/{lib/components/formatter → dist/view/wrapper}/index.js +90 -71
  147. package/dist/view/wrapper/line-group.js +145 -0
  148. package/dist/view/wrapper/line.js +157 -0
  149. package/dist/view/wrapper/pie.js +185 -0
  150. package/dist/view/wrapper/ring.js +264 -0
  151. package/{lib/components/formatter → dist/view/wrapper}/table/index.css +18 -18
  152. package/dist/view/wrapper/table/index.js +31 -0
  153. package/dist/view/wrapper/table/one-dimension-table-no-numeric-columns.js +144 -0
  154. package/dist/view/wrapper/table/one-dimension-table-with-numeric-columns.js +198 -0
  155. package/dist/view/wrapper/table/pivot-table-display-name.js +248 -0
  156. package/dist/view/wrapper/table/two-dimension-table.js +249 -0
  157. package/dist/view/wrapper/treemap.js +186 -0
  158. package/package.json +91 -100
  159. package/lib/components/formatter/area.js +0 -162
  160. package/lib/components/formatter/bar-group.js +0 -160
  161. package/lib/components/formatter/bar.js +0 -150
  162. package/lib/components/formatter/basic-number-card.js +0 -138
  163. package/lib/components/formatter/chart-component.js +0 -266
  164. package/lib/components/formatter/combination.js +0 -407
  165. package/lib/components/formatter/dashboard.js +0 -182
  166. package/lib/components/formatter/horizontal-bar-group.js +0 -161
  167. package/lib/components/formatter/horizontal-bar.js +0 -152
  168. package/lib/components/formatter/horizontal-component.js +0 -91
  169. package/lib/components/formatter/line-group.js +0 -157
  170. package/lib/components/formatter/line.js +0 -170
  171. package/lib/components/formatter/pie.js +0 -201
  172. package/lib/components/formatter/ring.js +0 -277
  173. package/lib/components/formatter/table/index.js +0 -42
  174. package/lib/components/formatter/table/one-dimension-table-no-numeric-columns.js +0 -145
  175. package/lib/components/formatter/table/one-dimension-table-with-numeric-columns.js +0 -193
  176. package/lib/components/formatter/table/pivot-table-display-name.js +0 -249
  177. package/lib/components/formatter/table/two-dimension-table.js +0 -241
  178. package/lib/components/formatter/treemap.js +0 -213
  179. package/lib/components/index.js +0 -5
  180. package/lib/components/number-input/index.js +0 -31
  181. package/lib/components/select-group/index.js +0 -63
  182. package/lib/components/settings/advance-bar-settings/style-settings.js +0 -149
  183. package/lib/components/settings/bar-settings/style-settings.js +0 -163
  184. package/lib/components/settings/basic-number-card/data-settings.js +0 -121
  185. package/lib/components/settings/basic-number-card/style-settings.js +0 -42
  186. package/lib/components/settings/combination-settings/data-settings.js +0 -256
  187. package/lib/components/settings/combination-settings/style-settings.js +0 -183
  188. package/lib/components/settings/dashboard-settings/data-settings.js +0 -167
  189. package/lib/components/settings/horizontal-bar-settings/data-settings.js +0 -45
  190. package/lib/components/settings/horizontal-bar-settings/style-settings.js +0 -38
  191. package/lib/components/settings/index.css +0 -73
  192. package/lib/components/settings/index.js +0 -74
  193. package/lib/components/settings/style-settings.js +0 -100
  194. package/lib/components/settings/time-comparison-settings/style-settings.js +0 -191
  195. package/lib/components/settings/widgets/basic-summary/index.css +0 -12
  196. package/lib/components/settings/widgets/basic-summary/index.js +0 -173
  197. package/lib/components/settings/widgets/data-filter/index.css +0 -17
  198. package/lib/components/settings/widgets/data-sort.js +0 -38
  199. package/lib/components/settings/widgets/date-summary-item.js +0 -126
  200. package/lib/components/settings/widgets/display-values-settings/index.css +0 -13
  201. package/lib/components/settings/widgets/divider/index.js +0 -10
  202. package/lib/components/settings/widgets/group-by.js +0 -168
  203. package/lib/components/settings/widgets/min-max-setting.js +0 -64
  204. package/lib/components/settings/widgets/mininum-slice-percent.js +0 -72
  205. package/lib/components/settings/widgets/numeric-summary-item.js +0 -109
  206. package/lib/components/settings/widgets/select-table/index.js +0 -49
  207. package/lib/components/settings/widgets/stack.js +0 -58
  208. package/lib/components/settings/widgets/statistic-type/index.js +0 -54
  209. package/lib/components/settings/widgets/summary-method-setting.js +0 -80
  210. package/lib/components/settings/widgets/summary-settings.js +0 -394
  211. package/lib/components/settings/widgets/switch/index.css +0 -37
  212. package/lib/components/settings/widgets/time-picker.js +0 -182
  213. package/lib/components/settings/widgets/title-settings/title-text.js +0 -31
  214. package/lib/components/settings/widgets/y-axis-group-settings.js +0 -399
  215. package/lib/components/types-dialog/index.css +0 -97
  216. package/lib/components/types-dialog/index.js +0 -127
  217. package/lib/constants/index.js +0 -164
  218. package/lib/constants/style.js +0 -13
  219. package/lib/constants/type-image.js +0 -32
  220. package/lib/constants/type.js +0 -97
  221. package/lib/context.js +0 -49
  222. package/lib/index.js +0 -6
  223. package/lib/intl.js +0 -37
  224. package/lib/layout/index.js +0 -4
  225. package/lib/layout/statistic/index.css +0 -53
  226. package/lib/layout/statistic/index.js +0 -190
  227. package/lib/layout/title/index.js +0 -41
  228. package/lib/locale/index.js +0 -11
  229. package/lib/model/area-group.js +0 -51
  230. package/lib/model/area.js +0 -42
  231. package/lib/model/bar-group.js +0 -54
  232. package/lib/model/bar-stack.js +0 -51
  233. package/lib/model/bar.js +0 -48
  234. package/lib/model/base-model.js +0 -11
  235. package/lib/model/basic-number-card.js +0 -32
  236. package/lib/model/combination.js +0 -48
  237. package/lib/model/compare-bar.js +0 -49
  238. package/lib/model/completeness-group.js +0 -34
  239. package/lib/model/completeness.js +0 -28
  240. package/lib/model/dashboard.js +0 -26
  241. package/lib/model/generic-model.js +0 -235
  242. package/lib/model/heat-map.js +0 -33
  243. package/lib/model/horizontal-bar.js +0 -48
  244. package/lib/model/horizontal-group-bar.js +0 -53
  245. package/lib/model/index.js +0 -36
  246. package/lib/model/line-group.js +0 -54
  247. package/lib/model/line.js +0 -48
  248. package/lib/model/map-bubble.js +0 -37
  249. package/lib/model/map.js +0 -37
  250. package/lib/model/mirror.js +0 -36
  251. package/lib/model/pie.js +0 -36
  252. package/lib/model/ring.js +0 -36
  253. package/lib/model/scatter.js +0 -29
  254. package/lib/model/stacked-horizontal-bar.js +0 -42
  255. package/lib/model/statistic.js +0 -22
  256. package/lib/model/table.js +0 -33
  257. package/lib/model/tree-map.js +0 -30
  258. package/lib/model/trend.js +0 -34
  259. package/lib/model/user.js +0 -22
  260. package/lib/model/world-map-bubble.js +0 -36
  261. package/lib/model/world-map.js +0 -36
  262. package/lib/utils/cell-format-utils.js +0 -41
  263. package/lib/utils/chart.js +0 -6
  264. package/lib/utils/collaborator-utils.js +0 -40
  265. package/lib/utils/column-utils.js +0 -247
  266. package/lib/utils/data-filter/filter-item-utils.js +0 -80
  267. package/lib/utils/data-filter/filters-utils.js +0 -406
  268. package/lib/utils/data-filter/index.js +0 -3
  269. package/lib/utils/index.js +0 -50
  270. package/lib/utils/key-generator.js +0 -13
  271. package/lib/utils/object-utils.js +0 -61
  272. package/lib/utils/statistic-column-2-sql-column-utils.js +0 -499
  273. package/lib/utils/statistic-utils.js +0 -1685
  274. /package/{lib → dist}/assets/icons/area-chart.svg +0 -0
  275. /package/{lib → dist}/assets/icons/bar-chart.svg +0 -0
  276. /package/{lib → dist}/assets/icons/card.svg +0 -0
  277. /package/{lib → dist}/assets/icons/combination-chart.svg +0 -0
  278. /package/{lib → dist}/assets/icons/dtable-logo.svg +0 -0
  279. /package/{lib → dist}/assets/icons/facet-chart.svg +0 -0
  280. /package/{lib → dist}/assets/icons/gauge.svg +0 -0
  281. /package/{lib → dist}/assets/icons/heat-map.svg +0 -0
  282. /package/{lib → dist}/assets/icons/histogram.svg +0 -0
  283. /package/{lib → dist}/assets/icons/line-chart.svg +0 -0
  284. /package/{lib → dist}/assets/icons/map.svg +0 -0
  285. /package/{lib → dist}/assets/icons/pie-chart.svg +0 -0
  286. /package/{lib → dist}/assets/icons/rectangular-tree-diagram.svg +0 -0
  287. /package/{lib → dist}/assets/icons/scatter-chart.svg +0 -0
  288. /package/{lib → dist}/assets/icons/type-change.svg +0 -0
  289. /package/{lib → dist}/assets/img/area-chart.png +0 -0
  290. /package/{lib → dist}/assets/img/area-group-chart.png +0 -0
  291. /package/{lib → dist}/assets/img/bar-group.png +0 -0
  292. /package/{lib → dist}/assets/img/bar-stack.png +0 -0
  293. /package/{lib → dist}/assets/img/bar.png +0 -0
  294. /package/{lib → dist}/assets/img/combination-chart.png +0 -0
  295. /package/{lib → dist}/assets/img/compared-chart.png +0 -0
  296. /package/{lib → dist}/assets/img/completeness-chart.png +0 -0
  297. /package/{lib → dist}/assets/img/custom-bar.png +0 -0
  298. /package/{lib → dist}/assets/img/dashboard-chart.png +0 -0
  299. /package/{lib → dist}/assets/img/group-completeness-chart.png +0 -0
  300. /package/{lib → dist}/assets/img/group_line.png +0 -0
  301. /package/{lib → dist}/assets/img/heat-map.png +0 -0
  302. /package/{lib → dist}/assets/img/horizontal-bar.png +0 -0
  303. /package/{lib → dist}/assets/img/horizontal-group-bar.png +0 -0
  304. /package/{lib → dist}/assets/img/line.png +0 -0
  305. /package/{lib → dist}/assets/img/map-bubble.png +0 -0
  306. /package/{lib → dist}/assets/img/map.png +0 -0
  307. /package/{lib → dist}/assets/img/mirror.png +0 -0
  308. /package/{lib → dist}/assets/img/number-card.png +0 -0
  309. /package/{lib → dist}/assets/img/pie.png +0 -0
  310. /package/{lib → dist}/assets/img/pivot-table.png +0 -0
  311. /package/{lib → dist}/assets/img/ring.png +0 -0
  312. /package/{lib → dist}/assets/img/scatter.png +0 -0
  313. /package/{lib → dist}/assets/img/stacked-horizontal-bar.png +0 -0
  314. /package/{lib → dist}/assets/img/treemap.png +0 -0
  315. /package/{lib → dist}/assets/img/trend-chart.png +0 -0
  316. /package/{lib → dist}/assets/img/world-map-bubble.png +0 -0
  317. /package/{lib → dist}/assets/img/world-map.png +0 -0
  318. /package/{lib → dist}/components/loading/index.css +0 -0
  319. /package/{lib/components/settings/widgets/select-table → dist/editor}/index.css +0 -0
  320. /package/{lib/components → dist}/settings/advance-bar-settings/index.js +0 -0
  321. /package/{lib/components → dist}/settings/bar-settings/index.js +0 -0
  322. /package/{lib/components → dist}/settings/basic-number-card/index.js +0 -0
  323. /package/{lib/components → dist}/settings/combination-settings/index.js +0 -0
  324. /package/{lib/components → dist}/settings/dashboard-settings/index.js +0 -0
  325. /package/{lib/components → dist}/settings/horizontal-bar-settings/index.js +0 -0
  326. /package/{lib/components → dist}/settings/pie-settings/index.js +0 -0
  327. /package/{lib/components → dist}/settings/table-settings/index.js +0 -0
  328. /package/{lib/components → dist}/settings/time-comparison-settings/index.js +0 -0
  329. /package/{lib/components → dist}/settings/widgets/font-settings/index.js +0 -0
  330. /package/{lib/components/settings/widgets/x-axios.js → dist/settings/widgets/select-table/index.css} +0 -0
@@ -0,0 +1,261 @@
1
+ import { Component } from 'react';
2
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
3
+ import { Chart } from '../../utils/custom-g2';
4
+ import { ChartUtils } from '../../utils';
5
+ import { CHART_SUMMARY_TYPE, LABEL_POSITION_TYPE, CHART_THEME_COLOR, EMPTY_NAME } from '../../constants';
6
+ import intl from '../../intl';
7
+ export default class ChartComponent extends Component {
8
+ constructor() {
9
+ var _this;
10
+ super(...arguments);
11
+ _this = this;
12
+ this.initChart = (container, _ref) => {
13
+ let {
14
+ appendPadding
15
+ } = _ref;
16
+ let config = {
17
+ container: container,
18
+ autoFit: true,
19
+ width: '100%',
20
+ height: '100%'
21
+ };
22
+ if (appendPadding) {
23
+ config.appendPadding = appendPadding;
24
+ }
25
+ this.chart = new Chart(config);
26
+ };
27
+ this.loadData = data => {
28
+ this.chart.data(data, {
29
+ 'name': {
30
+ type: 'cat',
31
+ nice: false
32
+ }
33
+ });
34
+ };
35
+ this.getChartDisplayLabels = (containerWidth, minItemWidth, charts) => {
36
+ let labels = [];
37
+ let labelCount = Math.floor(containerWidth / minItemWidth);
38
+ labelCount = labelCount % 2 ? labelCount + 1 : labelCount;
39
+ let avg = Math.round(charts.length / labelCount);
40
+ avg = avg > 2 ? avg : 2;
41
+ Array.isArray(charts) && charts.forEach((v, i) => {
42
+ if (i % avg === 0) {
43
+ labels.push(v.name);
44
+ }
45
+ });
46
+ return labels;
47
+ };
48
+ this.getChartGroupData = data => {
49
+ let chartGroupData = [];
50
+ Array.isArray(data) && data.forEach(item => {
51
+ if (!chartGroupData.find(g => g.name === item.name)) {
52
+ chartGroupData.push(item);
53
+ }
54
+ });
55
+ return chartGroupData;
56
+ };
57
+ this.drawLabels = function () {
58
+ let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
59
+ if (!_this.chart) return;
60
+ const {
61
+ width
62
+ } = _this.chart.coordinateBBox;
63
+ _this.labelCount = data.length;
64
+ if (Math.floor(width / _this.labelCount) <= 20) {
65
+ let displayLabels = _this.getChartDisplayLabels(width, 20, data);
66
+ _this.labelCount = displayLabels.length;
67
+ _this.chart.scale('name', {
68
+ type: 'cat',
69
+ ticks: displayLabels
70
+ });
71
+ }
72
+ };
73
+ this.renderAxisLabel = (chart, tables) => {
74
+ if (!this.chart || !chart) return;
75
+ const {
76
+ table_id,
77
+ x_axis_column_key,
78
+ y_axis_summary_column_key,
79
+ y_axis_show_label,
80
+ x_axis_show_label,
81
+ y_axis_label_position,
82
+ x_axis_label_position,
83
+ y_axis_summary_type
84
+ } = chart.config;
85
+ const table = getTableById(tables, table_id);
86
+ const autoPadding = this.chart.autoPadding;
87
+ const textColor = '#999';
88
+ const xAxisID = "chart-x-axis-label_".concat(chart.id);
89
+ const chartContainer = this.chart.getCanvas().get('container');
90
+ const xLabel = chartContainer.querySelector("#".concat(xAxisID));
91
+ if (!xLabel && x_axis_show_label) {
92
+ const div = document.createElement('div');
93
+ div.id = xAxisID;
94
+ div.className = 'chart-axis-label';
95
+ const column = getTableColumnByKey(table, x_axis_column_key);
96
+ div.innerHTML = "".concat(column ? column.name : '');
97
+ div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
98
+ chartContainer.appendChild(div);
99
+ }
100
+ if (xLabel && x_axis_show_label) {
101
+ xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
102
+ }
103
+ if (xLabel && !x_axis_show_label) {
104
+ xLabel.parentNode.removeChild(xLabel);
105
+ }
106
+ const yAxisID = "chart-y-axis-label_".concat(chart.id);
107
+ const yLabel = chartContainer.querySelector("#".concat(yAxisID));
108
+ if (!yLabel && y_axis_show_label) {
109
+ const div = document.createElement('div');
110
+ div.id = yAxisID;
111
+ div.className = 'chart-axis-label';
112
+ if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
113
+ div.innerHTML = intl.get('Amount');
114
+ } else {
115
+ const column = getTableColumnByKey(table, y_axis_summary_column_key) || {};
116
+ div.innerHTML = column.name || '';
117
+ }
118
+ const containerHeight = chartContainer.offsetHeight;
119
+ let textAlign = 'center';
120
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
121
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
122
+ div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
123
+ chartContainer.appendChild(div);
124
+ }
125
+ if (yLabel && y_axis_show_label) {
126
+ const containerHeight = chartContainer.offsetHeight;
127
+ let textAlign = 'center';
128
+ if (y_axis_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
129
+ if (y_axis_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
130
+ yLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
131
+ }
132
+ if (yLabel && !y_axis_show_label) {
133
+ yLabel.parentNode.removeChild(yLabel);
134
+ }
135
+ };
136
+ // Automatic adjustment of maximum and minimum values
137
+ this.autoAdjustDataOptions = function (chart) {
138
+ let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
139
+ let summaryColumn = arguments.length > 2 ? arguments[2] : undefined;
140
+ if (!_this.chart || !chart) return;
141
+ let valueScaleOptions = {};
142
+ const {
143
+ config
144
+ } = chart;
145
+ const {
146
+ y_axis_auto_range,
147
+ y_axis_min,
148
+ y_axis_max,
149
+ y_axis_summary_method
150
+ } = config;
151
+ if (summaryColumn) {
152
+ valueScaleOptions['formatter'] = value => {
153
+ return ChartUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method);
154
+ };
155
+ }
156
+ if (y_axis_auto_range === undefined || y_axis_auto_range) {
157
+ valueScaleOptions['nice'] = true;
158
+ } else {
159
+ valueScaleOptions['min'] = y_axis_min;
160
+ valueScaleOptions['max'] = y_axis_max;
161
+ // set the filter rule
162
+ _this.chart.filter('value', value => {
163
+ return value >= y_axis_min;
164
+ });
165
+ // filter the data
166
+ _this.chart.filterData(data);
167
+ }
168
+ _this.chart.scale({
169
+ name: {
170
+ type: 'cat'
171
+ },
172
+ value: valueScaleOptions
173
+ });
174
+ };
175
+ // set axis label and tooltip
176
+ this.setNameLabelAndTooltip = function () {
177
+ let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CHART_THEME_COLOR['light'];
178
+ let labelCount = arguments.length > 1 ? arguments[1] : undefined;
179
+ if (!_this.chart) return;
180
+ _this.chart.axis('name', {
181
+ line: {
182
+ style: theme.gridColor
183
+ },
184
+ label: {
185
+ style: {
186
+ fill: theme.textColor
187
+ },
188
+ offset: 20,
189
+ autoRotate: true,
190
+ rotate: labelCount > 11 ? 0.3 : 0,
191
+ formatter: name => {
192
+ const isString = typeof name === 'string';
193
+ if (!isString) name = String(name);
194
+ if (name === 'undefined') {
195
+ return intl.get(EMPTY_NAME);
196
+ }
197
+ if (name.length > 10) {
198
+ return "".concat(name.slice(0, 10), "...");
199
+ }
200
+ return name;
201
+ }
202
+ }
203
+ });
204
+ };
205
+ // set value label
206
+ this.setValueLabel = function () {
207
+ let theme = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : CHART_THEME_COLOR['light'];
208
+ if (!_this.chart) return;
209
+ _this.chart.axis('value', {
210
+ label: {
211
+ style: {
212
+ fill: theme.textColor
213
+ }
214
+ },
215
+ grid: {
216
+ line: {
217
+ style: {
218
+ stroke: theme.gridColor
219
+ }
220
+ }
221
+ }
222
+ });
223
+ };
224
+ // set legend
225
+ this.setLegend = function (legendName, theme) {
226
+ let legendPosition = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'bottom';
227
+ if (!_this.chart) return;
228
+ _this.chart.legend(legendName, {
229
+ position: legendPosition,
230
+ itemName: {
231
+ style: {
232
+ fill: theme.textColor
233
+ },
234
+ formatter: name => {
235
+ return !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name;
236
+ }
237
+ },
238
+ pageNavigator: {
239
+ text: {
240
+ style: {
241
+ fill: theme.textColor
242
+ }
243
+ },
244
+ marker: {
245
+ style: {
246
+ fill: theme.legendPageNavigatorMarkerColor,
247
+ inactiveFill: theme.legendPageNavigatorMarkerColor,
248
+ inactiveOpacity: 0.45
249
+ }
250
+ }
251
+ }
252
+ });
253
+ };
254
+ this.isShowXAxisLabel = chart => {
255
+ return !!(chart && chart.config && chart.config.x_axis_show_label);
256
+ };
257
+ this.isShowYAxisLabel = chart => {
258
+ return !!(chart && chart.config && chart.config.y_axis_show_label);
259
+ };
260
+ }
261
+ }
@@ -0,0 +1,399 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
4
+ import { Chart } from '../../utils/custom-g2';
5
+ import { ChartUtils } from '../../utils';
6
+ import { CHART_SUMMARY_TYPE, LABEL_COLORS, CHART_SUMMARY_SHOW, LABEL_POSITION_TYPE, EMPTY_NAME } from '../../constants';
7
+ import intl from '../../intl';
8
+ class Combination extends React.Component {
9
+ constructor(props) {
10
+ super(props);
11
+ this.clearChart = () => {
12
+ this.chart.annotation().clear(true);
13
+ this.chart.clear(true);
14
+ };
15
+ this.drawChart = () => {
16
+ let {
17
+ result: data
18
+ } = this.props;
19
+ this.draw(data);
20
+ };
21
+ this.draw = data => {
22
+ if (!Array.isArray(data)) return;
23
+ const {
24
+ chart,
25
+ theme,
26
+ tables,
27
+ themeName
28
+ } = this.props;
29
+ const {
30
+ table_id,
31
+ y_axis_left_summary_column,
32
+ y_axis_right_summary_column,
33
+ y_axis_left_summary_method,
34
+ y_axis_right_summary_method,
35
+ y_axis_left_summary_type,
36
+ y_axis_right_summary_type,
37
+ y_axis_left_group_by_multiple_numeric_column,
38
+ y_axis_auto_range_left,
39
+ y_axis_min_left,
40
+ y_axis_max_left,
41
+ y_axis_auto_range_right,
42
+ y_axis_min_right,
43
+ y_axis_max_right,
44
+ display_data,
45
+ label_font_size
46
+ } = chart.config;
47
+ this.chart = new Chart({
48
+ container: this.container,
49
+ autoFit: true,
50
+ width: '100%',
51
+ height: '100%',
52
+ appendPadding: [display_data ? 17 : 0, 0, 0, 0]
53
+ });
54
+ const currentTheme = ChartUtils.getCurrentTheme(themeName);
55
+ this.chart.data(data);
56
+ this.chart.coordinate('rect');
57
+ const table = getTableById(tables, table_id);
58
+ const leftSummaryColumn = getTableColumnByKey(table, y_axis_left_summary_column) || {};
59
+ const rightSummaryColumn = getTableColumnByKey(table, y_axis_right_summary_column) || {};
60
+ let leftValueScaleOptions = {
61
+ formatter: value => {
62
+ return ChartUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method);
63
+ }
64
+ };
65
+ let rightValueScaleOptions = {
66
+ formatter: value => {
67
+ return ChartUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method);
68
+ }
69
+ };
70
+ if (!y_axis_auto_range_left) {
71
+ leftValueScaleOptions = Object.assign(leftValueScaleOptions, {
72
+ min: y_axis_min_left,
73
+ max: y_axis_max_left
74
+ });
75
+ }
76
+ if (!y_axis_auto_range_right) {
77
+ rightValueScaleOptions = Object.assign(rightValueScaleOptions, {
78
+ min: y_axis_min_right,
79
+ max: y_axis_max_right
80
+ });
81
+ }
82
+ this.chart.scale({
83
+ name: {
84
+ type: 'cat'
85
+ },
86
+ // Automatic adjustment of maximum and minimum values
87
+ value_left: leftValueScaleOptions,
88
+ value_right: rightValueScaleOptions
89
+ });
90
+ this.chart.axis('name', {
91
+ label: {
92
+ style: {
93
+ fill: theme.textColor
94
+ },
95
+ formatter: name => {
96
+ const isString = typeof name === 'string';
97
+ if (!isString) name = String(name);
98
+ if (name === 'undefined') {
99
+ return intl.get(EMPTY_NAME);
100
+ }
101
+ if (name.length > 10) {
102
+ return "".concat(name.slice(0, 10), "...");
103
+ }
104
+ return name;
105
+ }
106
+ },
107
+ line: {
108
+ style: theme.gridColor
109
+ }
110
+ });
111
+ this.chart.axis('value_left', {
112
+ grid: {
113
+ line: {
114
+ style: {
115
+ stroke: theme.gridColor
116
+ }
117
+ }
118
+ },
119
+ label: {
120
+ style: {
121
+ fill: theme.textColor
122
+ }
123
+ }
124
+ });
125
+ this.chart.axis('value_right', {
126
+ grid: null,
127
+ label: {
128
+ style: {
129
+ fill: theme.textColor
130
+ }
131
+ }
132
+ });
133
+ let legendPosition = 'bottom';
134
+ this.chart.legend({
135
+ custom: true,
136
+ position: legendPosition,
137
+ itemName: {
138
+ style: {
139
+ fill: theme.textColor
140
+ }
141
+ },
142
+ items: this.getLegend(leftSummaryColumn, rightSummaryColumn, table, currentTheme)
143
+ });
144
+ this.chart.interval().position('name*value_left').color('color', color => {
145
+ if (!y_axis_left_group_by_multiple_numeric_column) {
146
+ return currentTheme.colors[0];
147
+ }
148
+ return color;
149
+ }).adjust('dodge').tooltip('name*value_left', (name, value) => {
150
+ return {
151
+ title: y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_left_summary_method]),
152
+ value: ChartUtils.getSummaryValueDisplayString(leftSummaryColumn, value, y_axis_left_summary_method),
153
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
154
+ };
155
+ });
156
+ this.chart.tooltip({
157
+ showMarkers: false
158
+ });
159
+ this.chart.line().position('name*value_right').color(currentTheme.colors[1]).size(3).tooltip('name*value_right', (name, value) => {
160
+ return {
161
+ title: y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_right_summary_method]),
162
+ value: ChartUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
163
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
164
+ };
165
+ });
166
+ this.chart.point().position('name*value_right').color(currentTheme.colors[1]).size(3).shape('circle').label(display_data ? 'value_right' : false, {
167
+ style: {
168
+ fontSize: ChartUtils.getLabelFontSize(label_font_size),
169
+ fill: theme.textColor
170
+ }
171
+ }).tooltip('name*value_right', (name, value) => {
172
+ return {
173
+ title: y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_right_summary_method]),
174
+ value: ChartUtils.getSummaryValueDisplayString(rightSummaryColumn, value, y_axis_right_summary_method),
175
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
176
+ };
177
+ });
178
+ this.chart.removeInteraction('legend-filter');
179
+ this.chart.render();
180
+ this.renderAxisLabel();
181
+ };
182
+ this.renderAxisLabel = () => {
183
+ if (!this.chart) return;
184
+ let {
185
+ chart,
186
+ tables
187
+ } = this.props;
188
+ const {
189
+ config
190
+ } = chart;
191
+ const {
192
+ table_id,
193
+ x_axis_column_key,
194
+ show_y_axis_left_label,
195
+ show_y_axis_right_label,
196
+ x_axis_show_label,
197
+ y_axis_left_label_position,
198
+ y_axis_right_label_position,
199
+ y_axis_left_summary_column,
200
+ y_axis_right_summary_column,
201
+ x_axis_label_position,
202
+ y_axis_left_summary_type,
203
+ y_axis_right_summary_type
204
+ } = config;
205
+ const table = getTableById(tables, table_id);
206
+ const autoPadding = this.chart.autoPadding;
207
+ const textColor = '#999';
208
+ const xAxisID = "chart-x-axis-label_".concat(chart.id);
209
+ const chartContainer = this.chart.getCanvas().get('container');
210
+ const xLabel = chartContainer.querySelector("#".concat(xAxisID));
211
+ if (!xLabel && x_axis_show_label) {
212
+ const div = document.createElement('div');
213
+ div.id = xAxisID;
214
+ div.className = 'chart-axis-label text-truncate';
215
+ const column = getTableColumnByKey(table, x_axis_column_key);
216
+ div.innerHTML = "".concat(column ? column.name : '');
217
+ div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
218
+ chartContainer.appendChild(div);
219
+ }
220
+ if (xLabel && x_axis_show_label) {
221
+ xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
222
+ }
223
+ if (xLabel && !x_axis_show_label) {
224
+ xLabel.parentNode.removeChild(xLabel);
225
+ }
226
+ const yAxisLeftID = "chart-y-axis-left-label_".concat(chart.id);
227
+ const yAxisLeftLabel = chartContainer.querySelector("#".concat(yAxisLeftID));
228
+ if (!yAxisLeftLabel && show_y_axis_left_label) {
229
+ const div = document.createElement('div');
230
+ div.id = yAxisLeftID;
231
+ div.className = 'chart-axis-label text-truncate';
232
+ if (y_axis_left_summary_type === CHART_SUMMARY_TYPE.COUNT) {
233
+ div.innerHTML = intl.get('Amount');
234
+ } else {
235
+ const column = getTableColumnByKey(table, y_axis_left_summary_column) || {};
236
+ div.innerHTML = column.name || '';
237
+ }
238
+ const containerHeight = chartContainer.offsetHeight;
239
+ let textAlign = 'center';
240
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
241
+ if (y_axis_left_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
242
+ div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
243
+ chartContainer.appendChild(div);
244
+ }
245
+ if (yAxisLeftLabel && show_y_axis_left_label) {
246
+ const containerHeight = chartContainer.offsetHeight;
247
+ let textAlign = 'center';
248
+ if (y_axis_left_label_position === 'bottom') textAlign = 'left';
249
+ if (y_axis_left_label_position === 'top') textAlign = 'right';
250
+ yAxisLeftLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; left: 0; transform: translate(-").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
251
+ }
252
+ if (yAxisLeftLabel && !show_y_axis_left_label) {
253
+ yAxisLeftLabel.parentNode.removeChild(yAxisLeftLabel);
254
+ }
255
+ const yAxisRightID = "chart-y-axis-right-label_".concat(chart.id);
256
+ const yAxisRightLabel = chartContainer.querySelector("#".concat(yAxisRightID));
257
+ if (!yAxisRightLabel && show_y_axis_right_label) {
258
+ const div = document.createElement('div');
259
+ div.id = yAxisRightID;
260
+ div.className = 'chart-axis-label text-truncate';
261
+ if (y_axis_right_summary_type === CHART_SUMMARY_TYPE.COUNT) {
262
+ div.innerHTML = intl.get('Amount');
263
+ } else {
264
+ const column = getTableColumnByKey(table, y_axis_right_summary_column) || {};
265
+ div.innerHTML = column.name || '';
266
+ }
267
+ const containerHeight = chartContainer.offsetHeight;
268
+ let textAlign = 'center';
269
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.BOTTOM) textAlign = 'left';
270
+ if (y_axis_right_label_position === LABEL_POSITION_TYPE.TOP) textAlign = 'right';
271
+ div.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
272
+ chartContainer.appendChild(div);
273
+ }
274
+ if (yAxisRightLabel && show_y_axis_right_label) {
275
+ const containerHeight = chartContainer.offsetHeight;
276
+ let textAlign = 'center';
277
+ if (y_axis_right_label_position === 'bottom') textAlign = 'left';
278
+ if (y_axis_right_label_position === 'top') textAlign = 'right';
279
+ yAxisRightLabel.setAttribute('style', "color:".concat(textColor, "; position: absolute; width: ").concat(containerHeight, "px; text-align: ").concat(textAlign, "; top: 0; right: 0; transform: translate(").concat(containerHeight / 2 + 12, "px, ").concat((containerHeight - autoPadding.bottom) / 2 + autoPadding.bottom / 4, "px) rotate(-90deg)"));
280
+ }
281
+ if (yAxisRightLabel && !show_y_axis_right_label) {
282
+ yAxisRightLabel.parentNode.removeChild(yAxisRightLabel);
283
+ }
284
+ };
285
+ this.getLegend = (leftSummaryColumn, rightSummaryColumn, table, currentTheme) => {
286
+ const {
287
+ chart
288
+ } = this.props;
289
+ const {
290
+ y_axis_left_group_by_multiple_numeric_column,
291
+ y_axis_left_group_by_numeric_columns
292
+ } = chart.config;
293
+ const legendItems = [];
294
+ if (!y_axis_left_group_by_multiple_numeric_column) {
295
+ legendItems.push({
296
+ value: 'value_left',
297
+ name: leftSummaryColumn.name || intl.get('Left'),
298
+ marker: {
299
+ symbol: 'square',
300
+ style: {
301
+ fill: currentTheme.colors[0],
302
+ r: 5
303
+ }
304
+ }
305
+ }, {
306
+ value: 'value_right',
307
+ name: rightSummaryColumn.name || intl.get('Right'),
308
+ marker: {
309
+ symbol: 'hyphen',
310
+ style: {
311
+ stroke: currentTheme.colors[1],
312
+ r: 5,
313
+ lineWidth: 3
314
+ }
315
+ }
316
+ });
317
+ } else {
318
+ legendItems.push({
319
+ value: 'value_left',
320
+ name: leftSummaryColumn.name || intl.get('Left'),
321
+ marker: {
322
+ fill: LABEL_COLORS[0],
323
+ symbol: 'square',
324
+ style: {
325
+ r: 5
326
+ }
327
+ }
328
+ });
329
+ y_axis_left_group_by_numeric_columns.forEach((item, index) => {
330
+ const column = getTableColumnByKey(table, item.column_key);
331
+ if (column) {
332
+ legendItems.push({
333
+ value: 'group_name',
334
+ name: column.name || intl.get('Left'),
335
+ marker: {
336
+ symbol: 'square',
337
+ style: {
338
+ fill: LABEL_COLORS[(index + 1) % 12],
339
+ r: 5
340
+ }
341
+ }
342
+ });
343
+ }
344
+ });
345
+ legendItems.push({
346
+ value: 'value_right',
347
+ name: rightSummaryColumn.name || intl.get('Right'),
348
+ marker: {
349
+ symbol: 'hyphen',
350
+ style: {
351
+ stroke: currentTheme.colors[1],
352
+ r: 5,
353
+ lineWidth: 3
354
+ }
355
+ }
356
+ });
357
+ }
358
+ return legendItems;
359
+ };
360
+ this.isShowXAxisLabel = chart => {
361
+ return !!(chart && chart.config && chart.config.x_axis_show_label);
362
+ };
363
+ this.isShowYAxisLeftLabel = chart => {
364
+ return !!(chart && chart.config && chart.config.show_y_axis_left_label);
365
+ };
366
+ this.isShowYAxisRightLabel = chart => {
367
+ return !!(chart && chart.config && chart.config.show_y_axis_right_label);
368
+ };
369
+ this.chart = null;
370
+ }
371
+ componentDidMount() {
372
+ this.drawChart();
373
+ this.renderAxisLabel(this.props.chart, this.props.tables);
374
+ }
375
+ componentDidUpdate(prevProps) {
376
+ if (ChartUtils.shouldChartComponentUpdate(prevProps, this.props)) {
377
+ this.chart && this.chart.destroy();
378
+ this.drawChart();
379
+ this.renderAxisLabel(prevProps.chart, prevProps.tables);
380
+ }
381
+ }
382
+ componentWillUnmount() {
383
+ this.chart && this.chart.destroy();
384
+ }
385
+ render() {
386
+ const {
387
+ chart
388
+ } = this.props;
389
+ return /*#__PURE__*/React.createElement("div", {
390
+ className: classnames('sea-chart-container w-100', {
391
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
392
+ 'show-y-axis-left-label': this.isShowYAxisLeftLabel(chart),
393
+ 'show-y-axis-right-label': this.isShowYAxisRightLabel(chart)
394
+ }),
395
+ ref: ref => this.container = ref
396
+ });
397
+ }
398
+ }
399
+ export default Combination;