@semcore/d3-chart 1.7.1 → 2.0.0
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.
- package/CHANGELOG.md +18 -0
- package/lib/cjs/Area.js +9 -9
- package/lib/cjs/Axis.js +33 -21
- package/lib/cjs/Axis.js.map +1 -1
- package/lib/cjs/Bar.js +11 -11
- package/lib/cjs/Bar.js.map +1 -1
- package/lib/cjs/Bubble.js +13 -34
- package/lib/cjs/Bubble.js.map +1 -1
- package/lib/cjs/ClipPath.js +2 -1
- package/lib/cjs/ClipPath.js.map +1 -1
- package/lib/cjs/Donut.js +8 -8
- package/lib/cjs/Donut.js.map +1 -1
- package/lib/cjs/Dots.js +9 -9
- package/lib/cjs/Dots.js.map +1 -1
- package/lib/cjs/GroupBar.js +8 -8
- package/lib/cjs/GroupBar.js.map +1 -1
- package/lib/cjs/HorizontalBar.js +11 -11
- package/lib/cjs/HorizontalBar.js.map +1 -1
- package/lib/cjs/Hover.js +4 -4
- package/lib/cjs/Line.js +8 -8
- package/lib/cjs/Plot.js +15 -1
- package/lib/cjs/Plot.js.map +1 -1
- package/lib/cjs/RadialTree.js +694 -0
- package/lib/cjs/RadialTree.js.map +1 -0
- package/lib/cjs/ResponsiveContainer.js +1 -1
- package/lib/cjs/ResponsiveContainer.js.map +1 -1
- package/lib/cjs/ScatterPlot.js +7 -7
- package/lib/cjs/StackBar.js +8 -8
- package/lib/cjs/StackBar.js.map +1 -1
- package/lib/cjs/StackedArea.js +8 -8
- package/lib/cjs/StackedArea.js.map +1 -1
- package/lib/cjs/Tooltip.js +11 -15
- package/lib/cjs/Tooltip.js.map +1 -1
- package/lib/cjs/Venn.js +9 -9
- package/lib/cjs/Venn.js.map +1 -1
- package/lib/cjs/color.js +122 -30
- package/lib/cjs/color.js.map +1 -1
- package/lib/cjs/createElement.js +3 -2
- package/lib/cjs/createElement.js.map +1 -1
- package/lib/cjs/index.js +8 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/area.shadow.css +4 -4
- package/lib/cjs/style/axis.shadow.css +6 -8
- package/lib/cjs/style/bar.shadow.css +2 -2
- package/lib/cjs/style/bubble.shadow.css +3 -3
- package/lib/cjs/style/donut.shadow.css +2 -2
- package/lib/cjs/style/dot.shadow.css +1 -1
- package/lib/cjs/style/hover.shadow.css +2 -2
- package/lib/cjs/style/line.shadow.css +2 -2
- package/lib/cjs/style/plot.shadow.css +6 -0
- package/lib/cjs/style/radial-tree.shadow.css +34 -0
- package/lib/cjs/style/scatterplot.shadow.css +2 -2
- package/lib/cjs/style/tooltip.shadow.css +5 -5
- package/lib/cjs/style/var.css +123 -30
- package/lib/cjs/style/venn.shadow.css +1 -1
- package/lib/cjs/types/Area.d.ts +47 -0
- package/lib/cjs/types/Axis.d.ts +64 -0
- package/lib/cjs/types/Bar.d.ts +48 -0
- package/lib/cjs/types/Bubble.d.ts +27 -0
- package/lib/cjs/types/ClipPath.d.ts +26 -0
- package/lib/cjs/types/Donut.d.ts +42 -0
- package/lib/cjs/types/GroupBar.d.ts +20 -0
- package/lib/cjs/types/HorizontalBar.d.ts +29 -0
- package/lib/cjs/types/Hover.d.ts +15 -0
- package/lib/cjs/types/Line.d.ts +50 -0
- package/lib/cjs/types/Plot.d.ts +16 -0
- package/lib/cjs/types/ResponsiveContainer.d.ts +20 -0
- package/lib/cjs/types/ScatterPlot.d.ts +27 -0
- package/lib/cjs/types/StackBar.d.ts +26 -0
- package/lib/cjs/types/StackedArea.d.ts +26 -0
- package/lib/cjs/types/Tooltip.d.ts +31 -0
- package/lib/cjs/types/Venn.d.ts +45 -0
- package/lib/cjs/types/context.d.ts +6 -0
- package/lib/cjs/types/index.d.ts +53 -0
- package/lib/cjs/utils.js +120 -55
- package/lib/cjs/utils.js.map +1 -1
- package/lib/es6/Area.js +9 -9
- package/lib/es6/Axis.js +33 -21
- package/lib/es6/Axis.js.map +1 -1
- package/lib/es6/Bar.js +11 -11
- package/lib/es6/Bar.js.map +1 -1
- package/lib/es6/Bubble.js +13 -34
- package/lib/es6/Bubble.js.map +1 -1
- package/lib/es6/ClipPath.js +2 -1
- package/lib/es6/ClipPath.js.map +1 -1
- package/lib/es6/Donut.js +8 -8
- package/lib/es6/Donut.js.map +1 -1
- package/lib/es6/Dots.js +9 -9
- package/lib/es6/Dots.js.map +1 -1
- package/lib/es6/GroupBar.js +8 -8
- package/lib/es6/GroupBar.js.map +1 -1
- package/lib/es6/HorizontalBar.js +11 -11
- package/lib/es6/HorizontalBar.js.map +1 -1
- package/lib/es6/Hover.js +4 -4
- package/lib/es6/Line.js +8 -8
- package/lib/es6/Plot.js +17 -1
- package/lib/es6/Plot.js.map +1 -1
- package/lib/es6/RadialTree.js +682 -0
- package/lib/es6/RadialTree.js.map +1 -0
- package/lib/es6/ResponsiveContainer.js +1 -1
- package/lib/es6/ResponsiveContainer.js.map +1 -1
- package/lib/es6/ScatterPlot.js +7 -7
- package/lib/es6/StackBar.js +8 -8
- package/lib/es6/StackBar.js.map +1 -1
- package/lib/es6/StackedArea.js +8 -8
- package/lib/es6/StackedArea.js.map +1 -1
- package/lib/es6/Tooltip.js +11 -15
- package/lib/es6/Tooltip.js.map +1 -1
- package/lib/es6/Venn.js +9 -9
- package/lib/es6/Venn.js.map +1 -1
- package/lib/es6/color.js +122 -30
- package/lib/es6/color.js.map +1 -1
- package/lib/es6/createElement.js +3 -2
- package/lib/es6/createElement.js.map +1 -1
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/area.shadow.css +4 -4
- package/lib/es6/style/axis.shadow.css +6 -8
- package/lib/es6/style/bar.shadow.css +2 -2
- package/lib/es6/style/bubble.shadow.css +3 -3
- package/lib/es6/style/donut.shadow.css +2 -2
- package/lib/es6/style/dot.shadow.css +1 -1
- package/lib/es6/style/hover.shadow.css +2 -2
- package/lib/es6/style/line.shadow.css +2 -2
- package/lib/es6/style/plot.shadow.css +6 -0
- package/lib/es6/style/radial-tree.shadow.css +34 -0
- package/lib/es6/style/scatterplot.shadow.css +2 -2
- package/lib/es6/style/tooltip.shadow.css +5 -5
- package/lib/es6/style/var.css +123 -30
- package/lib/es6/style/venn.shadow.css +1 -1
- package/lib/es6/types/Area.d.ts +47 -0
- package/lib/es6/types/Axis.d.ts +64 -0
- package/lib/es6/types/Bar.d.ts +48 -0
- package/lib/es6/types/Bubble.d.ts +27 -0
- package/lib/es6/types/ClipPath.d.ts +26 -0
- package/lib/es6/types/Donut.d.ts +42 -0
- package/lib/es6/types/GroupBar.d.ts +20 -0
- package/lib/es6/types/HorizontalBar.d.ts +29 -0
- package/lib/es6/types/Hover.d.ts +15 -0
- package/lib/es6/types/Line.d.ts +50 -0
- package/lib/es6/types/Plot.d.ts +16 -0
- package/lib/es6/types/ResponsiveContainer.d.ts +20 -0
- package/lib/es6/types/ScatterPlot.d.ts +27 -0
- package/lib/es6/types/StackBar.d.ts +26 -0
- package/lib/es6/types/StackedArea.d.ts +26 -0
- package/lib/es6/types/Tooltip.d.ts +31 -0
- package/lib/es6/types/Venn.d.ts +45 -0
- package/lib/es6/types/context.d.ts +6 -0
- package/lib/es6/types/index.d.ts +53 -0
- package/lib/es6/utils.js +95 -44
- package/lib/es6/utils.js.map +1 -1
- package/lib/types/RadialTree.d.ts +202 -0
- package/lib/types/index.d.ts +6 -0
- package/lib/types/utils.d.ts +27 -0
- package/package.json +22 -10
- package/src/Axis.jsx +11 -1
- package/src/Bubble.jsx +1 -21
- package/src/ClipPath.jsx +1 -0
- package/src/Donut.jsx +7 -9
- package/src/Plot.jsx +2 -0
- package/src/RadialTree.tsx +767 -0
- package/src/createElement.jsx +3 -1
- package/src/index.js +1 -0
- package/src/style/area.shadow.css +4 -4
- package/src/style/axis.shadow.css +6 -8
- package/src/style/bar.shadow.css +2 -2
- package/src/style/bubble.shadow.css +3 -3
- package/src/style/donut.shadow.css +2 -2
- package/src/style/dot.shadow.css +1 -1
- package/src/style/hover.shadow.css +2 -2
- package/src/style/line.shadow.css +2 -2
- package/src/style/plot.shadow.css +6 -0
- package/src/style/radial-tree.shadow.css +34 -0
- package/src/style/scatterplot.shadow.css +2 -2
- package/src/style/tooltip.shadow.css +5 -5
- package/src/style/var.css +123 -30
- package/src/style/venn.shadow.css +1 -1
- package/src/types/index.d.ts +6 -0
- package/src/utils.ts +227 -0
- 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": "
|
|
4
|
+
"version": "2.0.0",
|
|
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
|
-
"@
|
|
20
|
-
"
|
|
21
|
-
"d3-
|
|
22
|
-
"d3-
|
|
23
|
-
"d3-
|
|
24
|
-
"d3-
|
|
25
|
-
"
|
|
26
|
-
"
|
|
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/Axis.jsx
CHANGED
|
@@ -274,12 +274,22 @@ function Grid(props) {
|
|
|
274
274
|
function Title(props) {
|
|
275
275
|
const { Element: STitle, styles, scale, position } = props;
|
|
276
276
|
|
|
277
|
+
const { x, y } = MAP_POSITION_TITlE[position](scale);
|
|
278
|
+
|
|
279
|
+
const sstyles = sstyled(styles);
|
|
280
|
+
const sTitleStyles = sstyles.cn('STitle', {
|
|
281
|
+
'transform-origin': `${x.toFixed(2)}px ${y.toFixed(2)}px`,
|
|
282
|
+
});
|
|
283
|
+
|
|
277
284
|
return sstyled(styles)(
|
|
278
285
|
<STitle
|
|
279
286
|
render="text"
|
|
280
287
|
childrenPosition="inside"
|
|
281
288
|
position={position}
|
|
282
|
-
{
|
|
289
|
+
className={sTitleStyles.className}
|
|
290
|
+
style={sTitleStyles.style}
|
|
291
|
+
x={x}
|
|
292
|
+
y={y}
|
|
283
293
|
/>,
|
|
284
294
|
);
|
|
285
295
|
}
|
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
package/src/Donut.jsx
CHANGED
|
@@ -111,7 +111,7 @@ class DonutRoot extends Component {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
getArcs() {
|
|
114
|
-
|
|
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
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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);
|