MakieOrg / Makie.jl

Interactive data visualizations and plotting in Julia
https://docs.makie.org/stable
MIT License
2.37k stars 302 forks source link

DateTime support for band #3932

Open ValentinKaisermayer opened 3 months ago

ValentinKaisermayer commented 3 months ago
using Dates
using GLMakie
t = range(DateTime(2020); step=Hour(1), length=1000)
y = cumsum(randn(1000))

fig = Figure()
ax = Axis(fig[1,1])
lines!(t, y) # <-- works
band!(t, zeros(1000), y) # <-- does not
fig
milankl commented 1 month ago

Also hitting this. The error is

Plotting unit Point{2, Float64} into axis with type DateTime not supported.

Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] convert_dim_observable(conversion::Makie.DateTimeConversion, values::Observable{Vector{Point{2, Float64}}}, deregister::Vector{Observables.ObserverFunction})
    @ Makie ~/.julia/packages/Makie/rEu75/src/dim-converts/dates-integration.jl:79
  [3] convert_dim_observable(conversions::Makie.DimConversions, dim::Int64, value::Observable{Vector{Point{2, Float64}}}, deregister::Vector{Observables.ObserverFunction})
    @ Makie ~/.julia/packages/Makie/rEu75/src/dim-converts/dim-converts.jl:198
  [4] (::Makie.var"#191#193"{UnionAll, NoConversion, Tuple{Observable{Vector{Point{2, Float64}}}, Observable{Vector{GeometryBasics.NgonFace{3, GeometryBasics.OffsetInteger{-1, UInt32}}}}}, Vector{Observables.ObserverFunction}, Makie.DimConversions})(i::Int64)
...

So I'm wondering whether one just needs to define

function Makie.convert_dim_observable(conversion::Makie.DateTimeConversion, values::Observable{Vector{Point{2, Float64}}}, deregister::Vector{Observables.ObserverFunction})

or what's probably called within the corresponding convert_dim_value method. Any hint appreciated! Given a point is a new type, it's probably just about to pass on the conversion to its elements. Any advice appreciated!