Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yAccessor for CandleStickSeries not working as expected #594

Closed
imperfectlogic opened this issue Oct 17, 2021 · 1 comment · Fixed by #595
Closed

yAccessor for CandleStickSeries not working as expected #594

imperfectlogic opened this issue Oct 17, 2021 · 1 comment · Fixed by #595

Comments

@imperfectlogic
Copy link

imperfectlogic commented Oct 17, 2021

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch @react-financial-charts/[email protected] for the project I'm working on.

I found that using a custom yAccessor on the CandlestickSeries was not drawing any of the expected candles. Upon some investigation I found that the yAccessor was not being used in the initial filter which was excluding data due to it not having the 'close' property on the main data object.

Here is the diff that solved my problem:

diff --git a/node_modules/@react-financial-charts/series/src/CandlestickSeries.tsx b/node_modules/@react-financial-charts/series/src/CandlestickSeries.tsx
index 21729c4..c6158c1 100644
--- a/node_modules/@react-financial-charts/series/src/CandlestickSeries.tsx
+++ b/node_modules/@react-financial-charts/series/src/CandlestickSeries.tsx
@@ -136,7 +136,13 @@ export class CandlestickSeries extends React.Component<CandlestickSeriesProps> {
         const offset = trueOffset > 0.7 ? Math.round(trueOffset) : Math.floor(trueOffset);
 
         return plotData
-            .filter((d) => d.close !== undefined)
+            .filter((d) => {
+                const ohlc = yAccessor(d);
+                if (ohlc === undefined) {
+                    return false;
+                }
+                return true;
+            })
             .map((d) => {
                 const ohlc = yAccessor(d);
                 if (ohlc === undefined) {
markmcdowell added a commit that referenced this issue Oct 17, 2021
Filter was hardcoded to use the close instead of yAccessor.

Fixes #594
markmcdowell added a commit that referenced this issue Oct 17, 2021
Filter was hardcoded to use the close instead of yAccessor.

Fixes #594
@markmcdowell
Copy link
Collaborator

Fixed in v1.3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants