@easyv/charts 1.4.24 → 1.4.25

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 (89) hide show
  1. package/.babelrc +8 -8
  2. package/.husky/commit-msg +3 -3
  3. package/CHANGELOG.md +18 -18
  4. package/commitlint.config.js +1 -1
  5. package/lib/components/AnimateData.js +16 -8
  6. package/lib/components/Axis.js +133 -86
  7. package/lib/components/Background.js +26 -18
  8. package/lib/components/Band.js +98 -72
  9. package/lib/components/BaseLine.js +46 -33
  10. package/lib/components/Brush.js +46 -29
  11. package/lib/components/Carousel.js +40 -13
  12. package/lib/components/CartesianChart.js +146 -98
  13. package/lib/components/Chart.js +36 -23
  14. package/lib/components/ChartContainer.js +27 -18
  15. package/lib/components/ConicalGradient.js +89 -56
  16. package/lib/components/Control.js +28 -12
  17. package/lib/components/ExtentData.js +17 -9
  18. package/lib/components/FilterData.js +27 -16
  19. package/lib/components/Indicator.js +30 -23
  20. package/lib/components/Label.js +126 -96
  21. package/lib/components/Legend.js +66 -41
  22. package/lib/components/Lighter.js +50 -21
  23. package/lib/components/Line.js +59 -39
  24. package/lib/components/LinearGradient.js +22 -16
  25. package/lib/components/Mapping.js +34 -9
  26. package/lib/components/Marquee.js +31 -15
  27. package/lib/components/PieChart.js +405 -311
  28. package/lib/components/StackData.js +18 -8
  29. package/lib/components/StereoBar.js +105 -65
  30. package/lib/components/TextOverflow.js +21 -8
  31. package/lib/components/Tooltip.js +55 -41
  32. package/lib/components/index.js +28 -0
  33. package/lib/context/index.js +2 -0
  34. package/lib/css/index.module.css +42 -42
  35. package/lib/css/piechart.module.css +26 -26
  36. package/lib/element/ConicGradient.js +35 -29
  37. package/lib/element/Line.js +13 -9
  38. package/lib/element/index.js +2 -0
  39. package/lib/formatter/index.js +2 -0
  40. package/lib/formatter/legend.js +41 -30
  41. package/lib/hooks/index.js +9 -0
  42. package/lib/hooks/useAiData.js +20 -12
  43. package/lib/hooks/useAnimateData.js +21 -8
  44. package/lib/hooks/useAxes.js +117 -67
  45. package/lib/hooks/useCarouselAxisX.js +60 -27
  46. package/lib/hooks/useExtentData.js +46 -14
  47. package/lib/hooks/useFilterData.js +34 -13
  48. package/lib/hooks/useStackData.js +35 -12
  49. package/lib/hooks/useTooltip.js +53 -36
  50. package/lib/index.js +15 -0
  51. package/lib/utils/index.js +247 -95
  52. package/package.json +55 -55
  53. package/src/components/Background.tsx +61 -61
  54. package/src/components/Band.tsx +274 -274
  55. package/src/components/Brush.js +159 -159
  56. package/src/components/CartesianChart.js +1 -1
  57. package/src/components/Chart.js +99 -99
  58. package/src/components/ChartContainer.tsx +71 -71
  59. package/src/components/ConicalGradient.js +258 -258
  60. package/src/components/Control.jsx +51 -51
  61. package/src/components/ExtentData.js +17 -17
  62. package/src/components/Indicator.js +61 -61
  63. package/src/components/Label.js +275 -275
  64. package/src/components/Legend.js +165 -165
  65. package/src/components/Lighter.jsx +173 -173
  66. package/src/components/Line.js +150 -150
  67. package/src/components/LinearGradient.js +29 -29
  68. package/src/components/Marquee.tsx +1 -1
  69. package/src/components/PieChart.js +3 -7
  70. package/src/components/StereoBar.tsx +307 -307
  71. package/src/components/index.js +57 -57
  72. package/src/context/index.js +2 -2
  73. package/src/css/index.module.css +42 -42
  74. package/src/css/piechart.module.css +26 -26
  75. package/src/element/ConicGradient.jsx +55 -55
  76. package/src/element/Line.tsx +33 -33
  77. package/src/element/index.ts +3 -3
  78. package/src/formatter/index.js +1 -1
  79. package/src/formatter/legend.js +92 -92
  80. package/src/hooks/index.js +20 -20
  81. package/src/hooks/useAnimateData.ts +67 -67
  82. package/src/hooks/useCarouselAxisX.js +1 -1
  83. package/src/hooks/useFilterData.js +72 -72
  84. package/src/hooks/useStackData.js +101 -101
  85. package/src/hooks/useTooltip.ts +100 -100
  86. package/src/index.js +6 -6
  87. package/src/types/index.d.ts +67 -67
  88. package/src/utils/index.js +757 -757
  89. package/tsconfig.json +23 -23
