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

Cannot get time series example to work when using dates. #13

Closed
grady-lad opened this issue Sep 5, 2017 · 1 comment
Closed

Cannot get time series example to work when using dates. #13

grady-lad opened this issue Sep 5, 2017 · 1 comment

Comments

@grady-lad
Copy link

Hey great work on the lib, it looks really promising.

I tried to go through the example which i found here.

Which was working fine when using the dataset without any dates, but when I switched over to using the dataset with dates I received the error below which I found hard to trace.

screen shot 2017-09-05 at 23 25 50

This is the snippet I was using

// data for the graph
const data = [
    { id: 'linedata-1', color: '#00a2ce',
       data: [
            { sales: 500, timestamp: Date(2017, 7, 1) },
            { sales: 700, timestamp: Date(2017, 7, 2) },
            { sales: 0, timestamp: Date(2017, 7, 3) },
            { sales: 0, timestamp: Date(2017, 7, 4) },
            { sales: 200, timestamp: Date(2017, 7, 5) },
            { sales: 300, timestamp: Date(2017, 7, 6) },
            { sales: 500, timestamp: Date(2017, 7, 7) }
           ]
    },
]
//graph div
<XYFrame
    size={[500, 700]}
    lines={data}
    xAccessor="timestamp"
    yAccessor="sales"
    xScaleType={scaleTime()}
    lineDataAccessor="data"
    lineStyle={d => ({ stroke: d.color, fill: d.color })} />
@emeeks
Copy link
Member

emeeks commented Sep 5, 2017

If you use Date(x) it gives you a string date, what you want to use is new Date(x) which will give you a js Date object.

@emeeks emeeks closed this as completed Sep 5, 2017
alexeyraspopov pushed a commit that referenced this issue Dec 21, 2021
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