@easyv/charts 1.4.21 → 1.4.24
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/.babelrc +8 -8
- package/.husky/commit-msg +3 -3
- package/CHANGELOG.md +18 -18
- package/commitlint.config.js +1 -1
- package/lib/components/AnimateData.js +8 -16
- package/lib/components/Axis.js +106 -138
- package/lib/components/Background.js +18 -26
- package/lib/components/Band.js +105 -91
- package/lib/components/BaseLine.js +33 -46
- package/lib/components/Brush.js +29 -46
- package/lib/components/Carousel.js +13 -40
- package/lib/components/CartesianChart.js +292 -113
- package/lib/components/Chart.js +23 -36
- package/lib/components/ChartContainer.js +21 -29
- package/lib/components/ConicalGradient.js +56 -89
- package/lib/components/Control.js +65 -0
- package/lib/components/ExtentData.js +9 -17
- package/lib/components/FilterData.js +16 -27
- package/lib/components/Indicator.js +66 -12
- package/lib/components/Label.js +128 -118
- package/lib/components/Legend.js +41 -66
- package/lib/components/Lighter.js +21 -50
- package/lib/components/Line.js +39 -59
- package/lib/components/LinearGradient.js +16 -22
- package/lib/components/Mapping.js +9 -34
- package/lib/components/Marquee.js +14 -30
- package/lib/components/PieChart.js +312 -406
- package/lib/components/StackData.js +8 -18
- package/lib/components/StereoBar.js +65 -105
- package/lib/components/TextOverflow.js +8 -21
- package/lib/components/Tooltip.js +41 -55
- package/lib/components/index.js +7 -27
- package/lib/context/index.js +0 -2
- package/lib/css/index.module.css +42 -42
- package/lib/css/piechart.module.css +26 -26
- package/lib/element/ConicGradient.js +29 -35
- package/lib/element/Line.js +9 -13
- package/lib/element/index.js +0 -2
- package/lib/formatter/index.js +0 -2
- package/lib/formatter/legend.js +30 -41
- package/lib/hooks/index.js +0 -9
- package/lib/hooks/useAiData.js +12 -20
- package/lib/hooks/useAnimateData.js +8 -21
- package/lib/hooks/useAxes.js +69 -115
- package/lib/hooks/useCarouselAxisX.js +47 -68
- package/lib/hooks/useExtentData.js +14 -46
- package/lib/hooks/useFilterData.js +13 -34
- package/lib/hooks/useStackData.js +12 -35
- package/lib/hooks/useTooltip.js +37 -54
- package/lib/index.js +0 -15
- package/lib/utils/index.js +95 -247
- package/package.json +55 -55
- package/src/components/Axis.tsx +223 -183
- package/src/components/Background.tsx +61 -61
- package/src/components/Band.tsx +274 -239
- package/src/components/Brush.js +159 -159
- package/src/components/CartesianChart.js +320 -44
- package/src/components/Chart.js +99 -99
- package/src/components/ChartContainer.tsx +71 -64
- package/src/components/ConicalGradient.js +258 -258
- package/src/components/Control.jsx +51 -0
- package/src/components/ExtentData.js +17 -17
- package/src/components/Indicator.js +61 -13
- package/src/components/Label.js +275 -242
- package/src/components/Legend.js +165 -165
- package/src/components/Lighter.jsx +173 -173
- package/src/components/Line.js +150 -150
- package/src/components/LinearGradient.js +29 -29
- package/src/components/PieChart.js +8 -4
- package/src/components/StereoBar.tsx +307 -307
- package/src/components/index.js +57 -55
- package/src/context/index.js +2 -2
- package/src/css/index.module.css +42 -42
- package/src/css/piechart.module.css +26 -26
- package/src/element/ConicGradient.jsx +55 -55
- package/src/element/Line.tsx +33 -33
- package/src/element/index.ts +3 -3
- package/src/formatter/index.js +1 -1
- package/src/formatter/legend.js +92 -92
- package/src/hooks/index.js +20 -20
- package/src/hooks/useAnimateData.ts +67 -67
- package/src/hooks/useAxes.js +9 -2
- package/src/hooks/useCarouselAxisX.js +35 -18
- package/src/hooks/useFilterData.js +72 -72
- package/src/hooks/useStackData.js +101 -101
- package/src/hooks/useTooltip.ts +100 -100
- package/src/index.js +6 -6
- package/src/types/index.d.ts +67 -67
- package/src/utils/index.js +757 -757
- package/tsconfig.json +23 -23
package/package.json
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@easyv/charts",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "",
|
|
5
|
-
"main": "lib/index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"make": "babel src -d lib --extensions .ts,.tsx,.js,.jsx && cp -r src/css lib",
|
|
8
|
-
"prepare": "husky install"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [],
|
|
11
|
-
"author": "",
|
|
12
|
-
"license": "ISC",
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
"@babel/cli": "^7.17.10",
|
|
15
|
-
"@babel/core": "^7.17.10",
|
|
16
|
-
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
17
|
-
"@babel/plugin-proposal-export-default-from": "^7.16.7",
|
|
18
|
-
"@babel/plugin-transform-runtime": "^7.17.10",
|
|
19
|
-
"@babel/preset-env": "^7.17.10",
|
|
20
|
-
"@babel/preset-react": "^7.16.7",
|
|
21
|
-
"@babel/preset-typescript": "^7.16.7",
|
|
22
|
-
"@commitlint/cli": "^17.6.7",
|
|
23
|
-
"@commitlint/config-conventional": "^16.2.4",
|
|
24
|
-
"@types/d3": "^7.0.0",
|
|
25
|
-
"@types/react": "^18.0.12",
|
|
26
|
-
"@types/react-dom": "^18.0.5",
|
|
27
|
-
"babel-plugin-transform-import-styles": "^0.0.11",
|
|
28
|
-
"babel-preset-env": "^1.7.0",
|
|
29
|
-
"cz-conventional-changelog": "^3.3.0",
|
|
30
|
-
"husky": "^7.0.4",
|
|
31
|
-
"load-styles": "^2.0.0",
|
|
32
|
-
"standard-version": "^9.3.2"
|
|
33
|
-
},
|
|
34
|
-
"dependencies": {
|
|
35
|
-
"@easyv/utils": "^0.0.45",
|
|
36
|
-
"d3v7": "npm:d3@^7.0.0",
|
|
37
|
-
"gitignore": "^0.7.0",
|
|
38
|
-
"mrm": "^4.0.0",
|
|
39
|
-
"popmotion": "^9.3.6",
|
|
40
|
-
"react": "^17.0.2",
|
|
41
|
-
"svg-path-properties": "^1.0.11",
|
|
42
|
-
"svg-points": "^6.0.1",
|
|
43
|
-
"yarn": "^1.22.19"
|
|
44
|
-
},
|
|
45
|
-
"config": {
|
|
46
|
-
"commitizen": {
|
|
47
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
"standard-version": {
|
|
51
|
-
"skip": {
|
|
52
|
-
"commit": true
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@easyv/charts",
|
|
3
|
+
"version": "1.4.24",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"make": "babel src -d lib --extensions .ts,.tsx,.js,.jsx && cp -r src/css lib",
|
|
8
|
+
"prepare": "husky install"
|
|
9
|
+
},
|
|
10
|
+
"keywords": [],
|
|
11
|
+
"author": "",
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@babel/cli": "^7.17.10",
|
|
15
|
+
"@babel/core": "^7.17.10",
|
|
16
|
+
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
|
17
|
+
"@babel/plugin-proposal-export-default-from": "^7.16.7",
|
|
18
|
+
"@babel/plugin-transform-runtime": "^7.17.10",
|
|
19
|
+
"@babel/preset-env": "^7.17.10",
|
|
20
|
+
"@babel/preset-react": "^7.16.7",
|
|
21
|
+
"@babel/preset-typescript": "^7.16.7",
|
|
22
|
+
"@commitlint/cli": "^17.6.7",
|
|
23
|
+
"@commitlint/config-conventional": "^16.2.4",
|
|
24
|
+
"@types/d3": "^7.0.0",
|
|
25
|
+
"@types/react": "^18.0.12",
|
|
26
|
+
"@types/react-dom": "^18.0.5",
|
|
27
|
+
"babel-plugin-transform-import-styles": "^0.0.11",
|
|
28
|
+
"babel-preset-env": "^1.7.0",
|
|
29
|
+
"cz-conventional-changelog": "^3.3.0",
|
|
30
|
+
"husky": "^7.0.4",
|
|
31
|
+
"load-styles": "^2.0.0",
|
|
32
|
+
"standard-version": "^9.3.2"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@easyv/utils": "^0.0.45",
|
|
36
|
+
"d3v7": "npm:d3@^7.0.0",
|
|
37
|
+
"gitignore": "^0.7.0",
|
|
38
|
+
"mrm": "^4.0.0",
|
|
39
|
+
"popmotion": "^9.3.6",
|
|
40
|
+
"react": "^17.0.2",
|
|
41
|
+
"svg-path-properties": "^1.0.11",
|
|
42
|
+
"svg-points": "^6.0.1",
|
|
43
|
+
"yarn": "^1.22.19"
|
|
44
|
+
},
|
|
45
|
+
"config": {
|
|
46
|
+
"commitizen": {
|
|
47
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"standard-version": {
|
|
51
|
+
"skip": {
|
|
52
|
+
"commit": true
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
package/src/components/Axis.tsx
CHANGED
|
@@ -8,11 +8,13 @@ import React, {
|
|
|
8
8
|
useContext,
|
|
9
9
|
CSSProperties,
|
|
10
10
|
MouseEventHandler,
|
|
11
|
+
forwardRef,
|
|
11
12
|
} from "react";
|
|
12
13
|
import { getTickCoord, getGridCoord, getFontStyle } from "../utils";
|
|
13
14
|
import { chartContext } from "../context";
|
|
14
15
|
import { Line } from "../element";
|
|
15
16
|
import TextOverflow from "./TextOverflow";
|
|
17
|
+
import { path } from "d3";
|
|
16
18
|
const defaultEvent = () => {};
|
|
17
19
|
const defaultAppearance = {
|
|
18
20
|
angle: 0,
|
|
@@ -250,201 +252,239 @@ const Label: (
|
|
|
250
252
|
};
|
|
251
253
|
|
|
252
254
|
export default memo(
|
|
253
|
-
(
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
255
|
+
forwardRef(
|
|
256
|
+
(
|
|
257
|
+
{
|
|
258
|
+
orientation,
|
|
259
|
+
scaler,
|
|
260
|
+
tickSize = defaultTickSize,
|
|
261
|
+
ticks,
|
|
262
|
+
formatter,
|
|
263
|
+
rotate,
|
|
264
|
+
triggerClick,
|
|
265
|
+
config: { on, label, axisLine, tickLine, gridLine, unit },
|
|
266
|
+
config,
|
|
267
|
+
positions,
|
|
268
|
+
xLineRange,
|
|
269
|
+
range,
|
|
270
|
+
axisType,
|
|
271
|
+
//断轴图相关
|
|
272
|
+
isClipAxis = false,
|
|
273
|
+
yLineRange,
|
|
274
|
+
clipAxisRange,
|
|
275
|
+
//控制图相关
|
|
276
|
+
isControlChart,
|
|
277
|
+
controlConfig,
|
|
278
|
+
controlEnd,
|
|
279
|
+
rawTicks,
|
|
280
|
+
}: any,
|
|
281
|
+
ref
|
|
282
|
+
) => {
|
|
283
|
+
if (!(on && ticks.length > 0)) return null;
|
|
284
|
+
const { width, height } = useContext(chartContext);
|
|
285
|
+
const x = orientation == "right" ? width : 0;
|
|
286
|
+
const y = orientation == "bottom" ? height : 0;
|
|
274
287
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
288
|
+
function drawAxisTickLine() {
|
|
289
|
+
const draw = (ticks: any, scaler: any) => {
|
|
290
|
+
return ticks.map((tick: string, index: number) => {
|
|
291
|
+
const coordinate = scaler(tick);
|
|
292
|
+
if (isNaN(coordinate)) return null;
|
|
293
|
+
const _tickSize = tickLine.tickSize || tickSize;
|
|
294
|
+
const gridCoord = getGridCoord({
|
|
295
|
+
orientation,
|
|
296
|
+
coordinate,
|
|
297
|
+
end:
|
|
298
|
+
orientation == "left" || orientation == "right"
|
|
299
|
+
? width
|
|
300
|
+
: height,
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
const x1 = gridCoord.x1;
|
|
304
|
+
const y1 = gridCoord.y1;
|
|
305
|
+
return (
|
|
306
|
+
!(
|
|
307
|
+
(orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) ||
|
|
308
|
+
y1 < 0 ||
|
|
309
|
+
y1 > yLineRange
|
|
310
|
+
) && (
|
|
311
|
+
<Line
|
|
312
|
+
className="__easyv-tickLine"
|
|
313
|
+
key={index}
|
|
314
|
+
config={tickLine}
|
|
315
|
+
{...getTickCoord({
|
|
316
|
+
orientation,
|
|
317
|
+
coordinate,
|
|
318
|
+
tickSize: _tickSize,
|
|
319
|
+
})}
|
|
320
|
+
/>
|
|
321
|
+
)
|
|
322
|
+
);
|
|
286
323
|
});
|
|
324
|
+
};
|
|
287
325
|
|
|
288
|
-
|
|
289
|
-
const y1 = gridCoord.y1;
|
|
326
|
+
if (isClipAxis) {
|
|
290
327
|
return (
|
|
291
|
-
|
|
292
|
-
(
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
<Line
|
|
297
|
-
className="__easyv-tickLine"
|
|
298
|
-
key={index}
|
|
299
|
-
config={tickLine}
|
|
300
|
-
{...getTickCoord({
|
|
301
|
-
orientation,
|
|
302
|
-
coordinate,
|
|
303
|
-
tickSize: _tickSize,
|
|
304
|
-
})}
|
|
305
|
-
/>
|
|
306
|
-
)
|
|
328
|
+
<>
|
|
329
|
+
{ticks.map((ticks: any, index: number) => {
|
|
330
|
+
return draw(ticks, scaler[index]);
|
|
331
|
+
})}
|
|
332
|
+
</>
|
|
307
333
|
);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
if (isClipAxis) {
|
|
312
|
-
return (
|
|
313
|
-
<>
|
|
314
|
-
{ticks.map((ticks: any, index: number) => {
|
|
315
|
-
return draw(ticks, scaler[index]);
|
|
316
|
-
})}
|
|
317
|
-
</>
|
|
318
|
-
);
|
|
319
|
-
} else {
|
|
320
|
-
return <>{draw(ticks, scaler)}</>;
|
|
334
|
+
} else {
|
|
335
|
+
return <>{draw(ticks, scaler)}</>;
|
|
336
|
+
}
|
|
321
337
|
}
|
|
322
|
-
}
|
|
323
338
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
339
|
+
function drawLabel() {
|
|
340
|
+
const draw = (ticks: any, scaler: any) => {
|
|
341
|
+
return ticks.map((tick: string, index: number) => {
|
|
342
|
+
const coordinate = scaler(tick);
|
|
343
|
+
if (isNaN(coordinate)) return null;
|
|
344
|
+
const _tickSize = tickLine.tickSize || tickSize;
|
|
345
|
+
const gridCoord = getGridCoord({
|
|
346
|
+
orientation,
|
|
347
|
+
coordinate,
|
|
348
|
+
end:
|
|
349
|
+
orientation == "left" || orientation == "right"
|
|
350
|
+
? width
|
|
351
|
+
: height,
|
|
352
|
+
});
|
|
353
|
+
const x1 = gridCoord.x1;
|
|
354
|
+
const y1 = gridCoord.y1;
|
|
355
|
+
return (
|
|
356
|
+
(!(
|
|
357
|
+
(orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) ||
|
|
358
|
+
y1 < 0 ||
|
|
359
|
+
y1 > yLineRange
|
|
360
|
+
) ||
|
|
361
|
+
isControlChart) && (
|
|
362
|
+
<g key={index}>
|
|
363
|
+
{label && (
|
|
364
|
+
<Label
|
|
365
|
+
className="__easyv-label"
|
|
366
|
+
orientation={orientation}
|
|
367
|
+
coordinate={coordinate}
|
|
368
|
+
config={label}
|
|
369
|
+
label={tick}
|
|
370
|
+
tickSize={_tickSize}
|
|
371
|
+
formatter={formatter}
|
|
372
|
+
rotate={rotate}
|
|
373
|
+
onClick={triggerClick}
|
|
374
|
+
/>
|
|
375
|
+
)}
|
|
376
|
+
{gridLine && (
|
|
377
|
+
<Line
|
|
378
|
+
className="__easyv-gridLine"
|
|
379
|
+
config={gridLine}
|
|
380
|
+
{...gridCoord}
|
|
381
|
+
/>
|
|
382
|
+
)}
|
|
383
|
+
</g>
|
|
384
|
+
)
|
|
385
|
+
);
|
|
337
386
|
});
|
|
338
|
-
|
|
339
|
-
|
|
387
|
+
};
|
|
388
|
+
if (isClipAxis) {
|
|
340
389
|
return (
|
|
341
|
-
|
|
342
|
-
{
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
coordinate={coordinate}
|
|
347
|
-
config={label}
|
|
348
|
-
label={tick}
|
|
349
|
-
tickSize={_tickSize}
|
|
350
|
-
formatter={formatter}
|
|
351
|
-
rotate={rotate}
|
|
352
|
-
onClick={triggerClick}
|
|
353
|
-
/>
|
|
354
|
-
)}
|
|
355
|
-
{gridLine && (
|
|
356
|
-
<Line
|
|
357
|
-
className='__easyv-gridLine'
|
|
358
|
-
config={gridLine}
|
|
359
|
-
{...gridCoord}
|
|
360
|
-
/>
|
|
361
|
-
)}
|
|
362
|
-
</g>
|
|
390
|
+
<>
|
|
391
|
+
{ticks.map((ticks: any, index: number) => {
|
|
392
|
+
return draw(ticks, scaler[index]);
|
|
393
|
+
})}
|
|
394
|
+
</>
|
|
363
395
|
);
|
|
364
|
-
})
|
|
396
|
+
} else if (isControlChart && orientation == "bottom") {
|
|
397
|
+
return <>{draw(rawTicks, scaler)}</>;
|
|
398
|
+
} else {
|
|
399
|
+
return <>{draw(ticks, scaler)}</>;
|
|
400
|
+
}
|
|
365
401
|
}
|
|
366
|
-
if (isClipAxis) {
|
|
367
|
-
return (
|
|
368
|
-
<>
|
|
369
|
-
{ticks.map((ticks: any, index: number) => {
|
|
370
|
-
return draw(ticks, scaler[index]);
|
|
371
|
-
})}
|
|
372
|
-
</>
|
|
373
|
-
);
|
|
374
|
-
} else {
|
|
375
|
-
return <>{draw(ticks, scaler)}</>;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
402
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
403
|
+
return (
|
|
404
|
+
<g>
|
|
405
|
+
{/* 绘制轴线和刻度 */}
|
|
406
|
+
{axisLine && tickLine && (
|
|
407
|
+
<g>
|
|
408
|
+
{axisLine &&
|
|
409
|
+
(positions && positions.length ? (
|
|
410
|
+
positions.map(({ x, y }: any, index: number) => (
|
|
411
|
+
<g
|
|
412
|
+
key={index}
|
|
413
|
+
transform={"translate(" + x + ", " + y + ")"}
|
|
414
|
+
>
|
|
415
|
+
<AxisLine
|
|
416
|
+
orientation={orientation}
|
|
417
|
+
config={axisLine}
|
|
418
|
+
range={range}
|
|
419
|
+
/>
|
|
420
|
+
{tickLine &&
|
|
421
|
+
ticks.map((tick: string, index: number) => {
|
|
422
|
+
const coordinate = scaler(tick);
|
|
423
|
+
if (isNaN(coordinate)) return null;
|
|
424
|
+
const _tickSize = tickLine.tickSize || tickSize;
|
|
425
|
+
const gridCoord = getGridCoord({
|
|
426
|
+
orientation,
|
|
427
|
+
coordinate,
|
|
428
|
+
end:
|
|
429
|
+
orientation == "left" || orientation == "right"
|
|
430
|
+
? width
|
|
431
|
+
: height,
|
|
432
|
+
});
|
|
433
|
+
const x1 = gridCoord.x1;
|
|
434
|
+
const y1 = gridCoord.y1;
|
|
435
|
+
return (
|
|
436
|
+
!(
|
|
437
|
+
(orientation == "bottom" &&
|
|
438
|
+
(x1 < 0 || x1 > xLineRange)) ||
|
|
439
|
+
y1 < 0 ||
|
|
440
|
+
y1 > yLineRange
|
|
441
|
+
) && (
|
|
442
|
+
<Line
|
|
443
|
+
className="__easyv-tickLine"
|
|
444
|
+
key={index}
|
|
445
|
+
config={tickLine}
|
|
446
|
+
{...getTickCoord({
|
|
447
|
+
orientation,
|
|
448
|
+
coordinate,
|
|
449
|
+
tickSize: _tickSize,
|
|
450
|
+
})}
|
|
451
|
+
/>
|
|
452
|
+
)
|
|
453
|
+
);
|
|
454
|
+
})}
|
|
455
|
+
</g>
|
|
456
|
+
))
|
|
457
|
+
) : (
|
|
458
|
+
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
459
|
+
<AxisLine
|
|
460
|
+
orientation={orientation}
|
|
461
|
+
config={axisLine}
|
|
462
|
+
isClipAxis={isClipAxis}
|
|
463
|
+
clipAxisRange={clipAxisRange}
|
|
464
|
+
/>
|
|
465
|
+
{tickLine && drawAxisTickLine()}
|
|
425
466
|
</g>
|
|
426
|
-
))
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
{unit && <Unit config={unit} />}
|
|
467
|
+
))}
|
|
468
|
+
</g>
|
|
469
|
+
)}
|
|
470
|
+
{/* 绘制标签和网格线 */}
|
|
471
|
+
<svg
|
|
472
|
+
width={width}
|
|
473
|
+
style={{
|
|
474
|
+
overflow:
|
|
475
|
+
axisType !== "x" && isControlChart ? "visible" : "hidden",
|
|
476
|
+
}}
|
|
477
|
+
>
|
|
478
|
+
<g transform={"translate(" + x + ", " + y + ")"}>
|
|
479
|
+
{/* 用于控制图 */}
|
|
480
|
+
<g ref={ref as any}>
|
|
481
|
+
{label && gridLine && drawLabel()}
|
|
482
|
+
{unit && <Unit config={unit} />}
|
|
483
|
+
</g>
|
|
484
|
+
</g>
|
|
485
|
+
</svg>
|
|
446
486
|
</g>
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
487
|
+
);
|
|
488
|
+
}
|
|
489
|
+
)
|
|
450
490
|
);
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 轴类图背景
|
|
3
|
-
*/
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { getSeriesInfo } from '../utils';
|
|
6
|
-
|
|
7
|
-
export default ({
|
|
8
|
-
axis: { ticks, scaler, step, direction },
|
|
9
|
-
bandLength,
|
|
10
|
-
config: {
|
|
11
|
-
background,
|
|
12
|
-
seriesIntervalWidth: paddingInner,
|
|
13
|
-
paddingInner: paddingOuter,
|
|
14
|
-
},
|
|
15
|
-
length,
|
|
16
|
-
}: {
|
|
17
|
-
axis: {
|
|
18
|
-
ticks: Array<string>;
|
|
19
|
-
scaler: Function;
|
|
20
|
-
step: number;
|
|
21
|
-
direction: string;
|
|
22
|
-
};
|
|
23
|
-
bandLength: number;
|
|
24
|
-
config: {
|
|
25
|
-
background: string;
|
|
26
|
-
seriesIntervalWidth: number;
|
|
27
|
-
paddingInner: number;
|
|
28
|
-
};
|
|
29
|
-
length: number;
|
|
30
|
-
}) => {
|
|
31
|
-
const isVertical: boolean = direction === 'vertical';
|
|
32
|
-
|
|
33
|
-
const { width: bandwidth } = getSeriesInfo({
|
|
34
|
-
step,
|
|
35
|
-
bandLength,
|
|
36
|
-
paddingInner,
|
|
37
|
-
paddingOuter,
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const size = isVertical
|
|
41
|
-
? {
|
|
42
|
-
width: length,
|
|
43
|
-
height: bandwidth,
|
|
44
|
-
}
|
|
45
|
-
: {
|
|
46
|
-
width: bandwidth,
|
|
47
|
-
height: length,
|
|
48
|
-
};
|
|
49
|
-
return ticks.map((tick, index: number) => {
|
|
50
|
-
return (
|
|
51
|
-
<rect
|
|
52
|
-
key={index}
|
|
53
|
-
{...size}
|
|
54
|
-
x={isVertical ? 0 : scaler(tick) - bandwidth / 2}
|
|
55
|
-
y={isVertical ? scaler(tick) - bandwidth / 2 : 0}
|
|
56
|
-
fill={background}
|
|
57
|
-
stroke='none'
|
|
58
|
-
/>
|
|
59
|
-
);
|
|
60
|
-
});
|
|
61
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* 轴类图背景
|
|
3
|
+
*/
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { getSeriesInfo } from '../utils';
|
|
6
|
+
|
|
7
|
+
export default ({
|
|
8
|
+
axis: { ticks, scaler, step, direction },
|
|
9
|
+
bandLength,
|
|
10
|
+
config: {
|
|
11
|
+
background,
|
|
12
|
+
seriesIntervalWidth: paddingInner,
|
|
13
|
+
paddingInner: paddingOuter,
|
|
14
|
+
},
|
|
15
|
+
length,
|
|
16
|
+
}: {
|
|
17
|
+
axis: {
|
|
18
|
+
ticks: Array<string>;
|
|
19
|
+
scaler: Function;
|
|
20
|
+
step: number;
|
|
21
|
+
direction: string;
|
|
22
|
+
};
|
|
23
|
+
bandLength: number;
|
|
24
|
+
config: {
|
|
25
|
+
background: string;
|
|
26
|
+
seriesIntervalWidth: number;
|
|
27
|
+
paddingInner: number;
|
|
28
|
+
};
|
|
29
|
+
length: number;
|
|
30
|
+
}) => {
|
|
31
|
+
const isVertical: boolean = direction === 'vertical';
|
|
32
|
+
|
|
33
|
+
const { width: bandwidth } = getSeriesInfo({
|
|
34
|
+
step,
|
|
35
|
+
bandLength,
|
|
36
|
+
paddingInner,
|
|
37
|
+
paddingOuter,
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const size = isVertical
|
|
41
|
+
? {
|
|
42
|
+
width: length,
|
|
43
|
+
height: bandwidth,
|
|
44
|
+
}
|
|
45
|
+
: {
|
|
46
|
+
width: bandwidth,
|
|
47
|
+
height: length,
|
|
48
|
+
};
|
|
49
|
+
return ticks.map((tick, index: number) => {
|
|
50
|
+
return (
|
|
51
|
+
<rect
|
|
52
|
+
key={index}
|
|
53
|
+
{...size}
|
|
54
|
+
x={isVertical ? 0 : scaler(tick) - bandwidth / 2}
|
|
55
|
+
y={isVertical ? scaler(tick) - bandwidth / 2 : 0}
|
|
56
|
+
fill={background}
|
|
57
|
+
stroke='none'
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
};
|