@semcore/d3-chart 1.5.5 → 1.6.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 (113) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/lib/cjs/Area.js +9 -9
  3. package/lib/cjs/Area.js.map +1 -1
  4. package/lib/cjs/Axis.js +12 -12
  5. package/lib/cjs/Bar.js +8 -8
  6. package/lib/cjs/Bar.js.map +1 -1
  7. package/lib/cjs/Bubble.js +276 -0
  8. package/lib/cjs/Bubble.js.map +1 -0
  9. package/lib/cjs/Donut.js +77 -64
  10. package/lib/cjs/Donut.js.map +1 -1
  11. package/lib/cjs/Dots.js +8 -7
  12. package/lib/cjs/Dots.js.map +1 -1
  13. package/lib/cjs/GroupBar.js +6 -5
  14. package/lib/cjs/GroupBar.js.map +1 -1
  15. package/lib/cjs/HorizontalBar.js +8 -8
  16. package/lib/cjs/HorizontalBar.js.map +1 -1
  17. package/lib/cjs/Hover.js +3 -3
  18. package/lib/cjs/Line.js +8 -8
  19. package/lib/cjs/Line.js.map +1 -1
  20. package/lib/cjs/ScatterPlot.js +224 -0
  21. package/lib/cjs/ScatterPlot.js.map +1 -0
  22. package/lib/cjs/StackBar.js +6 -5
  23. package/lib/cjs/StackBar.js.map +1 -1
  24. package/lib/cjs/StackedArea.js +7 -6
  25. package/lib/cjs/StackedArea.js.map +1 -1
  26. package/lib/cjs/Tooltip.js +19 -15
  27. package/lib/cjs/Tooltip.js.map +1 -1
  28. package/lib/cjs/Venn.js +8 -8
  29. package/lib/cjs/Venn.js.map +1 -1
  30. package/lib/cjs/color.js +32 -30
  31. package/lib/cjs/color.js.map +1 -1
  32. package/lib/cjs/index.js +16 -0
  33. package/lib/cjs/index.js.map +1 -1
  34. package/lib/cjs/style/area.shadow.css +12 -2
  35. package/lib/cjs/style/bar.shadow.css +7 -2
  36. package/lib/cjs/style/bubble.shadow.css +45 -0
  37. package/lib/cjs/style/donut.shadow.css +15 -0
  38. package/lib/cjs/style/dot.shadow.css +6 -1
  39. package/lib/cjs/style/line.shadow.css +6 -1
  40. package/lib/cjs/style/scatterplot.shadow.css +27 -0
  41. package/lib/cjs/style/tooltip.shadow.css +7 -2
  42. package/lib/cjs/style/var.css +32 -0
  43. package/lib/cjs/style/venn.shadow.css +7 -1
  44. package/lib/es6/Area.js +9 -9
  45. package/lib/es6/Area.js.map +1 -1
  46. package/lib/es6/Axis.js +12 -12
  47. package/lib/es6/Bar.js +8 -8
  48. package/lib/es6/Bar.js.map +1 -1
  49. package/lib/es6/Bubble.js +259 -0
  50. package/lib/es6/Bubble.js.map +1 -0
  51. package/lib/es6/Donut.js +77 -64
  52. package/lib/es6/Donut.js.map +1 -1
  53. package/lib/es6/Dots.js +8 -7
  54. package/lib/es6/Dots.js.map +1 -1
  55. package/lib/es6/GroupBar.js +6 -5
  56. package/lib/es6/GroupBar.js.map +1 -1
  57. package/lib/es6/HorizontalBar.js +8 -8
  58. package/lib/es6/HorizontalBar.js.map +1 -1
  59. package/lib/es6/Hover.js +3 -3
  60. package/lib/es6/Line.js +8 -8
  61. package/lib/es6/Line.js.map +1 -1
  62. package/lib/es6/ScatterPlot.js +209 -0
  63. package/lib/es6/ScatterPlot.js.map +1 -0
  64. package/lib/es6/StackBar.js +6 -5
  65. package/lib/es6/StackBar.js.map +1 -1
  66. package/lib/es6/StackedArea.js +7 -6
  67. package/lib/es6/StackedArea.js.map +1 -1
  68. package/lib/es6/Tooltip.js +18 -14
  69. package/lib/es6/Tooltip.js.map +1 -1
  70. package/lib/es6/Venn.js +8 -8
  71. package/lib/es6/Venn.js.map +1 -1
  72. package/lib/es6/color.js +33 -31
  73. package/lib/es6/color.js.map +1 -1
  74. package/lib/es6/index.js +2 -0
  75. package/lib/es6/index.js.map +1 -1
  76. package/lib/es6/style/area.shadow.css +12 -2
  77. package/lib/es6/style/bar.shadow.css +7 -2
  78. package/lib/es6/style/bubble.shadow.css +45 -0
  79. package/lib/es6/style/donut.shadow.css +15 -0
  80. package/lib/es6/style/dot.shadow.css +6 -1
  81. package/lib/es6/style/line.shadow.css +6 -1
  82. package/lib/es6/style/scatterplot.shadow.css +27 -0
  83. package/lib/es6/style/tooltip.shadow.css +7 -2
  84. package/lib/es6/style/var.css +32 -0
  85. package/lib/es6/style/venn.shadow.css +7 -1
  86. package/lib/types/Bubble.d.ts +27 -0
  87. package/lib/types/ScatterPlot.d.ts +27 -0
  88. package/lib/types/index.d.ts +6 -0
  89. package/package.json +2 -2
  90. package/src/Area.js +0 -1
  91. package/src/Bar.js +0 -1
  92. package/src/Bubble.js +189 -0
  93. package/src/Donut.js +8 -7
  94. package/src/HorizontalBar.js +0 -1
  95. package/src/Line.js +0 -1
  96. package/src/ScatterPlot.js +130 -0
  97. package/src/Tooltip.js +12 -6
  98. package/src/Venn.js +1 -1
  99. package/src/color.js +6 -32
  100. package/src/index.js +2 -0
  101. package/src/style/area.shadow.css +12 -2
  102. package/src/style/bar.shadow.css +7 -2
  103. package/src/style/bubble.shadow.css +45 -0
  104. package/src/style/donut.shadow.css +15 -0
  105. package/src/style/dot.shadow.css +6 -1
  106. package/src/style/line.shadow.css +6 -1
  107. package/src/style/scatterplot.shadow.css +27 -0
  108. package/src/style/tooltip.shadow.css +7 -2
  109. package/src/style/var.css +32 -0
  110. package/src/style/venn.shadow.css +7 -1
  111. package/src/types/Bubble.d.ts +27 -0
  112. package/src/types/ScatterPlot.d.ts +27 -0
  113. package/src/types/index.d.ts +6 -0
