@easyv/charts 1.4.22 → 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.
Files changed (90) 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 +8 -16
  6. package/lib/components/Axis.js +106 -138
  7. package/lib/components/Background.js +18 -26
  8. package/lib/components/Band.js +105 -91
  9. package/lib/components/BaseLine.js +33 -46
  10. package/lib/components/Brush.js +29 -46
  11. package/lib/components/Carousel.js +13 -40
  12. package/lib/components/CartesianChart.js +291 -112
  13. package/lib/components/Chart.js +23 -36
  14. package/lib/components/ChartContainer.js +21 -29
  15. package/lib/components/ConicalGradient.js +56 -89
  16. package/lib/components/Control.js +65 -0
  17. package/lib/components/ExtentData.js +9 -17
  18. package/lib/components/FilterData.js +16 -27
  19. package/lib/components/Indicator.js +66 -12
  20. package/lib/components/Label.js +128 -118
  21. package/lib/components/Legend.js +41 -66
  22. package/lib/components/Lighter.js +21 -50
  23. package/lib/components/Line.js +39 -59
  24. package/lib/components/LinearGradient.js +16 -22
  25. package/lib/components/Mapping.js +9 -34
  26. package/lib/components/Marquee.js +14 -30
  27. package/lib/components/PieChart.js +311 -405
  28. package/lib/components/StackData.js +8 -18
  29. package/lib/components/StereoBar.js +65 -105
  30. package/lib/components/TextOverflow.js +8 -21
  31. package/lib/components/Tooltip.js +41 -55
  32. package/lib/components/index.js +7 -27
  33. package/lib/context/index.js +0 -2
  34. package/lib/css/index.module.css +42 -42
  35. package/lib/css/piechart.module.css +26 -26
  36. package/lib/element/ConicGradient.js +29 -35
  37. package/lib/element/Line.js +9 -13
  38. package/lib/element/index.js +0 -2
  39. package/lib/formatter/index.js +0 -2
  40. package/lib/formatter/legend.js +30 -41
  41. package/lib/hooks/index.js +0 -9
  42. package/lib/hooks/useAiData.js +12 -20
  43. package/lib/hooks/useAnimateData.js +8 -21
  44. package/lib/hooks/useAxes.js +69 -115
  45. package/lib/hooks/useCarouselAxisX.js +47 -68
  46. package/lib/hooks/useExtentData.js +14 -46
  47. package/lib/hooks/useFilterData.js +13 -34
  48. package/lib/hooks/useStackData.js +12 -35
  49. package/lib/hooks/useTooltip.js +37 -54
  50. package/lib/index.js +0 -15
  51. package/lib/utils/index.js +95 -247
  52. package/package.json +55 -55
  53. package/src/components/Axis.tsx +223 -183
  54. package/src/components/Background.tsx +61 -61
  55. package/src/components/Band.tsx +274 -239
  56. package/src/components/Brush.js +159 -159
  57. package/src/components/CartesianChart.js +319 -43
  58. package/src/components/Chart.js +99 -99
  59. package/src/components/ChartContainer.tsx +71 -64
  60. package/src/components/ConicalGradient.js +258 -258
  61. package/src/components/Control.jsx +51 -0
  62. package/src/components/ExtentData.js +17 -17
  63. package/src/components/Indicator.js +61 -13
  64. package/src/components/Label.js +275 -242
  65. package/src/components/Legend.js +165 -165
  66. package/src/components/Lighter.jsx +173 -173
  67. package/src/components/Line.js +150 -150
  68. package/src/components/LinearGradient.js +29 -29
  69. package/src/components/PieChart.js +7 -3
  70. package/src/components/StereoBar.tsx +307 -307
  71. package/src/components/index.js +57 -55
  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/useAxes.js +9 -2
  83. package/src/hooks/useCarouselAxisX.js +35 -18
  84. package/src/hooks/useFilterData.js +72 -72
  85. package/src/hooks/useStackData.js +101 -101
  86. package/src/hooks/useTooltip.ts +100 -100
  87. package/src/index.js +6 -6
  88. package/src/types/index.d.ts +67 -67
  89. package/src/utils/index.js +757 -757
  90. package/tsconfig.json +23 -23
