Skip to content

PlotlyJS direct plot() fails with ZonedDateTime x-axis, but add_trace!() with Scatter works #520

@MChristianBF

Description

@MChristianBF

Describe the bug
Direct plotting with ZonedDateTime as x-values fails, while the same data works when added via add_trace! and Scatter.

using Dates
using TimeZones
using PlotlyJS

# 1) Create vectors: 10 random y-values, DateTime x-vector, and ZonedDateTime x-vector.
n = 10
YVector = rand(n)
TimeVector = collect(now():Hour(1):now() + Hour(n - 1))
TimeVectorZoned = ZonedDateTime.(TimeVector, Ref(localzone()))

# 2) Baseline: DateTime works with direct plot call.
plot(TimeVector, YVector, mode="lines+markers", name="DateTime direct plot")

# 3) Repro: ZonedDateTime direct plot call (known issue).
plot(TimeVectorZoned, YVector, mode="lines+markers", name="ZonedDateTime direct plot")

# 4) Workaround: add_trace! with scatter using the same zoned x-vector works.
p_add_trace = Plot()
add_trace!(p_add_trace, scatter(
	x=TimeVectorZoned,
	y=YVector,
	mode="lines+markers",
	name="ZonedDateTime via add_trace!"
))
display(p_add_trace)

Version info
Julia Version 1.12.5
Commit 5fe89b8ddc (2026-02-09 16:05 UTC)
Build Info:
Official https://julialang.org release
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: 8 × 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
WORD_SIZE: 64
LLVM: libLLVM-18.1.7 (ORCJIT, tigerlake)
GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)
Environment:
JULIA_EDITOR = code
JULIA_VSCODE_REPL = 1

[336ed68f] CSV v0.10.16
[aaaa29a8] Clustering v0.15.8
[a93c6f00] DataFrames v1.8.1
[38e38edf] GLM v1.9.3
[cd3eb016] HTTP v1.11.0
[87dc4568] HiGHS v1.23.0
[033835bb] JLD2 v0.6.4
⌅ [682c06a0] JSON v0.21.4
[4076af6c] JuMP v1.30.0
[c03570c3] Memoize v0.4.4
[f0f68f2c] PlotlyJS v0.18.17
[92933f4c] ProgressMeter v1.11.0
[10745b16] Statistics v1.11.1
[f269a46b] TimeZones v1.22.2
[fdbf4ff8] XLSX v0.11.2
[ade2ca70] Dates v1.11.0
Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use status --outdated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions