@semcore/d3-chart 1.8.0 → 2.0.1

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 (179) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/cjs/Area.js +9 -9
  3. package/lib/cjs/Axis.js +17 -19
  4. package/lib/cjs/Axis.js.map +1 -1
  5. package/lib/cjs/Bar.js +11 -11
  6. package/lib/cjs/Bar.js.map +1 -1
  7. package/lib/cjs/Bubble.js +13 -34
  8. package/lib/cjs/Bubble.js.map +1 -1
  9. package/lib/cjs/ClipPath.js +2 -1
  10. package/lib/cjs/ClipPath.js.map +1 -1
  11. package/lib/cjs/Donut.js +8 -8
  12. package/lib/cjs/Donut.js.map +1 -1
  13. package/lib/cjs/Dots.js +9 -9
  14. package/lib/cjs/Dots.js.map +1 -1
  15. package/lib/cjs/GroupBar.js +8 -8
  16. package/lib/cjs/GroupBar.js.map +1 -1
  17. package/lib/cjs/HorizontalBar.js +11 -11
  18. package/lib/cjs/HorizontalBar.js.map +1 -1
  19. package/lib/cjs/Hover.js +4 -4
  20. package/lib/cjs/Line.js +8 -8
  21. package/lib/cjs/Plot.js +15 -1
  22. package/lib/cjs/Plot.js.map +1 -1
  23. package/lib/cjs/RadialTree.js +694 -0
  24. package/lib/cjs/RadialTree.js.map +1 -0
  25. package/lib/cjs/ResponsiveContainer.js +1 -1
  26. package/lib/cjs/ResponsiveContainer.js.map +1 -1
  27. package/lib/cjs/ScatterPlot.js +7 -7
  28. package/lib/cjs/StackBar.js +8 -8
  29. package/lib/cjs/StackBar.js.map +1 -1
  30. package/lib/cjs/StackedArea.js +8 -8
  31. package/lib/cjs/StackedArea.js.map +1 -1
  32. package/lib/cjs/Tooltip.js +11 -15
  33. package/lib/cjs/Tooltip.js.map +1 -1
  34. package/lib/cjs/Venn.js +9 -9
  35. package/lib/cjs/Venn.js.map +1 -1
  36. package/lib/cjs/color.js +122 -30
  37. package/lib/cjs/color.js.map +1 -1
  38. package/lib/cjs/createElement.js +3 -2
  39. package/lib/cjs/createElement.js.map +1 -1
  40. package/lib/cjs/index.js +8 -0
  41. package/lib/cjs/index.js.map +1 -1
  42. package/lib/cjs/style/area.shadow.css +4 -4
  43. package/lib/cjs/style/axis.shadow.css +4 -4
  44. package/lib/cjs/style/bar.shadow.css +2 -2
  45. package/lib/cjs/style/bubble.shadow.css +3 -3
  46. package/lib/cjs/style/donut.shadow.css +2 -2
  47. package/lib/cjs/style/dot.shadow.css +1 -1
  48. package/lib/cjs/style/hover.shadow.css +2 -2
  49. package/lib/cjs/style/line.shadow.css +2 -2
  50. package/lib/cjs/style/plot.shadow.css +6 -0
  51. package/lib/cjs/style/radial-tree.shadow.css +34 -0
  52. package/lib/cjs/style/scatterplot.shadow.css +2 -2
  53. package/lib/cjs/style/tooltip.shadow.css +5 -5
  54. package/lib/cjs/style/var.css +123 -30
  55. package/lib/cjs/style/venn.shadow.css +1 -1
  56. package/lib/cjs/types/Area.d.ts +47 -0
  57. package/lib/cjs/types/Axis.d.ts +64 -0
  58. package/lib/cjs/types/Bar.d.ts +48 -0
  59. package/lib/cjs/types/Bubble.d.ts +27 -0
  60. package/lib/cjs/types/ClipPath.d.ts +26 -0
  61. package/lib/cjs/types/Donut.d.ts +42 -0
  62. package/lib/cjs/types/GroupBar.d.ts +20 -0
  63. package/lib/cjs/types/HorizontalBar.d.ts +29 -0
  64. package/lib/cjs/types/Hover.d.ts +15 -0
  65. package/lib/cjs/types/Line.d.ts +50 -0
  66. package/lib/cjs/types/Plot.d.ts +16 -0
  67. package/lib/cjs/types/ResponsiveContainer.d.ts +20 -0
  68. package/lib/cjs/types/ScatterPlot.d.ts +27 -0
  69. package/lib/cjs/types/StackBar.d.ts +26 -0
  70. package/lib/cjs/types/StackedArea.d.ts +26 -0
  71. package/lib/cjs/types/Tooltip.d.ts +31 -0
  72. package/lib/cjs/types/Venn.d.ts +45 -0
  73. package/lib/cjs/types/context.d.ts +6 -0
  74. package/lib/cjs/types/index.d.ts +53 -0
  75. package/lib/cjs/utils.js +120 -55
  76. package/lib/cjs/utils.js.map +1 -1
  77. package/lib/es6/Area.js +9 -9
  78. package/lib/es6/Axis.js +17 -19
  79. package/lib/es6/Axis.js.map +1 -1
  80. package/lib/es6/Bar.js +11 -11
  81. package/lib/es6/Bar.js.map +1 -1
  82. package/lib/es6/Bubble.js +13 -34
  83. package/lib/es6/Bubble.js.map +1 -1
  84. package/lib/es6/ClipPath.js +2 -1
  85. package/lib/es6/ClipPath.js.map +1 -1
  86. package/lib/es6/Donut.js +8 -8
  87. package/lib/es6/Donut.js.map +1 -1
  88. package/lib/es6/Dots.js +9 -9
  89. package/lib/es6/Dots.js.map +1 -1
  90. package/lib/es6/GroupBar.js +8 -8
  91. package/lib/es6/GroupBar.js.map +1 -1
  92. package/lib/es6/HorizontalBar.js +11 -11
  93. package/lib/es6/HorizontalBar.js.map +1 -1
  94. package/lib/es6/Hover.js +4 -4
  95. package/lib/es6/Line.js +8 -8
  96. package/lib/es6/Plot.js +17 -1
  97. package/lib/es6/Plot.js.map +1 -1
  98. package/lib/es6/RadialTree.js +682 -0
  99. package/lib/es6/RadialTree.js.map +1 -0
  100. package/lib/es6/ResponsiveContainer.js +1 -1
  101. package/lib/es6/ResponsiveContainer.js.map +1 -1
  102. package/lib/es6/ScatterPlot.js +7 -7
  103. package/lib/es6/StackBar.js +8 -8
  104. package/lib/es6/StackBar.js.map +1 -1
  105. package/lib/es6/StackedArea.js +8 -8
  106. package/lib/es6/StackedArea.js.map +1 -1
  107. package/lib/es6/Tooltip.js +11 -15
  108. package/lib/es6/Tooltip.js.map +1 -1
  109. package/lib/es6/Venn.js +9 -9
  110. package/lib/es6/Venn.js.map +1 -1
  111. package/lib/es6/color.js +122 -30
  112. package/lib/es6/color.js.map +1 -1
  113. package/lib/es6/createElement.js +3 -2
  114. package/lib/es6/createElement.js.map +1 -1
  115. package/lib/es6/index.js +1 -0
  116. package/lib/es6/index.js.map +1 -1
  117. package/lib/es6/style/area.shadow.css +4 -4
  118. package/lib/es6/style/axis.shadow.css +4 -4
  119. package/lib/es6/style/bar.shadow.css +2 -2
  120. package/lib/es6/style/bubble.shadow.css +3 -3
  121. package/lib/es6/style/donut.shadow.css +2 -2
  122. package/lib/es6/style/dot.shadow.css +1 -1
  123. package/lib/es6/style/hover.shadow.css +2 -2
  124. package/lib/es6/style/line.shadow.css +2 -2
  125. package/lib/es6/style/plot.shadow.css +6 -0
  126. package/lib/es6/style/radial-tree.shadow.css +34 -0
  127. package/lib/es6/style/scatterplot.shadow.css +2 -2
  128. package/lib/es6/style/tooltip.shadow.css +5 -5
  129. package/lib/es6/style/var.css +123 -30
  130. package/lib/es6/style/venn.shadow.css +1 -1
  131. package/lib/es6/types/Area.d.ts +47 -0
  132. package/lib/es6/types/Axis.d.ts +64 -0
  133. package/lib/es6/types/Bar.d.ts +48 -0
  134. package/lib/es6/types/Bubble.d.ts +27 -0
  135. package/lib/es6/types/ClipPath.d.ts +26 -0
  136. package/lib/es6/types/Donut.d.ts +42 -0
  137. package/lib/es6/types/GroupBar.d.ts +20 -0
  138. package/lib/es6/types/HorizontalBar.d.ts +29 -0
  139. package/lib/es6/types/Hover.d.ts +15 -0
  140. package/lib/es6/types/Line.d.ts +50 -0
  141. package/lib/es6/types/Plot.d.ts +16 -0
  142. package/lib/es6/types/ResponsiveContainer.d.ts +20 -0
  143. package/lib/es6/types/ScatterPlot.d.ts +27 -0
  144. package/lib/es6/types/StackBar.d.ts +26 -0
  145. package/lib/es6/types/StackedArea.d.ts +26 -0
  146. package/lib/es6/types/Tooltip.d.ts +31 -0
  147. package/lib/es6/types/Venn.d.ts +45 -0
  148. package/lib/es6/types/context.d.ts +6 -0
  149. package/lib/es6/types/index.d.ts +53 -0
  150. package/lib/es6/utils.js +95 -44
  151. package/lib/es6/utils.js.map +1 -1
  152. package/lib/types/RadialTree.d.ts +202 -0
  153. package/lib/types/index.d.ts +6 -0
  154. package/lib/types/utils.d.ts +27 -0
  155. package/package.json +22 -10
  156. package/src/Bubble.jsx +1 -21
  157. package/src/ClipPath.jsx +1 -0
  158. package/src/Donut.jsx +7 -9
  159. package/src/Plot.jsx +2 -0
  160. package/src/RadialTree.tsx +767 -0
  161. package/src/createElement.jsx +3 -1
  162. package/src/index.js +1 -0
  163. package/src/style/area.shadow.css +4 -4
  164. package/src/style/axis.shadow.css +4 -4
  165. package/src/style/bar.shadow.css +2 -2
  166. package/src/style/bubble.shadow.css +3 -3
  167. package/src/style/donut.shadow.css +2 -2
  168. package/src/style/dot.shadow.css +1 -1
  169. package/src/style/hover.shadow.css +2 -2
  170. package/src/style/line.shadow.css +2 -2
  171. package/src/style/plot.shadow.css +6 -0
  172. package/src/style/radial-tree.shadow.css +34 -0
  173. package/src/style/scatterplot.shadow.css +2 -2
  174. package/src/style/tooltip.shadow.css +5 -5
  175. package/src/style/var.css +123 -30
  176. package/src/style/venn.shadow.css +1 -1
  177. package/src/types/index.d.ts +6 -0
  178. package/src/utils.ts +227 -0
  179. package/src/utils.js +0 -147
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/d3-chart",
3
3
  "description": "SEMRush D3 Chart Component",
