@octanejs/recharts 0.1.62 → 0.1.64

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 (73) hide show
  1. package/package.json +5 -5
  2. package/src/animation/AnimatedItems.tsrx +36 -31
  3. package/src/animation/CSSTransitionAnimate.tsrx +1 -2
  4. package/src/animation/JavascriptAnimate.tsrx +1 -2
  5. package/src/cartesian/Area.tsrx +414 -386
  6. package/src/cartesian/AreaRevealShape.tsrx +103 -84
  7. package/src/cartesian/Bar.tsrx +343 -317
  8. package/src/cartesian/BarStack.tsrx +33 -28
  9. package/src/cartesian/CartesianAxis.tsrx +168 -165
  10. package/src/cartesian/CartesianGrid.tsrx +256 -272
  11. package/src/cartesian/ErrorBar.tsrx +108 -104
  12. package/src/cartesian/Funnel.tsrx +405 -382
  13. package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
  14. package/src/cartesian/Line.tsrx +190 -177
  15. package/src/cartesian/LineDrawShape.tsrx +14 -15
  16. package/src/cartesian/ReferenceLine.tsrx +119 -105
  17. package/src/cartesian/Scatter.tsrx +416 -398
  18. package/src/cartesian/XAxis.tsrx +39 -32
  19. package/src/cartesian/YAxis.tsrx +47 -37
  20. package/src/cartesian/ZAxis.tsrx +76 -73
  21. package/src/chart/AreaChart.tsrx +15 -11
  22. package/src/chart/BarChart.tsrx +15 -11
  23. package/src/chart/CategoricalChart.tsrx +32 -26
  24. package/src/chart/ComposedChart.tsrx +15 -11
  25. package/src/chart/FunnelChart.tsrx +15 -11
  26. package/src/chart/LineChart.tsrx +15 -11
  27. package/src/chart/PieChart.tsrx +15 -11
  28. package/src/chart/PolarChart.tsrx +45 -48
  29. package/src/chart/RadarChart.tsrx +38 -32
  30. package/src/chart/RadialBarChart.tsrx +15 -11
  31. package/src/chart/RechartsWrapper.tsrx +214 -162
  32. package/src/chart/Sankey.tsrx +412 -378
  33. package/src/chart/ScatterChart.tsrx +15 -11
  34. package/src/chart/SunburstChart.tsrx +162 -155
  35. package/src/component/ActivePoints.tsrx +19 -13
  36. package/src/component/Cursor.tsrx +25 -18
  37. package/src/component/DefaultLegendContent.tsrx +131 -127
  38. package/src/component/DefaultTooltipContent.tsrx +46 -42
  39. package/src/component/Dots.tsrx +11 -5
  40. package/src/component/Label.tsrx +69 -55
  41. package/src/component/LabelList.tsrx +32 -27
  42. package/src/component/Legend.tsrx +120 -123
  43. package/src/component/ResponsiveContainer.tsrx +18 -11
  44. package/src/component/Text.tsrx +50 -43
  45. package/src/component/Tooltip.tsrx +234 -223
  46. package/src/component/TooltipBoundingBox.tsrx +34 -34
  47. package/src/container/ClipPathProvider.tsrx +1 -3
  48. package/src/container/Layer.tsrx +5 -1
  49. package/src/container/RootSurface.tsrx +31 -21
  50. package/src/container/Surface.tsrx +15 -13
  51. package/src/context/ErrorBarContext.tsrx +5 -5
  52. package/src/polar/Pie.tsrx +541 -487
  53. package/src/polar/PolarAngleAxis.tsrx +245 -227
  54. package/src/polar/PolarGrid.tsrx +139 -127
  55. package/src/polar/PolarRadiusAxis.tsrx +204 -185
  56. package/src/polar/Radar.tsrx +274 -264
  57. package/src/polar/RadialBar.tsrx +408 -361
  58. package/src/shape/Cross.tsrx +13 -7
  59. package/src/shape/Curve.tsrx +54 -44
  60. package/src/shape/Dot.tsrx +10 -8
  61. package/src/shape/Polygon.tsrx +38 -29
  62. package/src/shape/Rectangle.tsrx +73 -28
  63. package/src/shape/Sector.tsrx +30 -18
  64. package/src/shape/Symbols.tsrx +13 -11
  65. package/src/shape/Trapezoid.tsrx +16 -11
  66. package/src/state/RechartsStoreProvider.tsrx +5 -1
  67. package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
  68. package/src/util/BarUtils.tsrx +43 -40
  69. package/src/util/FunnelUtils.tsrx +5 -5
  70. package/src/util/RadialBarUtils.tsrx +3 -4
  71. package/src/util/ScatterUtils.tsrx +13 -8
  72. package/src/zIndex/ZIndexLayer.tsrx +2 -2
  73. package/src/zIndex/ZIndexPortal.tsrx +2 -8
