queryverse / VegaLite.jl

Julia bindings to Vega-Lite
Other
267 stars 39 forks source link

MethodError with mutliple fields tooltip #415

Open jfb-h opened 2 years ago

jfb-h commented 2 years ago

Specifying a tooltip via the encoding channel with multiple fields results in a method error for augment_encoding_type, which expects an AbstractDict and has no method for a Vector{AbstractDict}.

Here's an MWE:


d = [
  (x=1, y=1, l="a"),
  (x=2, y=2, l="b"),
  (x=3, y=3, l="c"),
]

@vlplot(
  :circle,
  data=d,
  x=:x,
  y=:y,
  tooltip=[
    {field=:x}, 
    {field=:y}, 
    {field=:l},
  ]
)

And this is the stacktrace:

Failed to show value:

MethodError: no method matching augment_encoding_type(::Vector{OrderedCollections.OrderedDict{String, Any}}, ::Vega.DataValuesNode)

Closest candidates are:

augment_encoding_type(!Matched::AbstractDict, ::Vega.DataValuesNode) at C:\Users\Jakob\.julia\packages\VegaLite\DBfOZ\src\vlspec.jl:17

    (::VegaLite.var"#6#9"{Vega.DataValuesNode})(::Pair{String, Vector{OrderedCollections.OrderedDict{String, Any}}})@none:0
    iterate@generator.jl:47[inlined]
    OrderedCollections.OrderedDict{String, Any}(::Base.Generator{OrderedCollections.OrderedDict{String, Any}, VegaLite.var"#6#9"{Vega.DataValuesNode}})@ordered_dict.jl:27
    (::VegaLite.var"#5#8"{Vega.DataValuesNode})(::Pair{String, OrderedCollections.OrderedDict{String, Any}})@none:0
    iterate@generator.jl:47[inlined]
    OrderedCollections.OrderedDict{String, Any}(::Base.Generator{OrderedCollections.OrderedDict{String, Any}, VegaLite.var"#5#8"{Vega.DataValuesNode}})@ordered_dict.jl:27
    add_encoding_types(::OrderedCollections.OrderedDict{String, Any}, ::Nothing)@vlspec.jl:45
    add_encoding_types(::OrderedCollections.OrderedDict{String, Any})@vlspec.jl:42
    our_json_print(::IOContext{IOBuffer}, ::VegaLite.VLSpec)@vlspec.jl:58
    var"#writehtml_partial_script#47"(::String, ::typeof(VegaLite.writehtml_partial_script), ::IOContext{IOBuffer}, ::VegaLite.VLSpec)@render.jl:174
    writehtml_partial_script@render.jl:155[inlined]
    show(::IOContext{IOBuffer}, ::MIME{Symbol("text/html")}, ::VegaLite.VLSpec)@show.jl:128
    show_richest(::IOContext{IOBuffer}, ::Any)@PlutoRunner.jl:1032
    var"#sprint_withreturned#54"(::IOContext{Base.DevNull}, ::Int64, ::typeof(Main.PlutoRunner.sprint_withreturned), ::Function, ::VegaLite.VLSpec)@PlutoRunner.jl:967
    format_output_default(::Any, ::Any)@PlutoRunner.jl:862
    var"#format_output#42"(::IOContext{Base.DevNull}, ::typeof(Main.PlutoRunner.format_output), ::Any)@PlutoRunner.jl:879
    formatted_result_of(::Base.UUID, ::Bool, ::Vector{String}, ::Nothing, ::Module)@PlutoRunner.jl:785
    top-level scope@none:1

this was on master.

Love the package!