@@ -1,258 +1,258 @@
1
- /**
2
- * 饼图装饰内圈
3
- */
4
- import React, { useEffect, useState } from 'react';
5
- import { arc } from 'd3v7';
6
- import { converColor } from '@easyv/utils/lib/common/utils';
7
- import css from '../css/index.module.css';
8
-
9
- export default ({
10
- width,
11
- height,
12
- centerX,
13
- centerY,
14
- radius,
15
- config: { show, innerRadius, outerRadius, opacity, speed, direction },
16
- arcs,
17
- }) => {
18
- if (!show) return null;
19
- const [canvas, setCanvas] = useState(null);
20
-
21
- useEffect(() => {
22
- if (arcs && arcs.length > 0 && canvas && canvas.getContext('2d')) {
23
- const _radius = radius * devicePixelRatio;
24
- const context = canvas.getContext('2d');
25
- context.clearRect(
26
- 0,
27
- 0,
28
- width * devicePixelRatio,
29
- height * devicePixelRatio
30
- );
31
-
32
- context.save();
33
- context.translate(centerX * devicePixelRatio, centerY * devicePixelRatio);
34
- context.beginPath();
35
-
36
- const _arc = arc()
37
- .innerRadius(innerRadius * _radius)
38
- .outerRadius(outerRadius * _radius)
39
- // .padAngle(axis.pole.padAngle)
40
- // .cornerRadius(axis.pole.cornerRadius)
41
- .context(context);
42
-
43
- arcs.forEach((element) => {
44
- const startAngle = element.arc.startAngle()();
45
- const endAngle = element.arc.endAngle()();
46
- _arc.startAngle(startAngle).endAngle(endAngle)();
47
- context.fillStyle = 'rgba(255, 255, 255, 0)';
48
- context.fill();
49
- });
50
-
51
- context.clip();
52
- context.rotate(-Math.PI / 2);
53
-
54
- const conic = new ConicalGradient();
55
- arcs.reduce(
56
- (
57
- reduced,
58
- {
59
- percent,
60
- series: {
61
- color: {
62
- type,
63
- pure,
64
- linear: { stops },
65
- },
66
- },
67
- }
68
- ) => {
69
- const result = reduced + percent / 100;
70
- const color = type == 'pure' ? pure : stops[0].color;
71
- if (!!color) {
72
- var { r, g, b, a } = converColor(color, 1);
73
- conic.addColorStop(reduced, { r, g, b, a: 0 });
74
- conic.addColorStop(result, { r, g, b, a });
75
- }
76
- return result;
77
- },
78
- 0
79
- );
80
-
81
- conic.fill(context, 0, 0, _radius, 0, 2 * Math.PI, false);
82
- context.restore();
83
- }
84
- }, [canvas, radius, arcs, innerRadius, outerRadius]);
85
-
86
- return (
87
- <canvas
88
- className={
89
- direction == 'clockwise'
90
- ? css.rotateClockwise
91
- : css.rotateCounterClockwise
92
- }
93
- ref={setCanvas}
94
- width={width * devicePixelRatio}
95
- height={height * devicePixelRatio}
96
- style={{
97
- opacity: opacity / 100,
98
- width,
99
- height,
100
- pointerEvents: 'none',
101
- position: 'absolute',
102
- animationTimingFunction: 'linear',
103
- animationDuration: speed + 's',
104
- animationIterationCount: 'infinite',
105
- transformOrigin: centerX + 'px ' + centerY + 'px',
106
- }}
107
- />
108
- );
109
- };
110
-
111
- /**
112
- * ConicalGradient
113
- */
114
- function ConicalGradient() {
115
- this._offsets = [];
116
- this._colors = [];
117
- }
118
-
119
- ConicalGradient.prototype = {
120
- /**
121
- * addColorStop
122
- *
123
- * @param {Number} offset
124
- * @param {Array} color RGBA值
125
- */
126
- addColorStop: function (offset, color) {
127
- this._offsets.push(offset);
128
- this._colors.push(color);
129
- return this;
130
- },
131
-
132
- /**
133
- * _offsetsReverse (array.forEach callback)
134
- */
135
- _offsetsReverse: function (offset, index, array) {
136
- array[index] = 1 - offset;
137
- },
138
- /**
139
- * fill
140
- *
141
- * @param {Number} context
142
- * @param {Number} x
143
- * @param {Number} y
144
- * @param {Number} radius
145
- * @param {Number} startAngle
146
- * @param {Number} endAngle
147
- * @param {Boolean} anticlockwise
148
- */
149
- fill: function (context, x, y, radius, startAngle, endAngle, anticlockwise) {
150
- var offsets = this._offsets;
151
- var colors = this._colors;
152
-
153
- var PI = Math.PI;
154
- var TWO_PI = PI * 2;
155
-
156
- if (startAngle < 0) startAngle = (startAngle % TWO_PI) + TWO_PI;
157
- startAngle %= TWO_PI;
158
- if (endAngle < 0) endAngle = (endAngle % TWO_PI) + TWO_PI;
159
- endAngle %= TWO_PI;
160
-
161
- if (anticlockwise) {
162
- // 逆时针
163
- var swap = startAngle;
164
- startAngle = endAngle;
165
- endAngle = swap;
166
-
167
- colors.reverse();
168
- offsets.reverse();
169
- offsets.forEach(this._offsetsReverse);
170
- }
171
-
172
- if (startAngle > endAngle || Math.abs(endAngle - startAngle) < 0.0001) {
173
- endAngle += TWO_PI;
174
- }
175
-
176
- var colorsLength = colors.length;
177
-
178
- var currentColorIndex = 0;
179
- var currentColor = colors[currentColorIndex];
180
- var nextColor = colors[currentColorIndex];
181
-
182
- var prevOffset = 0;
183
- var currentOffset = offsets[currentColorIndex];
184
- var offsetDist = currentOffset - prevOffset;
185
-
186
- var totalAngleDeg = ((endAngle - startAngle) * 180) / PI;
187
- var stepAngleRad = (endAngle - startAngle) / totalAngleDeg;
188
-
189
- var arcStartAngle = startAngle;
190
- var arcEndAngle;
191
-
192
- var r1 = currentColor.r,
193
- g1 = currentColor.g,
194
- b1 = currentColor.b,
195
- a1 = currentColor.a,
196
- r2 = nextColor.r,
197
- g2 = nextColor.g,
198
- b2 = nextColor.b,
199
- a2 = nextColor.a;
200
- if (!a1 && a1 !== 0) a1 = 1;
201
- if (!a2 && a2 !== 0) a2 = 1;
202
- var rd = r2 - r1,
203
- gd = g2 - g1,
204
- bd = b2 - b1,
205
- ad = a2 - a1;
206
- var t, r, g, b, a;
207
-
208
- context.save();
209
- for (var i = 0, n = 1 / totalAngleDeg; i < 1; i += n) {
210
- if (i >= currentOffset) {
211
- currentColorIndex++;
212
-
213
- currentColor = nextColor;
214
- r1 = currentColor.r;
215
- g1 = currentColor.g;
216
- b1 = currentColor.b;
217
- a1 = currentColor.a;
218
- if (!a1 && a1 !== 0) a1 = 1;
219
-
220
- nextColor = colors[currentColorIndex] || {r:0,g:0,b:0,a:1};
221
- r2 = nextColor.r;
222
- g2 = nextColor.g;
223
- b2 = nextColor.b;
224
- a2 = nextColor.a;
225
- if (!a2 && a2 !== 0) a2 = 1;
226
-
227
- rd = r2 - r1;
228
- gd = g2 - g1;
229
- bd = b2 - b1;
230
- ad = a2 - a1;
231
-
232
- prevOffset = currentOffset;
233
- currentOffset = offsets[currentColorIndex];
234
- offsetDist = currentOffset - prevOffset;
235
- }
236
-
237
- t = (i - prevOffset) / offsetDist;
238
- r = (rd * t + r1) & 255;
239
- g = (gd * t + g1) & 255;
240
- b = (bd * t + b1) & 255;
241
- a = ad * t + a1;
242
-
243
- arcEndAngle = arcStartAngle + stepAngleRad;
244
-
245
- context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
246
- context.beginPath();
247
- context.moveTo(x, y);
248
- context.arc(x, y, radius, arcStartAngle - 0.02, arcEndAngle, false);
249
- context.closePath();
250
- context.fill();
251
-
252
- arcStartAngle += stepAngleRad;
253
- }
254
- context.restore();
255
-
256
- return this;
257
- },
258
- };
1
+ /**
2
+ * 饼图装饰内圈
3
+ */
4
+ import React, { useEffect, useState } from 'react';
5
+ import { arc } from 'd3v7';
6
+ import { converColor } from '@easyv/utils/lib/common/utils';
7
+ import css from '../css/index.module.css';
8
+
9
+ export default ({
10
+ width,
11
+ height,
12
+ centerX,
13
+ centerY,
14
+ radius,
15
+ config: { show, innerRadius, outerRadius, opacity, speed, direction },
16
+ arcs,
17
+ }) => {
18
+ if (!show) return null;
19
+ const [canvas, setCanvas] = useState(null);
20
+
21
+ useEffect(() => {
22
+ if (arcs && arcs.length > 0 && canvas && canvas.getContext('2d')) {
23
+ const _radius = radius * devicePixelRatio;
24
+ const context = canvas.getContext('2d');
25
+ context.clearRect(
26
+ 0,
27
+ 0,
28
+ width * devicePixelRatio,
29
+ height * devicePixelRatio
30
+ );
31
+
32
+ context.save();
33
+ context.translate(centerX * devicePixelRatio, centerY * devicePixelRatio);
34
+ context.beginPath();
35
+
36
+ const _arc = arc()
37
+ .innerRadius(innerRadius * _radius)
38
+ .outerRadius(outerRadius * _radius)
39
+ // .padAngle(axis.pole.padAngle)
40
+ // .cornerRadius(axis.pole.cornerRadius)
41
+ .context(context);
42
+
43
+ arcs.forEach((element) => {
44
+ const startAngle = element.arc.startAngle()();
45
+ const endAngle = element.arc.endAngle()();
46
+ _arc.startAngle(startAngle).endAngle(endAngle)();
47
+ context.fillStyle = 'rgba(255, 255, 255, 0)';
48
+ context.fill();
49
+ });
50
+
51
+ context.clip();
52
+ context.rotate(-Math.PI / 2);
53
+
54
+ const conic = new ConicalGradient();
55
+ arcs.reduce(
56
+ (
57
+ reduced,
58
+ {
59
+ percent,
60
+ series: {
61
+ color: {
62
+ type,
63
+ pure,
64
+ linear: { stops },
65
+ },
66
+ },
67
+ }
68
+ ) => {
69
+ const result = reduced + percent / 100;
70
+ const color = type == 'pure' ? pure : stops[0].color;
71
+ if (!!color) {
72
+ var { r, g, b, a } = converColor(color, 1);
73
+ conic.addColorStop(reduced, { r, g, b, a: 0 });
74
+ conic.addColorStop(result, { r, g, b, a });
75
+ }
76
+ return result;
77
+ },
78
+ 0
79
+ );
80
+
81
+ conic.fill(context, 0, 0, _radius, 0, 2 * Math.PI, false);
82
+ context.restore();
83
+ }
84
+ }, [canvas, radius, arcs, innerRadius, outerRadius]);
85
+
86
+ return (
87
+ <canvas
88
+ className={
89
+ direction == 'clockwise'
90
+ ? css.rotateClockwise
91
+ : css.rotateCounterClockwise
92
+ }
93
+ ref={setCanvas}
94
+ width={width * devicePixelRatio}
95
+ height={height * devicePixelRatio}
96
+ style={{
97
+ opacity: opacity / 100,
98
+ width,
99
+ height,
100
+ pointerEvents: 'none',
101
+ position: 'absolute',
102
+ animationTimingFunction: 'linear',
103
+ animationDuration: speed + 's',
104
+ animationIterationCount: 'infinite',
105
+ transformOrigin: centerX + 'px ' + centerY + 'px',
106
+ }}
107
+ />
108
+ );
109
+ };
110
+
111
+ /**
112
+ * ConicalGradient
113
+ */
114
+ function ConicalGradient() {
115
+ this._offsets = [];
116
+ this._colors = [];
117
+ }
118
+
119
+ ConicalGradient.prototype = {
120
+ /**
121
+ * addColorStop
122
+ *
123
+ * @param {Number} offset
124
+ * @param {Array} color RGBA值
125
+ */
126
+ addColorStop: function (offset, color) {
127
+ this._offsets.push(offset);
128
+ this._colors.push(color);
129
+ return this;
130
+ },
131
+
132
+ /**
133
+ * _offsetsReverse (array.forEach callback)
134
+ */
135
+ _offsetsReverse: function (offset, index, array) {
136
+ array[index] = 1 - offset;
137
+ },
138
+ /**
139
+ * fill
140
+ *
141
+ * @param {Number} context
142
+ * @param {Number} x
143
+ * @param {Number} y
144
+ * @param {Number} radius
145
+ * @param {Number} startAngle
146
+ * @param {Number} endAngle
147
+ * @param {Boolean} anticlockwise
148
+ */
149
+ fill: function (context, x, y, radius, startAngle, endAngle, anticlockwise) {
150
+ var offsets = this._offsets;
151
+ var colors = this._colors;
152
+
153
+ var PI = Math.PI;
154
+ var TWO_PI = PI * 2;
155
+
156
+ if (startAngle < 0) startAngle = (startAngle % TWO_PI) + TWO_PI;
157
+ startAngle %= TWO_PI;
158
+ if (endAngle < 0) endAngle = (endAngle % TWO_PI) + TWO_PI;
159
+ endAngle %= TWO_PI;
160
+
161
+ if (anticlockwise) {
162
+ // 逆时针
163
+ var swap = startAngle;
164
+ startAngle = endAngle;
165
+ endAngle = swap;
166
+
167
+ colors.reverse();
168
+ offsets.reverse();
169
+ offsets.forEach(this._offsetsReverse);
170
+ }
171
+
172
+ if (startAngle > endAngle || Math.abs(endAngle - startAngle) < 0.0001) {
173
+ endAngle += TWO_PI;
174
+ }
175
+
176
+ var colorsLength = colors.length;
177
+
178
+ var currentColorIndex = 0;
179
+ var currentColor = colors[currentColorIndex];
180
+ var nextColor = colors[currentColorIndex];
181
+
182
+ var prevOffset = 0;
183
+ var currentOffset = offsets[currentColorIndex];
184
+ var offsetDist = currentOffset - prevOffset;
185
+
186
+ var totalAngleDeg = ((endAngle - startAngle) * 180) / PI;
187
+ var stepAngleRad = (endAngle - startAngle) / totalAngleDeg;
188
+
189
+ var arcStartAngle = startAngle;
190
+ var arcEndAngle;
191
+
192
+ var r1 = currentColor.r,
193
+ g1 = currentColor.g,
194
+ b1 = currentColor.b,
195
+ a1 = currentColor.a,
196
+ r2 = nextColor.r,
197
+ g2 = nextColor.g,
198
+ b2 = nextColor.b,
199
+ a2 = nextColor.a;
200
+ if (!a1 && a1 !== 0) a1 = 1;
201
+ if (!a2 && a2 !== 0) a2 = 1;
202
+ var rd = r2 - r1,
203
+ gd = g2 - g1,
204
+ bd = b2 - b1,
205
+ ad = a2 - a1;
206
+ var t, r, g, b, a;
207
+
208
+ context.save();
209
+ for (var i = 0, n = 1 / totalAngleDeg; i < 1; i += n) {
210
+ if (i >= currentOffset) {
211
+ currentColorIndex++;
212
+
213
+ currentColor = nextColor;
214
+ r1 = currentColor.r;
215
+ g1 = currentColor.g;
216
+ b1 = currentColor.b;
217
+ a1 = currentColor.a;
218
+ if (!a1 && a1 !== 0) a1 = 1;
219
+
220
+ nextColor = colors[currentColorIndex] || {r:0,g:0,b:0,a:1};
221
+ r2 = nextColor.r;
222
+ g2 = nextColor.g;
223
+ b2 = nextColor.b;
224
+ a2 = nextColor.a;
225
+ if (!a2 && a2 !== 0) a2 = 1;
226
+
227
+ rd = r2 - r1;
228
+ gd = g2 - g1;
229
+ bd = b2 - b1;
230
+ ad = a2 - a1;
231
+
232
+ prevOffset = currentOffset;
233
+ currentOffset = offsets[currentColorIndex];
234
+ offsetDist = currentOffset - prevOffset;
235
+ }
236
+
237
+ t = (i - prevOffset) / offsetDist;
238
+ r = (rd * t + r1) & 255;
239
+ g = (gd * t + g1) & 255;
240
+ b = (bd * t + b1) & 255;
241
+ a = ad * t + a1;
242
+
243
+ arcEndAngle = arcStartAngle + stepAngleRad;
244
+
245
+ context.fillStyle = 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';
246
+ context.beginPath();
247
+ context.moveTo(x, y);
248
+ context.arc(x, y, radius, arcStartAngle - 0.02, arcEndAngle, false);
249
+ context.closePath();
250
+ context.fill();
251
+
252
+ arcStartAngle += stepAngleRad;
253
+ }
254
+ context.restore();
255
+
256
+ return this;
257
+ },
258
+ };
@@ -1,51 +1,51 @@
1
- import React, { forwardRef, memo, useRef } from "react";
2
- import { scaleLinear } from "d3-scale";
3
-
4
- export default memo(forwardRef((props, ref) => {
5
- const { props: { control, axes, series, xLineRange, yLineRange, marginTop, axisX, bandLength } } = props;
6
- const _axisX = { ...axisX, scaler: axisX.controlDragScaler }
7
- return (
8
- <>
9
- <foreignObject
10
- style={{
11
- width: xLineRange,
12
- height: control.height,
13
- backgroundColor: control.color,
14
- // padding: ` 0 ${control.margin.left}px 0 ${control.margin.right}px`,
15
- transform: `translateY(${yLineRange + marginTop}px)`,
16
- }}
17
- >
18
- <svg width="100%" height="100%">
19
- {series.map(({ Component, yOrZ, ...config }, index) => {
20
- const yAxis = axes.get(yOrZ);
21
- const cloneYAxis = JSON.parse(JSON.stringify(yAxis));
22
- //todo range
23
- cloneYAxis.scaler = scaleLinear()
24
- .domain(yAxis.domain)
25
- .range([control.height, 0]);
26
- return (
27
- yAxis &&
28
- Component && (
29
- <Component
30
- key={index}
31
- {...config}
32
- bandLength={bandLength}
33
- xAxis={_axisX}
34
- yAxis={cloneYAxis}
35
- />
36
- )
37
- );
38
- })}
39
- {/* 控制条 */}
40
- <rect
41
- ref={ref}
42
- height={control.height}
43
- width={(xLineRange * control.drag.width) / 100}
44
- fill={control.drag.color}
45
- ></rect>
46
- </svg>
47
- </foreignObject>
48
- </>
49
- );
50
- }))
51
-
1
+ import React, { forwardRef, memo, useRef } from "react";
2
+ import { scaleLinear } from "d3-scale";
3
+
4
+ export default memo(forwardRef((props, ref) => {
5
+ const { props: { control, axes, series, xLineRange, yLineRange, marginTop, axisX, bandLength } } = props;
6
+ const _axisX = { ...axisX, scaler: axisX.controlDragScaler }
7
+ return (
8
+ <>
9
+ <foreignObject
10
+ style={{
11
+ width: xLineRange,
12
+ height: control.height,
13
+ backgroundColor: control.color,
14
+ // padding: ` 0 ${control.margin.left}px 0 ${control.margin.right}px`,
15
+ transform: `translateY(${yLineRange + marginTop}px)`,
16
+ }}
17
+ >
18
+ <svg width="100%" height="100%">
19
+ {series.map(({ Component, yOrZ, ...config }, index) => {
20
+ const yAxis = axes.get(yOrZ);
21
+ const cloneYAxis = JSON.parse(JSON.stringify(yAxis));
22
+ //todo range
23
+ cloneYAxis.scaler = scaleLinear()
24
+ .domain(yAxis.domain)
25
+ .range([control.height, 0]);
26
+ return (
27
+ yAxis &&
28
+ Component && (
29
+ <Component
30
+ key={index}
31
+ {...config}
32
+ bandLength={bandLength}
33
+ xAxis={_axisX}
34
+ yAxis={cloneYAxis}
35
+ />
36
+ )
37
+ );
38
+ })}
39
+ {/* 控制条 */}
40
+ <rect
41
+ ref={ref}
42
+ height={control.height}
43
+ width={(xLineRange * control.drag.width) / 100}
44
+ fill={control.drag.color}
45
+ ></rect>
46
+ </svg>
47
+ </foreignObject>
48
+ </>
49
+ );
50
+ }))
51
+
@@ -1,17 +1,17 @@
1
- /**
2
- * 计算X/Y/Z轴的domain,具体的逻辑在useExtentData(HOC)
3
- */
4
- import { memo } from 'react';
5
- import { useExtentData } from '../hooks';
6
- export default (Component) =>
7
- memo(({ config: { axes, series, ...config }, data, ...props }) => (
8
- <Component
9
- {...props}
10
- config={{
11
- ...config,
12
- axes: useExtentData({ series, axes, data }),
13
- series,
14
- }}
15
- data={data}
16
- />
17
- ));
1
+ /**
2
+ * 计算X/Y/Z轴的domain,具体的逻辑在useExtentData(HOC)
3
+ */
4
+ import { memo } from 'react';
5
+ import { useExtentData } from '../hooks';
6
+ export default (Component) =>
7
+ memo(({ config: { axes, series, ...config }, data, ...props }) => (
8
+ <Component
9
+ {...props}
10
+ config={{
11
+ ...config,
12
+ axes: useExtentData({ series, axes, data }),
13
+ series,
14
+ }}
15
+ data={data}
16
+ />
17
+ ));