@octanejs/recharts 0.1.61 → 0.1.63
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/package.json +5 -5
- package/src/animation/AnimatedItems.tsrx +36 -31
- package/src/animation/CSSTransitionAnimate.tsrx +1 -2
- package/src/animation/JavascriptAnimate.tsrx +1 -2
- package/src/cartesian/Area.tsrx +414 -386
- package/src/cartesian/AreaRevealShape.tsrx +103 -84
- package/src/cartesian/Bar.tsrx +343 -317
- package/src/cartesian/BarStack.tsrx +33 -28
- package/src/cartesian/CartesianAxis.tsrx +168 -165
- package/src/cartesian/CartesianGrid.tsrx +256 -272
- package/src/cartesian/ErrorBar.tsrx +108 -104
- package/src/cartesian/Funnel.tsrx +405 -382
- package/src/cartesian/GraphicalItemClipPath.tsrx +4 -8
- package/src/cartesian/Line.tsrx +190 -177
- package/src/cartesian/LineDrawShape.tsrx +14 -15
- package/src/cartesian/ReferenceLine.tsrx +119 -105
- package/src/cartesian/Scatter.tsrx +416 -398
- package/src/cartesian/XAxis.tsrx +39 -32
- package/src/cartesian/YAxis.tsrx +47 -37
- package/src/cartesian/ZAxis.tsrx +76 -73
- package/src/chart/AreaChart.tsrx +15 -11
- package/src/chart/BarChart.tsrx +15 -11
- package/src/chart/CategoricalChart.tsrx +32 -26
- package/src/chart/ComposedChart.tsrx +15 -11
- package/src/chart/FunnelChart.tsrx +15 -11
- package/src/chart/LineChart.tsrx +15 -11
- package/src/chart/PieChart.tsrx +15 -11
- package/src/chart/PolarChart.tsrx +45 -48
- package/src/chart/RadarChart.tsrx +38 -32
- package/src/chart/RadialBarChart.tsrx +15 -11
- package/src/chart/RechartsWrapper.tsrx +214 -162
- package/src/chart/Sankey.tsrx +412 -378
- package/src/chart/ScatterChart.tsrx +15 -11
- package/src/chart/SunburstChart.tsrx +162 -155
- package/src/component/ActivePoints.tsrx +19 -13
- package/src/component/Cursor.tsrx +25 -18
- package/src/component/DefaultLegendContent.tsrx +131 -127
- package/src/component/DefaultTooltipContent.tsrx +46 -42
- package/src/component/Dots.tsrx +11 -5
- package/src/component/Label.tsrx +69 -55
- package/src/component/LabelList.tsrx +32 -27
- package/src/component/Legend.tsrx +120 -123
- package/src/component/ResponsiveContainer.tsrx +18 -11
- package/src/component/Text.tsrx +50 -43
- package/src/component/Tooltip.tsrx +234 -223
- package/src/component/TooltipBoundingBox.tsrx +34 -34
- package/src/container/ClipPathProvider.tsrx +1 -3
- package/src/container/Layer.tsrx +5 -1
- package/src/container/RootSurface.tsrx +31 -21
- package/src/container/Surface.tsrx +15 -13
- package/src/context/ErrorBarContext.tsrx +5 -5
- package/src/polar/Pie.tsrx +541 -487
- package/src/polar/PolarAngleAxis.tsrx +245 -227
- package/src/polar/PolarGrid.tsrx +139 -127
- package/src/polar/PolarRadiusAxis.tsrx +204 -185
- package/src/polar/Radar.tsrx +274 -264
- package/src/polar/RadialBar.tsrx +408 -361
- package/src/shape/Cross.tsrx +13 -7
- package/src/shape/Curve.tsrx +54 -44
- package/src/shape/Dot.tsrx +10 -8
- package/src/shape/Polygon.tsrx +38 -29
- package/src/shape/Rectangle.tsrx +73 -28
- package/src/shape/Sector.tsrx +30 -18
- package/src/shape/Symbols.tsrx +13 -11
- package/src/shape/Trapezoid.tsrx +16 -11
- package/src/state/RechartsStoreProvider.tsrx +5 -1
- package/src/synchronisation/useChartSynchronisation.tsrx +8 -7
- package/src/util/BarUtils.tsrx +43 -40
- package/src/util/FunnelUtils.tsrx +5 -5
- package/src/util/RadialBarUtils.tsrx +3 -4
- package/src/util/ScatterUtils.tsrx +13 -8
- package/src/zIndex/ZIndexLayer.tsrx +2 -2
- package/src/zIndex/ZIndexPortal.tsrx +2 -8
|
@@ -37,14 +37,10 @@ export function GraphicalItemClipPath(props: GraphicalItemClipPathProps) @{
|
|
|
37
37
|
return null;
|
|
38
38
|
}
|
|
39
39
|
const { x, y, width, height } = plotArea;
|
|
40
|
-
const clipX =
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
const clipWidth =
|
|
45
|
-
needClipX && xAxisRange ? Math.abs(xAxisRange[1] - xAxisRange[0]) : width * 2;
|
|
46
|
-
const clipHeight =
|
|
47
|
-
needClipY && yAxisRange ? Math.abs(yAxisRange[1] - yAxisRange[0]) : height * 2;
|
|
40
|
+
const clipX = needClipX && xAxisRange ? Math.min(xAxisRange[0], xAxisRange[1]) : x - width / 2;
|
|
41
|
+
const clipY = needClipY && yAxisRange ? Math.min(yAxisRange[0], yAxisRange[1]) : y - height / 2;
|
|
42
|
+
const clipWidth = needClipX && xAxisRange ? Math.abs(xAxisRange[1] - xAxisRange[0]) : width * 2;
|
|
43
|
+
const clipHeight = needClipY && yAxisRange ? Math.abs(yAxisRange[1] - yAxisRange[0]) : height * 2;
|
|
48
44
|
<clipPath id={'clipPath-' + clipPathId}>
|
|
49
45
|
<rect x={clipX} y={clipY} width={clipWidth} height={clipHeight} />
|
|
50
46
|
</clipPath>
|
package/src/cartesian/Line.tsrx
CHANGED
|
@@ -71,9 +71,8 @@ interface InternalLineProps extends ZIndexable {
|
|
|
71
71
|
xAxisId: AxisId;
|
|
72
72
|
yAxisId: AxisId;
|
|
73
73
|
}
|
|
74
|
-
interface LineProps<DataPointType = any, DataValueType = any>
|
|
75
|
-
DataPointType
|
|
76
|
-
>, DataConsumer<DataPointType, DataValueType>, ZIndexable {
|
|
74
|
+
interface LineProps<DataPointType = any, DataValueType = any>
|
|
75
|
+
extends DataProvider<DataPointType>, DataConsumer<DataPointType, DataValueType>, ZIndexable {
|
|
77
76
|
activeDot?: ActiveDotType;
|
|
78
77
|
animateNewValues?: boolean;
|
|
79
78
|
animationBegin?: number;
|
|
@@ -106,8 +105,8 @@ interface LineProps<DataPointType = any, DataValueType = any> extends DataProvid
|
|
|
106
105
|
}
|
|
107
106
|
type LineSvgProps = Omit<CurveProps, 'points' | 'pathRef' | 'ref' | 'layout' | 'baseLine'>;
|
|
108
107
|
type InternalProps = LineSvgProps & InternalLineProps;
|
|
109
|
-
export type Props<DataPointType = any, ValueAxisType = any> =
|
|
110
|
-
|
|
108
|
+
export type Props<DataPointType = any, ValueAxisType = any> = LineSvgProps &
|
|
109
|
+
LineProps<DataPointType, ValueAxisType>;
|
|
111
110
|
// Port of cartesian/Line.tsx — the line graphical item: redux registration,
|
|
112
111
|
// store-computed points, the draw-in curve, dots, labels, active points.
|
|
113
112
|
// `computeLinePoints` stays here (vendored lineSelectors imports it through
|
|
@@ -150,7 +149,7 @@ import { Dots } from '../component/Dots.tsrx';
|
|
|
150
149
|
|
|
151
150
|
function getTotalLength(mainCurve: SVGPathElement | null) {
|
|
152
151
|
try {
|
|
153
|
-
return mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength() || 0;
|
|
152
|
+
return (mainCurve && mainCurve.getTotalLength && mainCurve.getTotalLength()) || 0;
|
|
154
153
|
} catch {
|
|
155
154
|
return 0;
|
|
156
155
|
}
|
|
@@ -258,55 +257,57 @@ const computeLegendPayloadFromAreaData = (props: Props) => {
|
|
|
258
257
|
];
|
|
259
258
|
};
|
|
260
259
|
|
|
261
|
-
const SetLineTooltipEntrySettings = memo(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
strokeWidth,
|
|
282
|
-
fill,
|
|
283
|
-
name,
|
|
284
|
-
hide,
|
|
285
|
-
unit,
|
|
286
|
-
formatter,
|
|
287
|
-
tooltipType,
|
|
288
|
-
id,
|
|
289
|
-
} = props;
|
|
290
|
-
const tooltipEntrySettings: TooltipPayloadConfiguration = {
|
|
291
|
-
dataDefinedOnItem: data,
|
|
292
|
-
getPosition: noop,
|
|
293
|
-
settings: {
|
|
260
|
+
const SetLineTooltipEntrySettings = memo(
|
|
261
|
+
(
|
|
262
|
+
props: Pick<
|
|
263
|
+
InternalProps,
|
|
264
|
+
| 'dataKey'
|
|
265
|
+
| 'data'
|
|
266
|
+
| 'stroke'
|
|
267
|
+
| 'strokeWidth'
|
|
268
|
+
| 'fill'
|
|
269
|
+
| 'name'
|
|
270
|
+
| 'hide'
|
|
271
|
+
| 'unit'
|
|
272
|
+
| 'formatter'
|
|
273
|
+
| 'tooltipType'
|
|
274
|
+
| 'id'
|
|
275
|
+
>,
|
|
276
|
+
) => {
|
|
277
|
+
const {
|
|
278
|
+
dataKey,
|
|
279
|
+
data,
|
|
294
280
|
stroke,
|
|
295
281
|
strokeWidth,
|
|
296
282
|
fill,
|
|
297
|
-
|
|
298
|
-
nameKey: undefined,
|
|
299
|
-
name: getTooltipNameProp(name, dataKey),
|
|
283
|
+
name,
|
|
300
284
|
hide,
|
|
301
|
-
type: tooltipType,
|
|
302
|
-
color: stroke,
|
|
303
285
|
unit,
|
|
304
286
|
formatter,
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
287
|
+
tooltipType,
|
|
288
|
+
id,
|
|
289
|
+
} = props;
|
|
290
|
+
const tooltipEntrySettings: TooltipPayloadConfiguration = {
|
|
291
|
+
dataDefinedOnItem: data,
|
|
292
|
+
getPosition: noop,
|
|
293
|
+
settings: {
|
|
294
|
+
stroke,
|
|
295
|
+
strokeWidth,
|
|
296
|
+
fill,
|
|
297
|
+
dataKey,
|
|
298
|
+
nameKey: undefined,
|
|
299
|
+
name: getTooltipNameProp(name, dataKey),
|
|
300
|
+
hide,
|
|
301
|
+
type: tooltipType,
|
|
302
|
+
color: stroke,
|
|
303
|
+
unit,
|
|
304
|
+
formatter,
|
|
305
|
+
graphicalItemId: id,
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
return <SetTooltipEntrySettings tooltipEntrySettings={tooltipEntrySettings} />;
|
|
309
|
+
},
|
|
310
|
+
);
|
|
310
311
|
|
|
311
312
|
function LineDotsWrapper(props: {
|
|
312
313
|
points: ReadonlyArray<LinePointItem>;
|
|
@@ -318,16 +319,18 @@ function LineDotsWrapper(props: {
|
|
|
318
319
|
// Exclude ID so it isn't duplicated across every dot.
|
|
319
320
|
const { id, ...propsWithoutId } = props.props;
|
|
320
321
|
const lineProps = svgPropertiesNoEvents(propsWithoutId);
|
|
321
|
-
return
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
return (
|
|
323
|
+
<Dots
|
|
324
|
+
points={points}
|
|
325
|
+
dot={dot}
|
|
326
|
+
className="recharts-line-dots"
|
|
327
|
+
dotClassName="recharts-line-dot"
|
|
328
|
+
dataKey={dataKey}
|
|
329
|
+
baseProps={lineProps}
|
|
330
|
+
needClip={needClip}
|
|
331
|
+
clipPathId={clipPathId}
|
|
332
|
+
/>
|
|
333
|
+
);
|
|
331
334
|
}
|
|
332
335
|
|
|
333
336
|
function LineLabelListProvider(props: {
|
|
@@ -356,9 +359,9 @@ function LineLabelListProvider(props: {
|
|
|
356
359
|
};
|
|
357
360
|
});
|
|
358
361
|
}, [points]);
|
|
359
|
-
<CartesianLabelListContextProvider
|
|
360
|
-
|
|
361
|
-
|
|
362
|
+
<CartesianLabelListContextProvider value={showLabels ? labelListEntries : undefined}>
|
|
363
|
+
{children}
|
|
364
|
+
</CartesianLabelListContextProvider>
|
|
362
365
|
}
|
|
363
366
|
|
|
364
367
|
function StaticCurve(staticCurveProps: {
|
|
@@ -398,11 +401,14 @@ function StaticCurve(staticCurveProps: {
|
|
|
398
401
|
isEntrance: props.animateNewValues ? isEntrance : false,
|
|
399
402
|
visibleLength,
|
|
400
403
|
};
|
|
401
|
-
return
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
404
|
+
return (
|
|
405
|
+
<>
|
|
406
|
+
{points?.length > 1 && (
|
|
407
|
+
<Shape option={shape} DefaultShape={defaultLineProps.shape} shapeProps={curveProps} />
|
|
408
|
+
)}
|
|
409
|
+
<LineDotsWrapper points={points} clipPathId={clipPathId} props={props} />
|
|
410
|
+
</>
|
|
411
|
+
);
|
|
406
412
|
}
|
|
407
413
|
|
|
408
414
|
function CurveWithAnimation(curveWithAnimationProps: {
|
|
@@ -434,57 +440,61 @@ function CurveWithAnimation(curveWithAnimationProps: {
|
|
|
434
440
|
(animationElapsedTime: number) => animationElapsedTime > 0 && totalLength > 0,
|
|
435
441
|
[totalLength],
|
|
436
442
|
);
|
|
437
|
-
return
|
|
438
|
-
{
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
443
|
+
return (
|
|
444
|
+
<LineLabelListProvider points={points} showLabels={showLabels}>
|
|
445
|
+
{props.children}
|
|
446
|
+
<AnimatedItems
|
|
447
|
+
animationInput={points}
|
|
448
|
+
animationIdPrefix="recharts-line-"
|
|
449
|
+
items={points}
|
|
450
|
+
previousItemsRef={previousPointsRef}
|
|
451
|
+
isAnimationActive={isAnimationActive}
|
|
452
|
+
animationBegin={animationBegin}
|
|
453
|
+
animationDuration={animationDuration}
|
|
454
|
+
animationEasing={animationEasing}
|
|
455
|
+
onAnimationStart={handleAnimationStart}
|
|
456
|
+
onAnimationEnd={handleAnimationEnd}
|
|
457
|
+
animationInterpolateFn={animationInterpolateFn}
|
|
458
|
+
animationMatchBy={animationMatchBy}
|
|
459
|
+
shouldUpdatePreviousRef={shouldUpdatePreviousRef}
|
|
460
|
+
layout={layout}
|
|
461
|
+
>
|
|
462
|
+
{(stepData, animationElapsedTime, isEntrance) => {
|
|
463
|
+
const animationActive = isAnimating || animationElapsedTime < 1;
|
|
464
|
+
const visibleLength = animationActive
|
|
465
|
+
? getVisibleLength(animationElapsedTime, totalLength)
|
|
466
|
+
: null;
|
|
467
|
+
return (
|
|
468
|
+
<StaticCurve
|
|
469
|
+
props={props}
|
|
470
|
+
points={stepData}
|
|
471
|
+
clipPathId={clipPathId}
|
|
472
|
+
pathRef={pathRef}
|
|
473
|
+
animationElapsedTime={animationElapsedTime}
|
|
474
|
+
isAnimating={animationActive}
|
|
475
|
+
isEntrance={isEntrance}
|
|
476
|
+
visibleLength={visibleLength}
|
|
477
|
+
/>
|
|
478
|
+
);
|
|
479
|
+
}}
|
|
480
|
+
</AnimatedItems>
|
|
481
|
+
<LabelListFromLabelProp label={props.label} />
|
|
482
|
+
</LineLabelListProvider>
|
|
483
|
+
);
|
|
473
484
|
}
|
|
474
485
|
|
|
475
|
-
function RenderCurve(props: {
|
|
476
|
-
clipPathId: string;
|
|
477
|
-
props: InternalProps;
|
|
478
|
-
}) {
|
|
486
|
+
function RenderCurve(props: { clipPathId: string; props: InternalProps }) {
|
|
479
487
|
const { clipPathId } = props;
|
|
480
488
|
const previousPointsRef = useRef<ReadonlyArray<LinePointItem> | null>(null);
|
|
481
489
|
const pathRef = useRef<SVGPathElement | null>(null);
|
|
482
|
-
return
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
490
|
+
return (
|
|
491
|
+
<CurveWithAnimation
|
|
492
|
+
props={props.props}
|
|
493
|
+
clipPathId={clipPathId}
|
|
494
|
+
previousPointsRef={previousPointsRef}
|
|
495
|
+
pathRef={pathRef}
|
|
496
|
+
/>
|
|
497
|
+
);
|
|
488
498
|
}
|
|
489
499
|
|
|
490
500
|
const errorBarDataPointFormatter: ErrorBarDataPointFormatter<LinePointItem> = (
|
|
@@ -588,38 +598,40 @@ function LineImpl(props: WithIdRequired<Props>) {
|
|
|
588
598
|
const plotArea = usePlotArea();
|
|
589
599
|
const layout = useChartLayout();
|
|
590
600
|
const isPanorama = useIsPanorama();
|
|
591
|
-
const points: ReadonlyArray<LinePointItem> | undefined = useAppSelector(
|
|
592
|
-
|
|
601
|
+
const points: ReadonlyArray<LinePointItem> | undefined = useAppSelector((state) =>
|
|
602
|
+
selectLinePoints(state, xAxisId, yAxisId, isPanorama, id),
|
|
593
603
|
);
|
|
594
|
-
if (layout !== 'horizontal' && layout !== 'vertical' || points == null || plotArea == null) {
|
|
604
|
+
if ((layout !== 'horizontal' && layout !== 'vertical') || points == null || plotArea == null) {
|
|
595
605
|
// Cannot render Line in an unsupported layout
|
|
596
606
|
return null;
|
|
597
607
|
}
|
|
598
608
|
const { height, width, x: left, y: top } = plotArea;
|
|
599
|
-
return
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
609
|
+
return (
|
|
610
|
+
<LineWithState
|
|
611
|
+
{...everythingElse}
|
|
612
|
+
id={id}
|
|
613
|
+
connectNulls={connectNulls}
|
|
614
|
+
dot={dot}
|
|
615
|
+
activeDot={activeDot}
|
|
616
|
+
animateNewValues={animateNewValues}
|
|
617
|
+
animationBegin={animationBegin}
|
|
618
|
+
animationDuration={animationDuration}
|
|
619
|
+
animationEasing={animationEasing}
|
|
620
|
+
isAnimationActive={isAnimationActive}
|
|
621
|
+
hide={hide}
|
|
622
|
+
label={label}
|
|
623
|
+
legendType={legendType}
|
|
624
|
+
xAxisId={xAxisId}
|
|
625
|
+
yAxisId={yAxisId}
|
|
626
|
+
points={points}
|
|
627
|
+
layout={layout}
|
|
628
|
+
height={height}
|
|
629
|
+
width={width}
|
|
630
|
+
left={left}
|
|
631
|
+
top={top}
|
|
632
|
+
needClip={needClip}
|
|
633
|
+
/>
|
|
634
|
+
);
|
|
623
635
|
}
|
|
624
636
|
|
|
625
637
|
export function computeLinePoints({
|
|
@@ -646,8 +658,7 @@ export function computeLinePoints({
|
|
|
646
658
|
const value: number = getValueByDataKey(entry, dataKey);
|
|
647
659
|
if (layout === 'horizontal') {
|
|
648
660
|
const x = getCateCoordinateOfLine({ axis: xAxis, ticks: xAxisTicks, bandSize, entry, index });
|
|
649
|
-
const y =
|
|
650
|
-
isNullish(value) ? null : yAxis.scale.map(value);
|
|
661
|
+
const y = isNullish(value) ? null : yAxis.scale.map(value);
|
|
651
662
|
return {
|
|
652
663
|
x,
|
|
653
664
|
y: y ?? null,
|
|
@@ -655,8 +666,7 @@ export function computeLinePoints({
|
|
|
655
666
|
payload: entry,
|
|
656
667
|
};
|
|
657
668
|
}
|
|
658
|
-
const x =
|
|
659
|
-
isNullish(value) ? null : xAxis.scale.map(value);
|
|
669
|
+
const x = isNullish(value) ? null : xAxis.scale.map(value);
|
|
660
670
|
const y = getCateCoordinateOfLine({ axis: yAxis, ticks: yAxisTicks, bandSize, entry, index });
|
|
661
671
|
if (x == null || y == null) {
|
|
662
672
|
return null;
|
|
@@ -665,9 +675,8 @@ export function computeLinePoints({
|
|
|
665
675
|
});
|
|
666
676
|
// This map returns only objects or null, so Boolean removes exactly the nulls.
|
|
667
677
|
return points.filter(
|
|
668
|
-
Boolean as BooleanConstructor &
|
|
669
|
-
typeof point
|
|
670
|
-
>),
|
|
678
|
+
Boolean as BooleanConstructor &
|
|
679
|
+
((point: (typeof points)[number]) => point is NonNullable<typeof point>),
|
|
671
680
|
);
|
|
672
681
|
}
|
|
673
682
|
|
|
@@ -676,36 +685,40 @@ function LineFn<DataPointType = any, ValueAxisType = any>(
|
|
|
676
685
|
) {
|
|
677
686
|
const props = resolveDefaultProps(outsideProps, defaultLineProps);
|
|
678
687
|
const isPanorama = useIsPanorama();
|
|
679
|
-
return
|
|
680
|
-
{
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
688
|
+
return (
|
|
689
|
+
<RegisterGraphicalItemId id={props.id} type="line">
|
|
690
|
+
{(id) => (
|
|
691
|
+
<>
|
|
692
|
+
<SetLegendPayload legendPayload={computeLegendPayloadFromAreaData(props)} />
|
|
693
|
+
<SetLineTooltipEntrySettings
|
|
694
|
+
dataKey={props.dataKey}
|
|
695
|
+
data={props.data}
|
|
696
|
+
stroke={props.stroke}
|
|
697
|
+
strokeWidth={props.strokeWidth}
|
|
698
|
+
fill={props.fill}
|
|
699
|
+
name={props.name}
|
|
700
|
+
hide={props.hide}
|
|
701
|
+
unit={props.unit}
|
|
702
|
+
formatter={props.formatter}
|
|
703
|
+
tooltipType={props.tooltipType}
|
|
704
|
+
id={id}
|
|
705
|
+
/>
|
|
706
|
+
<SetCartesianGraphicalItem
|
|
707
|
+
type="line"
|
|
708
|
+
id={id}
|
|
709
|
+
data={props.data}
|
|
710
|
+
xAxisId={props.xAxisId}
|
|
711
|
+
yAxisId={props.yAxisId}
|
|
712
|
+
zAxisId={0}
|
|
713
|
+
dataKey={props.dataKey}
|
|
714
|
+
hide={props.hide}
|
|
715
|
+
isPanorama={isPanorama}
|
|
716
|
+
/>
|
|
717
|
+
<LineImpl {...props} id={id} />
|
|
718
|
+
</>
|
|
719
|
+
)}
|
|
720
|
+
</RegisterGraphicalItemId>
|
|
721
|
+
);
|
|
709
722
|
}
|
|
710
723
|
|
|
711
724
|
/**
|
|
@@ -2,8 +2,8 @@ import type { RefObject } from '../util/OctaneTypes.ts';
|
|
|
2
2
|
import type { Props as CurveProps } from '../shape/Curve.tsrx';
|
|
3
3
|
import type { ShapeAnimationProps } from '../util/types';
|
|
4
4
|
|
|
5
|
-
export type LineDrawShapeProps =
|
|
6
|
-
|
|
5
|
+
export type LineDrawShapeProps = Omit<CurveProps, 'pathRef'> &
|
|
6
|
+
ShapeAnimationProps & {
|
|
7
7
|
pathRef: RefObject<SVGPathElement | null>;
|
|
8
8
|
visibleLength?: number | null;
|
|
9
9
|
};
|
|
@@ -17,7 +17,7 @@ import { Curve } from '../shape/Curve.tsrx';
|
|
|
17
17
|
*/
|
|
18
18
|
function getTotalLength(path: SVGPathElement | null) {
|
|
19
19
|
try {
|
|
20
|
-
return path && path.getTotalLength && path.getTotalLength() || 0;
|
|
20
|
+
return (path && path.getTotalLength && path.getTotalLength()) || 0;
|
|
21
21
|
} catch {
|
|
22
22
|
return 0;
|
|
23
23
|
}
|
|
@@ -57,18 +57,17 @@ function getStrokeDasharray(length: number, totalLength: number, lines: number[]
|
|
|
57
57
|
const count = Math.floor(length / lineLength);
|
|
58
58
|
const remainLength = length % lineLength;
|
|
59
59
|
let remainLines: number[] = [];
|
|
60
|
-
for (let i = 0, sum = 0; i < normalizedLines.length;
|
|
60
|
+
for (let i = 0, sum = 0; i < normalizedLines.length; sum += normalizedLines[i] ?? 0, ++i) {
|
|
61
61
|
const lineValue = normalizedLines[i];
|
|
62
62
|
if (lineValue != null && sum + lineValue > remainLength) {
|
|
63
63
|
remainLines = [...normalizedLines.slice(0, i), remainLength - sum];
|
|
64
64
|
break;
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
const emptyLines =
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
(
|
|
71
|
-
).join(', ');
|
|
67
|
+
const emptyLines = remainLines.length % 2 === 0 ? [0, totalLength] : [totalLength];
|
|
68
|
+
return [...repeat(normalizedLines, count), ...remainLines, ...emptyLines]
|
|
69
|
+
.map((line) => line + 'px')
|
|
70
|
+
.join(', ');
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
function computeAnimatedStrokeDasharray(
|
|
@@ -77,7 +76,9 @@ function computeAnimatedStrokeDasharray(
|
|
|
77
76
|
visibleLength: number,
|
|
78
77
|
) {
|
|
79
78
|
if (userStrokeDasharray) {
|
|
80
|
-
const lines = String(userStrokeDasharray)
|
|
79
|
+
const lines = String(userStrokeDasharray)
|
|
80
|
+
.split(/[,\s]+/gim)
|
|
81
|
+
.map((num) => parseFloat(num));
|
|
81
82
|
return getStrokeDasharray(visibleLength, totalLength, lines);
|
|
82
83
|
}
|
|
83
84
|
return generateSimpleStrokeDasharray(totalLength, visibleLength);
|
|
@@ -111,9 +112,7 @@ export function LineDrawShape(props: LineDrawShapeProps) {
|
|
|
111
112
|
} else if (userStrokeDasharray != null) {
|
|
112
113
|
strokeDasharray = String(userStrokeDasharray);
|
|
113
114
|
}
|
|
114
|
-
return
|
|
115
|
-
{...curveProps}
|
|
116
|
-
|
|
117
|
-
strokeDasharray={strokeDasharray}
|
|
118
|
-
/>;
|
|
115
|
+
return (
|
|
116
|
+
<Curve {...curveProps} connectNulls={finalConnectNulls} strokeDasharray={strokeDasharray} />
|
|
117
|
+
);
|
|
119
118
|
}
|