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

Problem: Unable to use DataTransform in Component #6

Closed
trevorbernard opened this issue Aug 13, 2015 · 11 comments
Closed

Problem: Unable to use DataTransform in Component #6

trevorbernard opened this issue Aug 13, 2015 · 11 comments

Comments

@trevorbernard
Copy link

Console output:

DataTransform.componentWillReceiveProps
bundle.js:83508 Uncaught TypeError: Cannot read property 'config' of undefined

This is the line:

var beginIndex = _utilsUtils2["default"].getClosestItemIndexes(dataForInterval, mainChartData.config.accessors.xAccessor(plotData[0]), mainChartData.config.accessors.xAccessor).left;

This is the code:

            <ChartCanvas width={this.state.width} height={400} margin={{left: 35, right: 50, top:10, bottom: 30}}
                         data={candles}>
              <DataTransform transformType="stockscale">
                <Chart id={1}>
                  <XAxis axisAt="bottom" orient="bottom" ticks={6}/>
                  <YAxis axisAt="left" orient="left" ticks={5}/>
                  <DataSeries yAccessor={CandlestickSeries.yAccessor} xAccessor={(d) => d.date}>
                    <CandlestickSeries />
                  </DataSeries>
                </Chart>
              </DataTransform>
            </ChartCanvas>

and this is my superagent rest call:

    request
      .get(config.api_url + '/candles')
      .accept('application/json')
      .query({
        start: start.format(),
        end: end.format(),
        granularity: granularity
      })
      .end(function (err, res) {
        if (res.ok) {
          var data = res.body;
          var candles = [];
          data.map(d => {
            candles.push({
              date: new Date(d.timestamp),
              open: d.open,
              high: d.high,
              low: d.low,
              close: d.close,
              volume: d.volume
            });
          });
          this.setState({candles: candles});
        }
      }.bind(this));
@rrag
Copy link
Owner

rrag commented Aug 13, 2015

This error on the 0.1.x and fixed it in the 0.2 branch. Let me see if I can cherry pick that commit over to master.

@rrag
Copy link
Owner

rrag commented Aug 13, 2015

should be fixed now. Thanks for the defect

@trevorbernard
Copy link
Author

That fixed my issue but another one is cropped up. You can view it here: http://imgur.com/4vJoFyr

When I don't have a DataTransform it displays fine and the xaxis doesn't "tick"

This is what I see in the logs

DataTransform.componentWillReceiveProps
bundle.js:82387 Uncaught TypeError: Cannot read property 'idx' of undefined

@rrag
Copy link
Owner

rrag commented Aug 13, 2015

Can you create this in a plunkr. It appears you have intra day data. stockscale currently supports only end of day data.

@rrag
Copy link
Owner

rrag commented Aug 13, 2015

can you try to remove the xAccessor={(d) => d.date} in your DataSeries and try

like https://gist.github.com/rrag/1eac0cb78f27b31415ac#file-candlestickstockscalechart-jsx
Line 29

@trevorbernard
Copy link
Author

Ok, will try. I was AFK this morning. I'll keep you posted

@trevorbernard
Copy link
Author

http://plnkr.co/edit/2vRRTjfkxqi8FpQSfOcW?p=preview

I can change the interval from minutes, hours, days, weeks and months. I can see why some settings won't work from your previous comment. But the same thing still happens even if I choose day interval. But I can't recreate it in plunker.

@rrag
Copy link
Owner

rrag commented Aug 13, 2015

the problem with

Uncaught TypeError: Cannot read property 'idx' of undefined

is because of stockscale creating an xScale based on xAccessor of d => d.idx and DataSeries overwriting it with the xAccessor with d => d.date.

There should be a better error message or warning

@rrag
Copy link
Owner

rrag commented Aug 14, 2015

@trevorbernard any luck with the problem? let me know how I can help.

@trevorbernard
Copy link
Author

Not much luck though I didn't spend much time looking into this issue. I might spend some time looking at this over the weekend. Also, if you want, we can take this offline. My email is on my github profile.

Best,
Trev

@rrag
Copy link
Owner

rrag commented Aug 29, 2015

Does not appear to be a problem. I can use DataTransform

Also DataTransform is going away in 0.2, the docs for 0.2 are in progress, and you can see them in the v0.2 branch.

@rrag rrag closed this as completed Aug 29, 2015
ematlock0418 added a commit to ematlock0418/react-stockcharts that referenced this issue May 25, 2021
brivad pushed a commit to brivad/react-stockcharts that referenced this issue Aug 21, 2021
…e-function

feat: change adding horizontal line function
brivad pushed a commit to brivad/react-stockcharts that referenced this issue Aug 21, 2021
enthusiastdev121 added a commit to enthusiastdev121/charts_react that referenced this issue Jan 22, 2023
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

2 participants