4
- "version": "1.8.0",
4
+ "version": "2.0.1",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -9,21 +9,22 @@
9
9
  "author": "Roman Lysov <r.lysov@semrush.com>",
10
10
  "license": "MIT",
11
11
  "scripts": {
12
- "build": "build --source=js",
12
+ "build": "build --source=js,ts",
13
13
  "test": "jest"
14
14
  },
15
15
  "dependencies": {
16
+ "@semcore/animation": "^1",
16
17
  "@semcore/flex-box": "^4",
17
18
  "@semcore/popper": "^4.9",
18
19
  "@semcore/utils": "^3.15",
19
- "@semcore/animation": "^1",
20
- "@upsetjs/venn.js": "^1.4.1",
21
- "d3-array": "^3",
22
- "d3-shape": "^3",
23
- "d3-scale": "^4",
24
- "d3-interpolate": "^3",
25
- "d3-transition": "^3",
26
- "resize-observer-polyfill": "^1.5"
20
+ "@upsetjs/venn.js": "1.4.1",
21
+ "d3-array": "3.1.6",
22
+ "d3-shape": "3.1.0",
23
+ "d3-scale": "3.3.0",
24
+ "d3-interpolate": "3.0.1",
25
+ "d3-transition": "3.0.1",
26
+ "resize-observer-polyfill": "1.5.1",
27
+ "hoist-non-react-statics": "3.3.2"
27
28
  },
28
29
  "peerDependencies": {
29
30
  "@semcore/core": "^1.11",
@@ -36,5 +37,16 @@
36
37
  "type": "git",
37
38
  "url": "https://github.com/semrush/intergalactic.git",
38
39
  "directory": "semcore/d3-chart"
40
+ },
41
+ "devDependencies": {
42
+ "@semcore/jest-preset-ui": "1.0.0",
43
+ "@types/d3-array": "^3.0.2",
44
+ "@types/d3-scale": "^4.0.2",
45
+ "@types/d3-transition": "^3.0.1",
46
+ "@semcore/typography": "*",
47
+ "@semcore/dropdown-menu": "*",
48
+ "@semcore/button": "*",
49
+ "@semcore/checkbox": "*",
50
+ "@semcore/icon": "*"
39
51
  }
40
52
  }
package/src/Bubble.jsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Component, sstyled } from '@semcore/core';
3
3
  import canUseDOM from '@semcore/utils/lib/canUseDOM';
4
- import { CONSTANT } from './utils';
4
+ import { CONSTANT, measureText } from './utils';
5
5
  import createElement from './createElement';
6
6
  import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
7
7
  import { transition } from 'd3-transition';
@@ -9,26 +9,6 @@ import style from './style/bubble.shadow.css';
9
9
  import ClipPath from './ClipPath';
10
10
  import { scaleSqrt } from 'd3-scale';
11
11
 
12
- const memoize = (func) => {
13
- const results = {};
14
- return (argsKey) => {
15
- if (!results[argsKey]) {
16
- results[argsKey] = func(argsKey);
17
- }
18
- return results[argsKey];
19
- };
20
- };
21
-
22
- const measureText = memoize((text) => {
23
- const span = document.createElement('span');
24
- span.append(document.createTextNode(text));
25
- span.style.display = 'inline-block';
26
- document.body.append(span);
27
- const textLength = span.offsetWidth;
28
- span.remove();
29
- return textLength;
30
- });
31
-
32
12
  class BubbleRoot extends Component {
33
13
  static displayName = 'Bubble';
34
14
  static style = style;
package/src/ClipPath.jsx CHANGED
@@ -34,6 +34,7 @@ class ClipPath extends Component {
34
34
  }
35
35
 
36
36
  render() {
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
37
38
  const { id, transition, tag: Tag, style, className, ...other } = this.asProps;
38
39
  return (
39
40
  <clipPath ref={this.refClipPath} id={id}>
package/src/Donut.jsx CHANGED
@@ -111,7 +111,7 @@ class DonutRoot extends Component {
111
111
  }
112
112
 
113
113
  getArcs() {
114
- let { Children, data, d3Pie } = this.asProps;
114
+ const { Children, data, d3Pie } = this.asProps;
115
115
  let pieData = Object.entries(data);
116
116
 
117
117
  if (d3Pie[DEFAULT_INSTANCE]) {
@@ -137,14 +137,12 @@ class DonutRoot extends Component {
137
137
  return d3Pie(pieData);
138
138
  }
139
139
 
140
- bindHandlerTooltip =
141
- (visible, props) =>
142
- ({ clientX: x, clientY: y }) => {
143
- const { eventEmitter } = this.asProps;
144
- this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);
145
- this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
146
- eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);
147
- };
140
+ bindHandlerTooltip = (visible, props) => ({ clientX: x, clientY: y }) => {
141
+ const { eventEmitter } = this.asProps;
142
+ this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);
143
+ this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
144
+ eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);
145
+ };
148
146
 
149
147
  getPieProps(props) {
150
148
  let { d3Arc, duration, innerRadius } = this.asProps;
package/src/Plot.jsx CHANGED
@@ -3,9 +3,11 @@ import createComponent, { Component, Root, sstyled } from '@semcore/core';
3
3
  import { Box } from '@semcore/flex-box';
4
4
  import EventEmitter from '@semcore/utils/lib/eventEmitter';
5
5
  import { eventToPoint } from './utils';
6
+ import style from './style/plot.shadow.css';
6
7
 
7
8
  class PlotRoot extends Component {
8
9
  static displayName = 'Plot';
10
+ static style = style;
9
11
 
10
12
  constructor(props) {
11
13
  super(props);