diff --git a/src/LineChart.tsx b/src/LineChart.tsx index d42642e..75cb94c 100644 --- a/src/LineChart.tsx +++ b/src/LineChart.tsx @@ -43,10 +43,10 @@ const getExtraConfig = (extraConfig: ExtraConfig): ExtraConfig => { activeOffsetX: extraConfig.activeOffsetX || EXTRA_CONFIG.activeOffsetX, animationConfig: extraConfig.animationConfig || EXTRA_CONFIG.animationConfig, - invertLineOrder: - extraConfig.invertLineOrder !== undefined - ? extraConfig.invertLineOrder - : EXTRA_CONFIG.invertLineOrder, + leadLineIndex: + extraConfig.leadLineIndex !== undefined + ? extraConfig.leadLineIndex + : EXTRA_CONFIG.leadLineIndex, }; }; function LineChart({ diff --git a/src/SvgPath.tsx b/src/SvgPath.tsx index 88fb9c7..260cb59 100644 --- a/src/SvgPath.tsx +++ b/src/SvgPath.tsx @@ -4,7 +4,6 @@ import React, { ReactElement, useCallback, useEffect, - useMemo, } from 'react'; import { interpolate, @@ -88,16 +87,9 @@ const SvgPath = ({ return activeIndexLocal; }, [activeTouchX, lines[0]?.data]); - const checkedLines = useMemo(() => { - if (extraConfig?.invertLineOrder) { - return [...lines].reverse(); - } - return lines; - }, [lines, extraConfig?.invertLineOrder]); - return ( <> - {checkedLines.map((line, index) => { + {lines.map((line, index) => { if (line?.data) { return ( ); } diff --git a/src/defaults.tsx b/src/defaults.tsx index e310c12..e09f233 100644 --- a/src/defaults.tsx +++ b/src/defaults.tsx @@ -29,7 +29,7 @@ export const EXTRA_CONFIG = { calculateChartYAxisMinMax: undefined, activeOffsetX: [0, 0], animationConfig: undefined, - invertLineOrder: false, + leadLineIndex: 0, }; export const LINE_CHART = { diff --git a/src/types.ts b/src/types.ts index 3d96a59..a8460aa 100644 --- a/src/types.ts +++ b/src/types.ts @@ -222,10 +222,10 @@ export interface ExtraConfig { */ animationConfig?: AnimationConfig; /** - * Invert the order of the lines (useful when you want to show the last line on top) - * @default false + * The line where the onPointFocus & activePointSharedValue will be called on + * @default 0 */ - invertLineOrder?: boolean; + leadLineIndex?: number; } /**