question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

wrong timestamp parser when xAxis type is 'time'

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

12reactions
plainheartcommented, Aug 4, 2020

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]
        ]
    }]
};
0reactions
plainheartcommented, Aug 4, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

wrong timestamp parser when xAxis type is 'time' · Issue #13073
It may be not a bug but an incorrect usage. xAxis.data is just for the type of category . If the type is...
Read more >
timestamp values showing wrong on xaxis in highcharts its ...
You have passed the incorrect time in the x , current x value is 1550862788 if you passed this into to new Date(1550862788)...
Read more >
Date/Time label is shown in wrong value on X-Axis - Highcharts
Here I have an issue with the latest Highchart. I am trying to display the data in specified local time zone (for instance,...
Read more >
Formatting Dates, Time Series, and Timestamps - Plotly
Learn how to use dates, time series, and timestamp formats with Chart Studio graphs. Chart Studio is the easiest and fastest way to...
Read more >
Using a date/time scale - JpGraph
The easiest way to get a date time scale for the X-axis is to use the pre-defined " dat " scale. To be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found