package/package.json CHANGED
@@ -1,55 +1,55 @@
1
- {
2
- "name": "@easyv/charts",
3
- "version": "1.4.22",
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
+ }
@@ -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
- orientation,
255
- scaler,
256
- tickSize = defaultTickSize,
257
- ticks,
258
- formatter,
259
- rotate,
260
- triggerClick,
261
- config: { on, label, axisLine, tickLine, gridLine, unit },
262
- config,
263
- positions,
264
- xLineRange,
265
- //断轴图相关
266
- isClipAxis = false,
267
- yLineRange,
268
- clipAxisRange,
269
- }: any) => {
270
- if (!(on && ticks.length > 0)) return null;
271
- const { width, height } = useContext(chartContext);
272
- const x = orientation == "right" ? width : 0;
273
- const y = orientation == "bottom" ? height : 0;
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
- function drawYAxisTickLine() {
276
- const draw = (ticks: any, scaler: any) => {
277
- return ticks.map((tick: string, index: number) => {
278
- const coordinate = scaler(tick);
279
- if (isNaN(coordinate)) return null;
280
- const _tickSize = tickLine.tickSize || tickSize;
281
- const gridCoord = getGridCoord({
282
- orientation,
283
- coordinate,
284
- end:
285
- orientation == "left" || orientation == "right" ? width : height,
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
- const x1 = gridCoord.x1;
289
- const y1 = gridCoord.y1;
326
+ if (isClipAxis) {
290
327
  return (
291
- !(
292
- (orientation == "bottom" && (x1 < 0 || x1 > xLineRange)) ||
293
- y1 < 0 ||
294
- y1 > yLineRange
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
- function drawLabel() {
325
- const draw = (ticks: any, scaler: any) => {
326
- return ticks.map((tick: string, index: number) => {
327
- const coordinate = scaler(tick);
328
- if (isNaN(coordinate)) return null;
329
- const _tickSize = tickLine.tickSize || tickSize;
330
- const gridCoord = getGridCoord({
331
- orientation,
332
- coordinate,
333
- end:
334
- orientation == 'left' || orientation == 'right'
335
- ? width
336
- : height,
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
- const x1 = gridCoord.x1;
339
- const y1 = gridCoord.y1;
387
+ };
388
+ if (isClipAxis) {
340
389
  return (
341
- !(orientation=="bottom" && (x1<0 || x1>xLineRange) || (y1<0 || y1>yLineRange)) && <g key={index}>
342
- {label && (
343
- <Label
344
- className='__easyv-label'
345
- orientation={orientation}
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
- return (
380
- <>
381
- {/* 绘制轴线和刻度 */}
382
- {axisLine && tickLine && (
383
- <>
384
- {axisLine &&
385
- // 依据positions来区分x轴y轴,有position为x轴
386
- (positions && positions.length ? (
387
- positions.map(({ x, y }: any, index: number) => (
388
- <g key={index} transform={"translate(" + x + ", " + y + ")"}>
389
- <AxisLine orientation={orientation} config={axisLine} />
390
- {tickLine &&
391
- ticks.map((tick: string, index: number) => {
392
- const coordinate = scaler(tick);
393
- if (isNaN(coordinate)) return null;
394
- const _tickSize = tickLine.tickSize || tickSize;
395
- const gridCoord = getGridCoord({
396
- orientation,
397
- coordinate,
398
- end:
399
- orientation == "left" || orientation == "right"
400
- ? width
401
- : height,
402
- });
403
- const x1 = gridCoord.x1;
404
- const y1 = gridCoord.y1;
405
- return (
406
- !(
407
- (orientation == "bottom" &&
408
- (x1 < 0 || x1 > xLineRange)) ||
409
- y1 < 0 ||
410
- y1 > yLineRange
411
- ) && (
412
- <Line
413
- className="__easyv-tickLine"
414
- key={index}
415
- config={tickLine}
416
- {...getTickCoord({
417
- orientation,
418
- coordinate,
419
- tickSize: _tickSize,
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
- <g transform={"translate(" + x + ", " + y + ")"}>
429
- <AxisLine
430
- orientation={orientation}
431
- config={axisLine}
432
- isClipAxis={isClipAxis}
433
- clipAxisRange={clipAxisRange}
434
- />
435
- {tickLine && drawYAxisTickLine()}
436
- </g>
437
- ))}
438
- </>
439
- )}
440
- {/* 绘制标签和网格线 */}
441
- <g transform={'translate(' + x + ', ' + y + ')'}>
442
- {label &&
443
- gridLine && drawLabel()
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
+ };