[Bug] Echarts are plotted wrongly for type time, if the time data is given with timezone offset

8yoxcaq7  于 8个月前  发布在  Echarts
关注(0)|答案(6)|浏览(265)

Version

5.2.1

https://codesandbox.io/s/area-pieces-forked-v068xl?file=/index.html

Steps to Reproduce

index.html

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Area Pieces - Apache ECharts Demo</title>
  6. <link rel="stylesheet" href="./style.css">
  7. </head>
  8. <body>
  9. <div id="chart-container"></div>
  10. <script src="https://fastly.jsdelivr.net/npm/echarts@5.3.2/dist/echarts.min.js"></script>
  11. <script src="./index.js"></script>
  12. </body>
  13. </html>

index.js

  1. var dom = document.getElementById("chart-container");
  2. var myChart = echarts.init(dom, null, {
  3. renderer: "canvas",
  4. useDirtyRect: false
  5. });
  6. var app = {};
  7. var option;
  8. option = {
  9. xAxis: {
  10. type: "time",
  11. boundaryGap: false
  12. },
  13. yAxis: {
  14. type: "value",
  15. boundaryGap: [0, "30%"]
  16. },
  17. visualMap: {
  18. type: "piecewise",
  19. show: false,
  20. dimension: 0,
  21. seriesIndex: 0,
  22. pieces: [
  23. {
  24. gt: 1,
  25. lt: 3,
  26. color: "rgba(0, 0, 180, 0.4)"
  27. },
  28. {
  29. gt: 5,
  30. lt: 7,
  31. color: "rgba(0, 0, 180, 0.4)"
  32. }
  33. ]
  34. },
  35. series: [
  36. {
  37. type: "line",
  38. smooth: 0,
  39. symbol: "none",
  40. lineStyle: {
  41. color: "#5470C6",
  42. width: 5
  43. },
  44. markLine: {
  45. symbol: ["none", "none"],
  46. label: { show: false },
  47. data: [{ xAxis: 1 }, { xAxis: 3 }, { xAxis: 5 }, { xAxis: 7 }]
  48. },
  49. areaStyle: {},
  50. data: [
  51. ["2022-05-31 17:25:00+05:30", 19],
  52. ["2022-05-31 17:30:00+05:30", 29],
  53. ["2022-05-31 17:35:00+05:30", 39],
  54. ["2022-05-31 17:40:00+05:30", 49],
  55. ["2022-05-31 17:45:00+05:30", 19],
  56. ["2022-05-31 17:50:00+05:30", 19],
  57. ["2022-05-31 17:55:00+05:30", 19],
  58. ["2022-05-31 18:00:00+05:30", 19],
  59. ["2022-05-31 18:05:00+05:30", 19],
  60. ["2022-05-31 18:10:00+05:30", 19],
  61. ["2022-05-31 18:15:00+05:30", 19]
  62. ]
  63. }
  64. ]
  65. };
  66. if (option && typeof option === "object") {
  67. myChart.setOption(option);
  68. }
  69. window.addEventListener("resize", myChart.resize);

Here in the series data, along with date and time, timezone (+05:30) is also provided.

Current Behavior

The chart plotted against the data is skewed by 30 mins.

Expected Behavior

Users expect the chart to start the plotting from 17:25 but it begins at 17:55 and is expected to end at 18:15 but ends at 18:45.

Environment

  1. - OS: Windows
  2. - Browser: Chrome
  3. - Framework: Vanilla JS, Angular@11

Any additional comments?

No response

b4qexyjb

b4qexyjb1#

As is tested, there seems not to be such bugs in 5.3.x.. Would you mind trying using 5.3.x to plot?

ulmd4ohb

ulmd4ohb2#

The reproduction link which I have provided uses the echart version 5.3.2 and the problem still exists.

Minimal reproduction link

gr8qqesn

gr8qqesn3#

Right, what I am seeing is as followed in your link:

And it doesn't look like what you've provided in the issue and looks good to me.
Is this demo what you think is problematic? Did I miss anything?

mkshixfv

mkshixfv4#

My current time zone is (GMT+5:30) Indian Standard Time. So for the data point ["2022-05-31 17:25:00+05:30", 19] the line should be plotted at 17:25, but currently, it's plotting to 17:55 which is differed by 30 minutes.

I am not sure about your time zone. So to test in your system, you can change your system's timezone to (GMT+5:30) and check the output

vkc1a9a2

vkc1a9a25#

Can confirm, we have the same issue. Our local TZ is UTC+8:00, but the data is UTC+9:30. The data is offset by 30 mins, as if it is interpretting the timezone as UTC+9.

ma8fv8wu

ma8fv8wu6#

Still exists in echarts 5.5.0

相关问题