Skip to content

Commit

Permalink
Revert "feat: allow option to invert lines"
Browse files Browse the repository at this point in the history
This reverts commit 9093a91.
  • Loading branch information
WadhahEssam committed Nov 13, 2023
1 parent ea04c1d commit b1965b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 38 deletions.
4 changes: 0 additions & 4 deletions src/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ 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,
};
};
function LineChart({
Expand Down
50 changes: 22 additions & 28 deletions src/SvgPath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import React, {
ReactElement,
useCallback,
useEffect,
useMemo,
} from 'react';
import {
interpolate,
Expand Down Expand Up @@ -88,35 +87,30 @@ 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) => {
if (line?.data) {
return (
<MemoizedLineComponent
key={`${index}`}
line={line}
allData={allData}
svgHeight={svgHeight}
svgWidth={svgWidth}
activeIndex={activeIndex}
activeTouch={activeTouch}
identifier={`${index}`}
extraConfig={extraConfig}
onPointChange={index === 0 ? onPointChange : undefined}
/>
);
}
// @ts-ignore
return <View key={`${index}`} />;
})}
{lines
.filter((line) => line?.data)
.map((line, index) => {
if (line?.data) {
return (
<MemoizedLineComponent
key={`${index}`}
line={line}
allData={allData}
svgHeight={svgHeight}
svgWidth={svgWidth}
activeIndex={activeIndex}
activeTouch={activeTouch}
identifier={`${index}`}
extraConfig={extraConfig}
onPointChange={index === 0 ? onPointChange : undefined}
/>
);
}
// @ts-ignore
return <View key={`${index}`} />;
})}
</>
);
};
Expand Down
1 change: 0 additions & 1 deletion src/defaults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const EXTRA_CONFIG = {
calculateChartYAxisMinMax: undefined,
activeOffsetX: [0, 0],
animationConfig: undefined,
invertLineOrder: false,
};

export const LINE_CHART = {
Expand Down
5 changes: 0 additions & 5 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,6 @@ export interface ExtraConfig {
* Animation configuration
*/
animationConfig?: AnimationConfig;
/**
* Invert the order of the lines (useful when you want to show the last line on top)
* @default false
*/
invertLineOrder?: boolean;
}

/**
Expand Down

0 comments on commit b1965b6

Please sign in to comment.