# VegaLite (v0.5.1) Tooltips in Julia v1.0.2 - Can Only Do Single Field with DataFrame Source?

**URL:** <https://discourse.julialang.org/t/vegalite-v0-5-1-tooltips-in-julia-v1-0-2-can-only-do-single-field-with-dataframe-source/18079>\
**Category:** New to Julia\
**Created:** [November 27, 2018, 10:02pm UTC](https://discourse.julialang.org/t/vegalite-v0-5-1-tooltips-in-julia-v1-0-2-can-only-do-single-field-with-dataframe-source/18079 "2018-11-27T22:02:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jort](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jort](https://discourse.julialang.org/u/jort)\
**Post date:** [November 27, 2018, 10:02pm UTC](https://discourse.julialang.org/t/vegalite-v0-5-1-tooltips-in-julia-v1-0-2-can-only-do-single-field-with-dataframe-source/18079/1 "2018-11-27T22:02:46Z")

</div>

Was having good success with VegaLite until I tried tooltips. Using this dataframe:

julia\> df3  
17x2 DataFrame  
│ Row │ x1 │ x1\_1 │  
│ │ Date │ Int64 │  
├─────┼────────────┼───────┤  
│ 1 │ 2017-06-06 │ 1 │  
│ 2 │ 2017-06-28 │ 1 │  
│ 3 │ 2017-06-30 │ 1 │  
│ 4 │ 2017-07-03 │ 2 │  
│ 5 │ 2017-07-06 │ 2 │  
│ 6 │ 2017-07-21 │ 1 │  
│ 7 │ 2017-07-31 │ 1 │  
│ 8 │ 2017-08-08 │ 1 │  
│ 9 │ 2017-08-11 │ 1 │  
│ 10 │ 2017-08-16 │ 2 │  
│ 11 │ 2017-08-20 │ 1 │  
│ 12 │ 2017-08-22 │ 1 │  
│ 13 │ 2017-08-24 │ 1 │  
│ 14 │ 2017-09-12 │ 1 │  
│ 15 │ 2017-09-28 │ 1 │  
│ 16 │ 2017-10-19 │ 3 │  
│ 17 │ 2017-10-23 │ 2 │

in this @vlplot() call works - I get my plot with the single field tooltip:

```julia
@vlplot(
mark={typ="point"},
data=df3,
width=800,height=600,
encoding={
x={field="x1", typ="nominal", axis={labelAngle="-60", grid="true"}},
y={field="x1_1", typ="quantitative"},
tooltip={field="x1_1", typ="quantitative"}
})

```

If I View Source from the plot, I can modify the tooltip to add the “x1” field value by enclosing in square brackets, and call this spec with the vl macro and it works - I see both field values in the tooltip on the plot:

```julia
spec = vl"""
{
  "height": 600,
  "encoding": {
    "tooltip": **[{"field": "x1", "type": "nominal"},** {"field": "x1_1", "type": "quantitative"}**]**,
    "x": {
      "axis": {"labelAngle": "-60", "grid": "true"},
      "field": "x1",
      "type": "nominal"
    },
    "y": {"field": "x1_1", "type": "quantitative"}
  },
  "data": {
    "values": [
      {"x1": "2017-06-06", "x1_1": 1},
      {"x1": "2017-06-28", "x1_1": 1},
      {"x1": "2017-06-30", "x1_1": 1},
      {"x1": "2017-07-03", "x1_1": 2},
      {"x1": "2017-07-06", "x1_1": 2},
      {"x1": "2017-07-21", "x1_1": 1},
      {"x1": "2017-07-31", "x1_1": 1},
      {"x1": "2017-08-08", "x1_1": 1},
      {"x1": "2017-08-11", "x1_1": 1},
      {"x1": "2017-08-16", "x1_1": 2},
      {"x1": "2017-08-20", "x1_1": 1},
      {"x1": "2017-08-22", "x1_1": 1},
      {"x1": "2017-08-24", "x1_1": 1},
      {"x1": "2017-09-12", "x1_1": 1},
      {"x1": "2017-09-28", "x1_1": 1},
      {"x1": "2017-10-19", "x1_1": 3},
      {"x1": "2017-10-23", "x1_1": 2}
    ]
  },
  "width": 800,
  "mark": {"type": "point"}
}
"""

```

but if I try to use two fields in the tooltip using @vlplot I get this error:

```julia
julia> @vlplot(
       mark={typ="point"},
       data=df3,
       width=800,height=600,
       encoding={
       x={field="x1", typ="nominal", axis={labelAngle="-60", grid="true"}},
       y={field="x1_1", typ="quantitative"},
       tooltip=[{field="x1", typ="nominal"},{field="x1_1", typ="quantitative"}]
       })
ERROR: MethodError: no method matching haskey(::Array{Dict{String,Any},1}, ::Str
ing)

```

but this tooltip format works for a simple example:

```julia

@vlplot(
  data= {
    values= [
      {a= "A",b= 28}, {a= "B",b= 55}, {a= "C",b= 43},
      {a= "D",b= 91}, {a= "E",b= 81}, {a= "F",b= 53},
      {a= "G",b= 19}, {a= "H",b= 87}, {a= "I",b= 52}
    ]
  },
  mark= {type= "bar"},
  encoding= {
    x= {field= "a", type= "ordinal"},
    y= {field= "b", type= "quantitative"}, tooltip= [{field= "a", type= "ordinal"},{field= "b", type= "quantitative"}]
  })

```

the difference seems to me to be that it does not work for multiple tooltip fields when my datasource is a dataframe. Since a dataframe would be my normal source for plots, any advice is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![jort](https://avatars.discourse-cdn.com/v4/letter/j/c37758/32.png) [@jort](https://discourse.julialang.org/u/jort)\
**Post date:** [November 27, 2018, 10:05pm UTC](https://discourse.julialang.org/t/vegalite-v0-5-1-tooltips-in-julia-v1-0-2-can-only-do-single-field-with-dataframe-source/18079/2 "2018-11-27T22:05:05Z")

</div>

Argh! I tried to bold the edits I had made to the tooltip in the vl spec call…now I see that it shows “ **" instead of bolding. Please ignore the "** ” in that code block.

---

<div class="post-metadata">

**Author:** ![davidanthoff](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/davidanthoff/32/223493_2.png) [@davidanthoff](https://discourse.julialang.org/u/davidanthoff)\
**Post date:** [February 11, 2019, 5:49am UTC](https://discourse.julialang.org/t/vegalite-v0-5-1-tooltips-in-julia-v1-0-2-can-only-do-single-field-with-dataframe-source/18079/3 "2019-02-11T05:49:35Z")

</div>

This should now be fixed with [Handle tooltip encodings with an array properly by davidanthoff · Pull Request #144 · queryverse/VegaLite.jl · GitHub](https://github.com/fredo-dedup/VegaLite.jl/pull/144) merged.
