rrag/react-stockcharts

How to set candlestick wick based on time

Closed this issue · 1 comments

Hi, amazing project.
I know that the demo code here http://rrag.github.io/stockcharts-demo/ is not open source, but can you help me with an example of how to set the candlestick wick based on time (1m, 3m etc).
Also there is an UI bug in the demo header. The setting filter dropdown has extra list element. Attaching the screenshot.
ui bug

Thanks.

rrag commented

changing the x domain of the chart to be 1 month/3 month/6 month/... has to be done by calculating the x value of the start and end candles for that period.

when user clicks on say 3 month, you have to

handlePeriodClick(period) {
  if (period === "3month") {
    const { plotData, fullData, xAccessor } = this.refs.chartCanvas.getDataInfo()
    const x2 = xAccessor(last(plotData))
    // const x1 = xAccessor(find the candle which is 3 months before x2 from fullData)
    this.setState({ xExtents: [x1, x2] })
  }
}
...
render() {
  ...
  return (
    <ChartCanvas ref={node => this.chartCanvas = node} xExtents={this.state.xExtents} ...>
      ...
  )
}