@@ -37,69 +37,69 @@ export type ErrorBarDirection = 'x' | 'y';
37
37
 
38
38
  export type ErrorBarDataPointFormatter<
39
39
  T extends BarRectangleItem | LinePointItem | ScatterPointItem,
40
- > =
41
- (entry: T, dataKey: DataKey<
42
- T,
43
- number[] | number
44
- >, direction: ErrorBarDirection) => ErrorBarDataItem;
40
+ > = (
41
+ entry: T,
42
+ dataKey: DataKey<T, number[] | number>,
43
+ direction: ErrorBarDirection,
44
+ ) => ErrorBarDataItem;
45
45
 
46
46
  /**
47
47
  * External ErrorBar props, visible for users of the library
48
48
  */
49
49
  interface ErrorBarProps<DataPointType = any, DataValueType = any> extends ZIndexable {
50
50
  /**
51
- * Decides how to extract the value of this ErrorBar from the data:
52
- * - `string`: the name of the field in the data object;
53
- * - `number`: the index of the field in the data;
54
- * - `function`: a function that receives the data object and returns the value of this ErrorBar.
55
- *
56
- * The error values can be a single value for symmetric error bars;
57
- * or an array of a lower and upper error value for asymmetric error bars.
58
- */
51
+ * Decides how to extract the value of this ErrorBar from the data:
52
+ * - `string`: the name of the field in the data object;
53
+ * - `number`: the index of the field in the data;
54
+ * - `function`: a function that receives the data object and returns the value of this ErrorBar.
55
+ *
56
+ * The error values can be a single value for symmetric error bars;
57
+ * or an array of a lower and upper error value for asymmetric error bars.
58
+ */
59
59
  dataKey: DataKey<DataPointType, DataValueType>;
60
60
  /**
61
- * Width of the error bar ends (the serifs) in pixels.
62
- * This is not the total width of the error bar, but just the width of the little lines at the ends.
63
- *
64
- * The total width of the error bar is determined by the data value plus/minus the error value.
65
- *
66
- * @defaultValue 5
67
- */
61
+ * Width of the error bar ends (the serifs) in pixels.
62
+ * This is not the total width of the error bar, but just the width of the little lines at the ends.
63
+ *
64
+ * The total width of the error bar is determined by the data value plus/minus the error value.
65
+ *
66
+ * @defaultValue 5
67
+ */
68
68
  width?: number;
69
69
  /**
70
- * Direction of the error bar. Usually determined by chart layout, except in Scatter chart.
71
- * In Scatter chart, "x" means horizontal error bars, "y" means vertical error bars.
72
- */
70
+ * Direction of the error bar. Usually determined by chart layout, except in Scatter chart.
71
+ * In Scatter chart, "x" means horizontal error bars, "y" means vertical error bars.
72
+ */
73
73
  direction?: ErrorBarDirection;
74
74
  /**
75
- * @defaultValue true
76
- */
75
+ * @defaultValue true
76
+ */
77
77
  isAnimationActive?: boolean;
78
78
  /**
79
- * @defaultValue 0
80
- */
79
+ * @defaultValue 0
80
+ */
81
81
  animationBegin?: number;
82
82
  /**
83
- * @defaultValue 400
84
- */
83
+ * @defaultValue 400
84
+ */
85
85
  animationDuration?: number;
86
86
  /**
87
- * @defaultValue ease-in-out
88
- */
87
+ * @defaultValue ease-in-out
88
+ */
89
89
  animationEasing?: EasingInput;
90
90
  /**
91
- * The width of the stroke
92
- */
91
+ * The width of the stroke
92
+ */
93
93
  strokeWidth?: number | string;
94
94
  /**
95
- * The stroke color. If "none", no line will be drawn.
96
- *
97
- * @defaultValue black
98
- */
95
+ * The stroke color. If "none", no line will be drawn.
96
+ *
97
+ * @defaultValue black
98
+ */
99
99
  stroke?: string;
100
100
  /**
101
- * @defaultValue 400
102
- */
101
+ * @defaultValue 400
102
+ */
103
103
  zIndex?: number;
104
104
  }
105
105
 
@@ -108,21 +108,20 @@ export type Props = SVGProps<SVGLineElement> & ErrorBarProps;
108
108
  /**
109
109
  * Props after defaults, and required props have been applied.
110
110
  */
111
- type ErrorBarInternalProps =
112
- SVGProps<SVGLineElement> & {
113
- dataKey: DataKey<any>;
114
- /** the width of the error bar ends */
115
- width: number;
116
- /**
117
- * Only used for ScatterChart with error bars in two directions.
118
- * Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
119
- */
120
- direction: ErrorBarDirection;
121
- isAnimationActive: boolean;
122
- animationBegin: number;
123
- animationDuration: number;
124
- animationEasing: EasingInput;
125
- };
111
+ type ErrorBarInternalProps = SVGProps<SVGLineElement> & {
112
+ dataKey: DataKey<any>;
113
+ /** the width of the error bar ends */
114
+ width: number;
115
+ /**
116
+ * Only used for ScatterChart with error bars in two directions.
117
+ * Only accepts a value of "x" or "y" and makes the error bars lie in that direction.
118
+ */
119
+ direction: ErrorBarDirection;
120
+ isAnimationActive: boolean;
121
+ animationBegin: number;
122
+ animationDuration: number;
123
+ animationEasing: EasingInput;
124
+ };
126
125
 
127
126
  function ErrorBarImpl(props: ErrorBarInternalProps) {
128
127
  const {
@@ -137,8 +136,13 @@ function ErrorBarImpl(props: ErrorBarInternalProps) {
137
136
  } = props;
138
137
  const svgProps = svgPropertiesNoEvents(others);
139
138
 
140
- const { data, dataPointFormatter, xAxisId, yAxisId, errorBarOffset: offset } =
141
- useErrorBarContext();
139
+ const {
140
+ data,
141
+ dataPointFormatter,
142
+ xAxisId,
143
+ yAxisId,
144
+ errorBarOffset: offset,
145
+ } = useErrorBarContext();
142
146
 
143
147
  const xAxis = useXAxis(xAxisId);
144
148
  const yAxis = useYAxis(yAxisId);
@@ -213,32 +217,36 @@ function ErrorBarImpl(props: ErrorBarInternalProps) {
213
217
  }
214
218
  }
215
219
 
216
- const scaleDirection: string =
217
- direction === 'x' ? 'scaleX' : 'scaleY';
218
-
219
- const transformOrigin =
220
- direction === 'x' ? `${x}px ${y + offset}px` : `${x + offset}px ${y}px`;
221
-
222
- return <Layer
223
- className="recharts-errorBar"
224
- key={`bar-${x}-${y}-${value}-${dataIndex}`}
225
- {...svgProps}
226
- >{lineCoordinates.map((c, lineIndex) => {
227
- const lineStyle = isAnimationActive ? { transformOrigin } : undefined;
228
- return <CSSTransitionAnimate
229
- animationId={`error-bar-${direction}_${c.x1}-${c.x2}-${c.y1}-${c.y2}`}
230
- from={`${scaleDirection}(0)`}
231
- to={`${scaleDirection}(1)`}
232
- attributeName="transform"
233
- begin={animationBegin}
234
- easing={extractCssEasing(animationEasing)}
235
- isActive={isAnimationActive}
236
- duration={animationDuration}
237
- key={`errorbar-${dataIndex}-${c.x1}-${c.y1}-${c.x2}-${c.y2}-${lineIndex}`}
220
+ const scaleDirection: string = direction === 'x' ? 'scaleX' : 'scaleY';
221
+
222
+ const transformOrigin = direction === 'x' ? `${x}px ${y + offset}px` : `${x + offset}px ${y}px`;
223
+
224
+ return (
225
+ <Layer
226
+ className="recharts-errorBar"
227
+ key={`bar-${x}-${y}-${value}-${dataIndex}`}
228
+ {...svgProps}
238
229
  >
239
- {(style) => <line {...c} style={{ ...lineStyle, ...style }} />}
240
- </CSSTransitionAnimate>;
241
- })}</Layer>;
230
+ {lineCoordinates.map((c, lineIndex) => {
231
+ const lineStyle = isAnimationActive ? { transformOrigin } : undefined;
232
+ return (
233
+ <CSSTransitionAnimate
234
+ animationId={`error-bar-${direction}_${c.x1}-${c.x2}-${c.y1}-${c.y2}`}
235
+ from={`${scaleDirection}(0)`}
236
+ to={`${scaleDirection}(1)`}
237
+ attributeName="transform"
238
+ begin={animationBegin}
239
+ easing={extractCssEasing(animationEasing)}
240
+ isActive={isAnimationActive}
241
+ duration={animationDuration}
242
+ key={`errorbar-${dataIndex}-${c.x1}-${c.y1}-${c.x2}-${c.y2}-${lineIndex}`}
243
+ >
244
+ {(style) => <line {...c} style={{ ...lineStyle, ...style }} />}
245
+ </CSSTransitionAnimate>
246
+ );
247
+ })}
248
+ </Layer>
249
+ );
242
250
  });
243
251
 
244
252
  return <Layer className="recharts-errorBars">{errorBars}</Layer>;
@@ -294,29 +302,25 @@ export const errorBarDefaultProps = {
294
302
  export function ErrorBar(outsideProps: Props) {
295
303
  const realDirection: ErrorBarDirection = useErrorBarDirection(outsideProps.direction);
296
304
  const props = resolveDefaultProps(outsideProps, errorBarDefaultProps);
297
- const {
298
- width,
299
- isAnimationActive,
300
- animationBegin,
301
- animationDuration,
302
- animationEasing,
303
- zIndex,
304
- } = props;
305
-
306
- return <>
307
- <ReportErrorBarSettings dataKey={props.dataKey} direction={realDirection} />
308
- <ZIndexLayer zIndex={zIndex}>
309
- <ErrorBarImpl
310
- {...props}
311
- direction={realDirection}
312
- width={width}
313
- isAnimationActive={isAnimationActive}
314
- animationBegin={animationBegin}
315
- animationDuration={animationDuration}
316
- animationEasing={animationEasing}
317
- />
318
- </ZIndexLayer>
319
- </>;
305
+ const { width, isAnimationActive, animationBegin, animationDuration, animationEasing, zIndex } =
306
+ props;
307
+
308
+ return (
309
+ <>
310
+ <ReportErrorBarSettings dataKey={props.dataKey} direction={realDirection} />
311
+ <ZIndexLayer zIndex={zIndex}>
312
+ <ErrorBarImpl
313
+ {...props}
314
+ direction={realDirection}
315
+ width={width}
316
+ isAnimationActive={isAnimationActive}
317
+ animationBegin={animationBegin}
318
+ animationDuration={animationDuration}
319
+ animationEasing={animationEasing}
320
+ />
321
+ </ZIndexLayer>
322
+ </>
323
+ );
320
324
  }
321
325
 
322
326
  ErrorBar.displayName = 'ErrorBar';