@@ -0,0 +1,27 @@
1
+ import { CProps, ReturnEl } from '@semcore/core';
2
+ import IContext from './context';
3
+
4
+ export interface IScatterPlotProps extends IContext {
5
+ /** Field from data for XAxis */
6
+ x: string;
7
+ /** Field from data for YAxis */
8
+ y: string;
9
+ /** Field from data for circle value */
10
+ value?: string;
11
+ /** Circle color */
12
+ color?: string;
13
+ /** Circle value color */
14
+ valueColor?: string;
15
+ /** Animation duration in ms
16
+ * @default 500
17
+ */
18
+ duration?: number;
19
+ /** Radius of circles
20
+ * @default 5.5 or 12 with value
21
+ */
22
+ r?: number;
23
+ }
24
+
25
+ declare const ScatterPlot: <T>(props: CProps<IScatterPlotProps & T>) => ReturnEl;
26
+
27
+ export default ScatterPlot;
@@ -39,3 +39,9 @@ export * from './Donut';
39
39
 
40
40
  export { default as Tooltip } from './Tooltip';
41
41
  export * from './Tooltip';
42
+
43
+ export { default as ScatterPlot } from './ScatterPlot';
44
+ export * from './ScatterPlot';
45
+
46
+ export { default as Bubble } from './Bubble';
47
+ export * from './Bubble';
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.5.5",
4
+ "version": "1.6.2",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "dependencies": {
16
16
  "@semcore/flex-box": "^4",
17
17
  "@semcore/popper": "^4.9",
18
- "@semcore/utils": "^3.15",
18
+ "@semcore/utils": "^3.31",
19
19
  "@semcore/animation": "^1",
20
20
  "@upsetjs/venn.js": "^1.4.1",
21
21
  "d3-array": "^3",
package/src/Area.js CHANGED
@@ -30,7 +30,6 @@ class AreaRoot extends Component {
30
30
  .curve(curve)
31
31
  .x((p) => scaleOfBandwidth(xScale, p[x]))
32
32
  .y((p) => scaleOfBandwidth(yScale, p[y])),
33
- color: '#50aef4',
34
33
  duration: 500,
35
34
  };
36
35
  };
package/src/Bar.js CHANGED
@@ -14,7 +14,6 @@ class BarRoot extends Component {
14
14
  static enhance = [uniqueIDEnhancement()];
15
15
 
16
16
  static defaultProps = {
17
- color: '#50aef4',
18
17
  offset: [0, 0],
19
18
  duration: 500,
20
19
  r: 2,
package/src/Bubble.js ADDED
@@ -0,0 +1,189 @@
1
+ import React from 'react';
2
+ import { Component, sstyled } from '@semcore/core';
3
+ import canUseDOM from '@semcore/utils/lib/canUseDOM';
4
+ import { CONSTANT } from './utils';
5
+ import createElement from './createElement';
6
+ import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
7
+ import { transition } from 'd3-transition';
8
+ import style from './style/bubble.shadow.css';
9
+ import ClipPath from './ClipPath';
10
+ import { scaleSqrt } from 'd3-scale';
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
+ let 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
+ class BubbleRoot extends Component {
33
+ static displayName = 'Bubble';
34
+ static style = style;
35
+ static enhance = [uniqueIDEnhancement()];
36
+
37
+ static defaultProps = {
38
+ offset: [0, 0],
39
+ duration: 500,
40
+ markedCross: true,
41
+ };
42
+
43
+ virtualElement = canUseDOM() ? document.createElement('div') : {};
44
+
45
+ generateGetBoundingClientRect(x = 0, y = 0) {
46
+ return () => ({ width: 0, height: 0, top: y, right: x, bottom: y, left: x });
47
+ }
48
+
49
+ bindHandlerTooltip = (visible, props) => ({ clientX: x, clientY: y }) => {
50
+ const { eventEmitter } = this.asProps;
51
+ this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);
52
+ this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
53
+ eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);
54
+ };
55
+
56
+ animationCircle() {
57
+ const { duration, uid, data, value } = this.asProps;
58
+ const z = scaleSqrt()
59
+ .domain([0, Math.max(...data.map((el) => el[value]))])
60
+ .range([5.5, 50.5]);
61
+
62
+ const selectRect = transition()
63
+ .selection()
64
+ .selectAll(`[id^=${uid}${uid}]`)
65
+ .attr('r', 0);
66
+
67
+ const selectRectNode = selectRect.node();
68
+ if (duration > 0 && selectRectNode) {
69
+ selectRect
70
+ .transition()
71
+ .duration(duration)
72
+ .attr('r', function(_, ind) {
73
+ return z(data[ind][value]);
74
+ });
75
+ }
76
+ }
77
+
78
+ componentDidUpdate() {
79
+ this.animationCircle();
80
+ }
81
+
82
+ componentDidMount() {
83
+ this.animationCircle();
84
+ }
85
+
86
+ renderCircle(d, i) {
87
+ const {
88
+ color,
89
+ scale,
90
+ x,
91
+ y,
92
+ offset,
93
+ styles,
94
+ uid,
95
+ duration,
96
+ value,
97
+ label,
98
+ markedCross,
99
+ size,
100
+ data,
101
+ } = this.asProps;
102
+ const [xScale, yScale] = scale;
103
+
104
+ const SBubble = this.Element;
105
+ const SCenter = 'text';
106
+ const SLabel = 'text';
107
+ const z = scaleSqrt()
108
+ .domain([0, Math.max(...data.map((el) => el[value]))])
109
+ .range([5.5, 50.5]);
110
+
111
+ const margin = Math.min(xScale.range()[0], xScale.range()[1]);
112
+
113
+ const labelPosition =
114
+ size[0] - 2 * margin - (xScale(d[x]) + offset[0] + z(d[value])) < measureText(d[label])
115
+ ? 'right'
116
+ : 'left';
117
+ const labelDistance = {
118
+ right: xScale(d[x]) + offset[0] - z(d[value]),
119
+ left: xScale(d[x]) + offset[0] + z(d[value]),
120
+ }[labelPosition];
121
+
122
+ return sstyled(styles)(
123
+ <g
124
+ key={`circle(#${i})`}
125
+ onMouseMove={this.bindHandlerTooltip(true, { ...this.props, xIndex: i })}
126
+ onMouseLeave={this.bindHandlerTooltip(false, { ...this.props, xIndex: i })}
127
+ >
128
+ {markedCross && (
129
+ <SCenter
130
+ x={xScale(d[x]) + offset[0]}
131
+ y={yScale(d[y]) + offset[1]}
132
+ dy=".3em"
133
+ clipPath={`url(#${uid})`}
134
+ color={d[color] ?? color}
135
+ >
136
+ &#43;
137
+ </SCenter>
138
+ )}
139
+ <SBubble
140
+ id={`${uid}${uid}`}
141
+ render="circle"
142
+ clipPath={`url(#${uid})`}
143
+ cx={xScale(d[x]) + offset[0]}
144
+ cy={yScale(d[y]) + offset[1]}
145
+ color={d[color]}
146
+ r={z(d[value])}
147
+ use:duration={`${duration}ms`}
148
+ />
149
+ {d[label] && (
150
+ <SLabel
151
+ x={labelDistance}
152
+ y={yScale(d[y]) + offset[1]}
153
+ dy=".3em"
154
+ clipPath={`url(#${uid})`}
155
+ position={labelPosition}
156
+ color={d[color]}
157
+ >
158
+ {d[label]}
159
+ </SLabel>
160
+ )}
161
+ </g>,
162
+ );
163
+ }
164
+
165
+ render() {
166
+ const { data, uid, size, scale } = this.asProps;
167
+ const [xScale, yScale] = scale;
168
+ const marginX = Math.min(xScale.range()[0], xScale.range()[1]);
169
+ const marginY = Math.min(yScale.range()[0], yScale.range()[1]);
170
+
171
+ return (
172
+ <>
173
+ {data.map(this.renderCircle.bind(this))}
174
+ {data.map(this.animationCircle.bind(this))}
175
+ <ClipPath
176
+ id={uid}
177
+ x={marginX}
178
+ y={marginY}
179
+ width={`${size[0] - 2 * marginX}px`}
180
+ height={`${size[1] - 2 * marginY}px`}
181
+ />
182
+ </>
183
+ );
184
+ }
185
+ }
186
+
187
+ const Bubble = createElement(BubbleRoot);
188
+
189
+ export default Bubble;
package/src/Donut.js CHANGED
@@ -181,12 +181,7 @@ class DonutRoot extends Component {
181
181
  getEmptyDataProps() {
182
182
  const { d3Arc } = this.asProps;
183
183
  return {
184
- data: {
185
- endAngle: Math.PI * 2,
186
- startAngle: 0,
187
- },
188
184
  d3Arc,
189
- color: '#E4ECF1',
190
185
  };
191
186
  }
192
187
 
@@ -236,10 +231,16 @@ class DonutRoot extends Component {
236
231
  }
237
232
  }
238
233
 
239
- function Pie({ Element: SPie, styles, d3Arc, data, color = '#50aef4' }) {
234
+ function Pie({ Element: SPie, styles, d3Arc, data, color }) {
240
235
  return sstyled(styles)(<SPie render="path" color={color} d={d3Arc(data)} />);
241
236
  }
242
237
 
238
+ function EmptyData({ Element: SEmptyData, styles, d3Arc, color }) {
239
+ return sstyled(styles)(
240
+ <SEmptyData render="path" color={color} d={d3Arc({ endAngle: Math.PI * 2, startAngle: 0 })} />,
241
+ );
242
+ }
243
+
243
244
  function Label({ Element: SLabel, styles, Children }) {
244
245
  return sstyled(styles)(
245
246
  <SLabel render="text" x="0" y="0">
@@ -248,6 +249,6 @@ function Label({ Element: SLabel, styles, Children }) {
248
249
  );
249
250
  }
250
251
 
251
- const Donut = createElement(DonutRoot, { Pie, Label, EmptyData: Pie });
252
+ const Donut = createElement(DonutRoot, { Pie, Label, EmptyData });
252
253
 
253
254
  export default Donut;
@@ -13,7 +13,6 @@ class HorizontalBarRoot extends Component {
13
13
  static style = style;
14
14
 
15
15
  static defaultProps = {
16
- color: '#50aef4',
17
16
  offset: [0, 0],
18
17
  duration: 500,
19
18
  r: 2,
package/src/Line.js CHANGED
@@ -22,7 +22,6 @@ class LineRoot extends Component {
22
22
  .curve(curve)
23
23
  .x((p) => scaleOfBandwidth(xScale, p[x]))
24
24
  .y((p) => scaleOfBandwidth(yScale, p[y])),
25
- color: '#50aef4',
26
25
  duration: 500,
27
26
  };
28
27
  };
@@ -0,0 +1,130 @@
1
+ import React from 'react';
2
+ import { Component, sstyled } from '@semcore/core';
3
+ import canUseDOM from '@semcore/utils/lib/canUseDOM';
4
+ import { CONSTANT } from './utils';
5
+ import createElement from './createElement';
6
+ import uniqueIDEnhancement from '@semcore/utils/lib/uniqueID';
7
+ import { transition } from 'd3-transition';
8
+ import style from './style/scatterplot.shadow.css';
9
+ import ClipPath from './ClipPath';
10
+
11
+ class ScatterPlotRoot extends Component {
12
+ static displayName = 'ScatterPlot';
13
+ static style = style;
14
+ static enhance = [uniqueIDEnhancement()];
15
+
16
+ static defaultProps = {
17
+ offset: [0, 0],
18
+ duration: 500,
19
+ };
20
+
21
+ virtualElement = canUseDOM() ? document.createElement('div') : {};
22
+
23
+ generateGetBoundingClientRect(x = 0, y = 0) {
24
+ return () => ({ width: 0, height: 0, top: y, right: x, bottom: y, left: x });
25
+ }
26
+
27
+ bindHandlerTooltip = (visible, props) => ({ clientX: x, clientY: y }) => {
28
+ const { eventEmitter } = this.asProps;
29
+ this.virtualElement.getBoundingClientRect = this.generateGetBoundingClientRect(x, y);
30
+ this.virtualElement[CONSTANT.VIRTUAL_ELEMENT] = true;
31
+ eventEmitter.emit('onTooltipVisible', visible, props, this.virtualElement);
32
+ };
33
+
34
+ animationCircle() {
35
+ const { duration, uid, r, value } = this.asProps;
36
+ const radius = r ? r : value ? 12 : 5.5;
37
+ const selectRect = transition()
38
+ .selection()
39
+ .selectAll(`[id^=${uid}]`)
40
+ .attr('r', 0);
41
+ const selectRectNode = selectRect.node();
42
+
43
+ if (duration > 0 && selectRectNode) {
44
+ selectRect
45
+ .transition()
46
+ .duration(duration)
47
+ .attr('r', radius);
48
+ }
49
+ }
50
+
51
+ componentDidUpdate() {
52
+ this.animationCircle();
53
+ }
54
+
55
+ componentDidMount() {
56
+ this.animationCircle();
57
+ }
58
+
59
+ renderCircle(d, i) {
60
+ const {
61
+ color,
62
+ scale,
63
+ x,
64
+ y,
65
+ r,
66
+ offset,
67
+ styles,
68
+ uid,
69
+ duration,
70
+ value,
71
+ valueColor,
72
+ } = this.asProps;
73
+ const [xScale, yScale] = scale;
74
+ const SScatterPlot = this.Element;
75
+ const SValue = 'text';
76
+ return sstyled(styles)(
77
+ <g
78
+ key={`circle(#${i})`}
79
+ onMouseMove={this.bindHandlerTooltip(true, { ...this.props, xIndex: i })}
80
+ onMouseLeave={this.bindHandlerTooltip(false, { ...this.props, xIndex: i })}
81
+ >
82
+ <SScatterPlot
83
+ id={`${uid}${i}`}
84
+ render="circle"
85
+ clipPath={`url(#${uid})`}
86
+ cx={xScale(d[x]) + offset[0]}
87
+ cy={yScale(d[y]) + offset[1]}
88
+ color={color}
89
+ r={r}
90
+ use:duration={`${duration}ms`}
91
+ />
92
+ {d[value] && (
93
+ <SValue
94
+ x={xScale(d[x]) + offset[0]}
95
+ y={yScale(d[y]) + offset[1]}
96
+ dy=".3em"
97
+ clipPath={`url(#${uid})`}
98
+ color={valueColor}
99
+ >
100
+ {d[value]}
101
+ </SValue>
102
+ )}
103
+ </g>,
104
+ );
105
+ }
106
+
107
+ render() {
108
+ const { data, uid, size, scale } = this.asProps;
109
+ const [xScale, yScale] = scale;
110
+ const marginX = Math.min(xScale.range()[0], xScale.range()[1]);
111
+ const marginY = Math.min(yScale.range()[0], yScale.range()[1]);
112
+
113
+ return (
114
+ <>
115
+ {data.map(this.renderCircle.bind(this))}
116
+ <ClipPath
117
+ id={uid}
118
+ x={marginX}
119
+ y={marginY}
120
+ width={`${size[0] - 2 * marginX}px`}
121
+ height={`${size[1] - 2 * marginY}px`}
122
+ />
123
+ </>
124
+ );
125
+ }
126
+ }
127
+
128
+ const ScatterPlot = createElement(ScatterPlotRoot);
129
+
130
+ export default ScatterPlot;
package/src/Tooltip.js CHANGED
@@ -2,10 +2,10 @@ import React, { useCallback } from 'react';
2
2
  import { Component, Root, sstyled } from '@semcore/core';
3
3
  import Popper from '@semcore/popper';
4
4
  import { Box } from '@semcore/flex-box';
5
- import findComponent from '@semcore/utils/lib/findComponent';
6
- import resolveColor from '@semcore/utils/lib/color';
5
+ import { isAdvanceMode } from '@semcore/utils/lib/findComponent';
7
6
  import { CONSTANT } from './utils';
8
7
  import createElement from './createElement';
8
+ import resolveColor from '@semcore/utils/lib/color';
9
9
 
10
10
  import style from './style/tooltip.shadow.css';
11
11
 
@@ -63,7 +63,7 @@ class TooltipRoot extends Component {
63
63
  render() {
64
64
  const { Children, children, tag, ...other } = this.asProps;
65
65
 
66
- const advanceMode = !!findComponent(Children, [
66
+ const advanceMode = isAdvanceMode(Children, [
67
67
  Tooltip.Trigger.displayName,
68
68
  Tooltip.Popper.displayName,
69
69
  ]);
@@ -96,14 +96,20 @@ class TooltipRoot extends Component {
96
96
  }
97
97
 
98
98
  function PopperPopper(props) {
99
- const { Element: STooltip, styles, $visible } = props;
99
+ const { Element: STooltip, styles, $visible, x, y } = props;
100
100
 
101
101
  const handlerCancel = useCallback(() => false, []);
102
102
 
103
103
  if (!$visible) return null;
104
104
 
105
105
  return sstyled(styles)(
106
- <STooltip render={Popper.Popper} childrenPosition="inside" onMouseMove={handlerCancel} />,
106
+ <STooltip
107
+ render={Popper.Popper}
108
+ childrenPosition="inside"
109
+ onMouseMove={handlerCancel}
110
+ x={x}
111
+ y={y}
112
+ />,
107
113
  );
108
114
  }
109
115
 
@@ -114,7 +120,7 @@ function Title(props) {
114
120
  }
115
121
 
116
122
  function Dot(props) {
117
- const { styles, color = '#50aef4', Children } = props;
123
+ const { styles, color, Children } = props;
118
124
  const SDotGroup = Root;
119
125
  const SDot = Box;
120
126
  return sstyled(styles)(
package/src/Venn.js CHANGED
@@ -81,7 +81,7 @@ class VennRoot extends Component {
81
81
  }
82
82
  }
83
83
 
84
- function Circle({ Element: SCircle, styles, color = '#3AB011', data, duration }) {
84
+ function Circle({ Element: SCircle, styles, color, data, duration }) {
85
85
  return sstyled(styles)(
86
86
  <SCircle
87
87
  render="circle"
package/src/color.js CHANGED
@@ -1,35 +1,8 @@
1
- export const colors = {
2
- 'blue-01': '#50aef4',
3
- 'blue-02': '#91c7ef',
4
- 'blue-03': '#0e75c2',
5
- 'blue-04': '#d1e8f8',
6
- 'blue-05': '#084c80',
7
- 'green-01': '#3ab011',
8
- 'green-02': '#91d27b',
9
- 'green-03': '#278707',
10
- 'green-04': '#d1edc8',
11
- 'green-05': '#1a6700',
12
- 'orange-01': '#ff8e29',
13
- 'orange-02': '#fec089',
14
- 'orange-03': '#da6905',
15
- 'orange-04': '#ffe5cd',
16
- 'orange-05': '#a14e03',
17
- 'violet-01': '#890c85',
18
- 'violet-02': '#c783c5',
19
- 'violet-03': '#6e026b',
20
- 'violet-04': '#e7cbe6',
21
- 'violet-05': '#4d024b',
22
- 'red-01': '#e91e25',
23
- 'red-02': '#f69498',
24
- 'red-03': '#bd0000',
25
- 'red-04': '#fbd2d3',
26
- 'red-05': '#830005',
27
- 'yellow-01': '#ffc83f',
28
- 'yellow-02': '#ffdb82',
29
- 'yellow-03': '#e4aa18',
30
- 'yellow-04': '#ffebb9',
31
- 'yellow-05': '#b3840c',
32
- };
1
+ /*__semcore-vars__:"./style/var.css"*/
2
+ const colors = preval`
3
+ const path = require('path');
4
+ module.exports = require('@semcore/babel-plugin-react-semcore/utils/vars')(path.resolve(__dirname, './style/var.css'));
5
+ `;
33
6
 
34
7
  let componentRenderIndex = 0;
35
8
  const cache = {};
@@ -37,6 +10,7 @@ const colorValues = Object.keys(colors).sort((a, b) => {
37
10
  return parseInt(a.match(/[0-9]/g).join(''), 10) - parseInt(b.match(/[0-9]/g).join(''), 10);
38
11
  });
39
12
 
13
+ export { colors };
40
14
  export default function getColor(key) {
41
15
  if (cache[key]) {
42
16
  return cache[key];
package/src/index.js CHANGED
@@ -10,6 +10,8 @@ export { default as GroupBar } from './GroupBar';
10
10
  export { default as StackBar } from './StackBar';
11
11
  export { default as Area } from './Area';
12
12
  export { default as StackedArea } from './StackedArea';
13
+ export { default as ScatterPlot } from './ScatterPlot';
14
+ export { default as Bubble } from './Bubble';
13
15
  export { default as Donut } from './Donut';
14
16
  export { default as Venn } from './Venn';
15
17
 
@@ -1,14 +1,24 @@
1
+ @import '@semcore/d3-chart/src/style/var.css';
2
+
1
3
  SArea {
2
- fill: var(--color);
4
+ fill: var(--blue-01);
3
5
  fill-opacity: 0.4;
4
6
  }
5
7
 
8
+ SArea[color] {
9
+ fill: var(--color);
10
+ }
11
+
6
12
  SAreaLine {
7
- stroke: var(--color);
13
+ stroke: var(--blue-01);
8
14
  stroke-width: 3;
9
15
  fill: transparent;
10
16
  }
11
17
 
18
+ SAreaLine[color] {
19
+ stroke: var(--color);
20
+ }
21
+
12
22
  SArea,
13
23
  SAreaLine {
14
24
  transition-property: d;
@@ -1,16 +1,21 @@
1
1
  @import '@semcore/utils/style/var.css';
2
+ @import '@semcore/d3-chart/src/style/var.css';
2
3
 
3
4
  SBar {
4
- fill: var(--color);
5
+ fill: var(--blue-01);
5
6
  transition-property: height, width, y;
6
7
  transition-duration: var(--duration);
7
8
  transition-timing-function: ease-in-out;
8
9
  }
9
10
 
11
+ SBar[color] {
12
+ fill: var(--color);
13
+ }
14
+
10
15
  SBar[hide] {
11
16
  display: none;
12
17
  }
13
18
 
14
19
  SBackground {
15
- fill: color-mod(var(--mystic));
20
+ fill: var(--mystic);
16
21
  }
@@ -0,0 +1,45 @@
1
+ @import '@semcore/utils/style/var.css';
2
+ @import '@semcore/d3-chart/src/style/var.css';
3
+
4
+ SBubble {
5
+ fill: #2bb3ff;
6
+ stroke: #fff;
7
+ stroke-width: 2px;
8
+ transition-property: cx, cy;
9
+ transition-duration: var(--duration);
10
+ transition-timing-function: ease-in-out;
11
+ opacity: 0.5;
12
+ &:hover {
13
+ opacity: 0.8;
14
+ }
15
+ }
16
+
17
+ SBubble[color] {
18
+ fill: var(--color);
19
+ }
20
+
21
+ SCenter {
22
+ text-anchor: middle;
23
+ font-size: 11px;
24
+ stroke: #2bb3ff;
25
+ }
26
+
27
+ SCenter[color] {
28
+ stroke: var(--color);
29
+ }
30
+
31
+ SLabel {
32
+ fill: #2bb3ff;
33
+ }
34
+
35
+ SLabel[position='right'] {
36
+ text-anchor: end;
37
+ }
38
+
39
+ SLabel[position='left'] {
40
+ text-anchor: start;
41
+ }
42
+
43
+ SLabel[color] {
44
+ fill: var(--color);
45
+ }
@@ -1,5 +1,20 @@
1
+ @import '@semcore/utils/style/var.css';
2
+ @import '@semcore/d3-chart/src/style/var.css';
3
+
1
4
  SPie {
2
5
  stroke: #ffffff;
6
+ fill: var(--blue-01);
7
+ }
8
+
9
+ SPie[color] {
10
+ fill: var(--color);
11
+ }
12
+
13
+ SEmptyData {
14
+ fill: var(--mystic);
15
+ }
16
+
17
+ SEmptyData[color] {
3
18
  fill: var(--color);
4
19
  }
5
20