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

access candle data from renderRect #192

Open
TobiasGrothmann opened this issue Jan 15, 2025 · 3 comments
Open

access candle data from renderRect #192

TobiasGrothmann opened this issue Jan 15, 2025 · 3 comments

Comments

@TobiasGrothmann
Copy link

TobiasGrothmann commented Jan 15, 2025

Hi there,

I'm trying to use useCandleData inside of renderRect. Something like this:

<CandlestickChart.Provider data={data}>
    <CandlestickChart>
        <CandlestickChart.Candles
          renderRect={customRect}
          useAnimations={false}
        />
...
const customRect = ({
  useAnimations,
  height,
  opacity,
  width,
  y,
  ...rest
}: RectProps & { useAnimations: boolean }) => {
  const {
    value: { timestamp, open, high, low, close },
  } = CandlestickChart.useCandleData()
  const { currentX, currentY, data, domain, step } = CandlestickChart.useChart()
  
  ...
  
  return someCSV
})

CandlestickChart.useChart() seems to work as expected – but CandlestickChart.useCandleData() doesn't.

  1. The code described in the docs
const { timestamp, open, high, low, close } = CandlestickChart.useCandleData();

doesn't work. Instead it has to be

const {
  value: { timestamp, open, high, low, close },
} = CandlestickChart.useCandleData()
  1. I am only getting -1 for all values (timestamp, open, high, low and close)
@TobiasGrothmann
Copy link
Author

TobiasGrothmann commented Jan 15, 2025

Also, currentX.value and currentY.value from CandlestickChart.useChart() are always -1.

@TobiasGrothmann
Copy link
Author

related #180

@TobiasGrothmann
Copy link
Author

Just found out here that currentX is meant to be the currently selected candle. It's kind of hard to find documentation about it.

Could we add some arguments to the renderRect function to be able to render candles differently depending on the data?

@TobiasGrothmann TobiasGrothmann changed the title using CandlestickChart.useCandleData inside of renderRect access candle data from of renderRect Jan 15, 2025
@TobiasGrothmann TobiasGrothmann changed the title access candle data from of renderRect access candle data from renderRect Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant