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

wrong timestamp parser when xAxis type is 'time' #13073

Closed
wlbksy opened this issue Aug 4, 2020 · 5 comments
Closed

wrong timestamp parser when xAxis type is 'time' #13073

wlbksy opened this issue Aug 4, 2020 · 5 comments
Labels
en This issue is in English not-a-bug topic: axis-time

Comments

@wlbksy
Copy link

wlbksy commented Aug 4, 2020

Version

4.8.0

Steps to reproduce

following timestamp is around 2020-08-04 10:11:00

option = {
    xAxis: {
        data: [1596507060, 1596507160, 1596507260], // second
        type : 'time'
    },
    yAxis: {},
    series: [{
        type: 'line',
        data:[220, 182, 191]
    }]
};
option = {
    xAxis: {
        data: [1596507060000, 1596507160000, 1596507260000], // milliseconds
        type : 'time'
    },
    yAxis: {},
    series: [{
        type: 'line',
        data:[220, 182, 191]
    }]
};
option = {
    xAxis: {
        data: [1596507060.000, 1596507160.000, 1596507260.000], // second with decimal
        type : 'time'
    },
    yAxis: {},
    series: [{
        type: 'line',
        data:[220, 182, 191]
    }]
};

What is expected?

According to https://echarts.apache.org/en/option.html#series-line.data, timestamp can be used as axis value when type is 'time'.
image

right parsing of x axis timestamp, timestamp is around 2020-08-04 10:11:00

What is actually happening?

  1. timestamp displays 08:00:00
  2. wrong xaxis interval
  3. wrong y axis value trending
    image
@echarts-bot
Copy link

echarts-bot bot commented Aug 4, 2020

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that you have posted enough image to demo your request. You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to dev@echarts.apache.org. Please attach the issue link if it's a technical questions.

If you are interested in the project, you may also subscribe our mail list.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added bug en This issue is in English pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Aug 4, 2020
@plainheart
Copy link
Member

It may be not a bug but an incorrect usage. xAxis.data is just for the type of category. If the type is time, it can't be specified.

Category data, available in type: 'category' axis.

When the type of xAxis is time, the time should be specified as a dimension in the series.data.

Example:

option = {
    xAxis: {
        type : 'time'
    },
    yAxis: {},
    series: [{
        type: 'line',
        data:[
            [1596507060000, 220],
            [1596507160000, 182],
            [1596507260000, 191]
        ]
    }]
};

@plainheart plainheart added not-a-bug topic: axis-time waiting-for: author and removed bug pending We are not sure about whether this is a bug/new feature. labels Aug 4, 2020
@wlbksy
Copy link
Author

wlbksy commented Aug 4, 2020

thanks.

@wlbksy
Copy link
Author

wlbksy commented Aug 4, 2020

@plainheart One more question, could we use Standard Unit like seconds as default timestamp unit, instead of javascript's milliseconds?

@plainheart
Copy link
Member

@wlbksy I'm afraid we can't. For a numerical timestamp, ECharts will parse it to a Date object by new Date(timestamp).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English not-a-bug topic: axis-time
Projects
None yet
Development

No branches or pull requests

2 participants