Home Forums Chart Support Prevent Date Conversion to Local Time

Prevent Date Conversion to Local Time

Viewing 3 posts - 1 through 3 (of 3 total)
  • #61168

    Hi,

    I’m using CanvasJS to display a time series chart where all my data is in UTC. Here’s a simplified example:

    
    dataPoints: [
      { x: new Date("2025-03-30T01:40Z"), y: 50 }
    ]
    

    However, when the chart renders, the x-axis time label shows a shifted time, based on the user’s local timezone (e.g., 04:40 instead of 01:40). This becomes especially problematic around daylight saving time changes, like March 30.

    Is there a built-in way in CanvasJS to force the x-axis to treat date/timestamps as UTC (for both positioning and labeling)? Or is using timestamp + manual formatting the only way?

    Thank you!

    #61173

    @scompliance,

    By default, JavaScript Date objects are displayed based on the client’s local timezone. If you wish to format the displayed date object in UTC, you can use labelFormatter and contentFormatter to format the labels and the tooltip content, respectively.

    Please take a look at this JSFiddle for a working example of the same.

    Chart with UTC labels


    Ananya Deka
    Team CanvasJS

    #61179

    how to fix the crosshair?

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.