Forum Discussion

Doug7983's avatar
Doug7983
Helper II
2 years ago
Solved

Deneb | Vega-Lite tooltip issue

With much help from giammariam , I have a Deneb custom visual that is exactly what I want--except for the tooltip. Deneb is displaying the tooltip for the highlighted null data point as 0.0%. I would expect to see a blank. 

 

Here is the relevant part of the tooltip block from my spec:

{
"field": "Growth (month over year-ago month)",
"type": "quantitative",
"format": ".1%"
},

 

This works great except for the display of the last data point, which again should be blank, null, "n/a" or something of the sort.

 

Appreciate any help. 

 

 

  • Thanks Doug7983, try the following:

     

    1. In the top transform array add the following: 

     

        ,
        {
          "calculate": "isValid(datum['Growth (MoYaM)']) ? format(datum['Growth (MoYaM)'], '.1%') : ''",
          "as": "Growth (MoYaM) Tooltip"
        },
        {
          "calculate": "isValid(datum['Growth (WDC)']) ? format(datum['Growth (WDC)'], '.1%') : ''",
          "as": "Growth (WDC) Tooltip"
        }

     

    Note - if you want it to show null or n/a, replace the '' with null or 'n/a'. As it is currently, it will just be blank

     

    2. Update the tooltip to the following:

     

          "tooltip": [
            {"field": "Category", "type": "nominal"},
            {"field": "Date", "type": "temporal"},
            {"field": "Growth (MoYaM) Tooltip", "title": "Growth (MoYaM)", "type": "nominal"},
            {"field": "Growth (WDC) Tooltip", "title": "Growth (WDC)", "type": "nominal"}
          ],

     

     

     

    Let me know if this works

5 Replies

  • Hey Doug7983, thanks for the tag. Can you either send me your .pbix  (here's how), or send me the link to the post where I helped you originally? Happy to dive back into the spec and get this straight for you, I would just would need to refamiliarize myself with what I did.

  • Hey giammariam, thanks for the response. Security policies prevent me from sharing a pbix in that manner. Here's the thread where you helped me with the spec.

     

    Thank you.

    • giammariam's avatar
      giammariam
      Solution Sage

      Thanks Doug7983, try the following:

       

      1. In the top transform array add the following: 

       

          ,
          {
            "calculate": "isValid(datum['Growth (MoYaM)']) ? format(datum['Growth (MoYaM)'], '.1%') : ''",
            "as": "Growth (MoYaM) Tooltip"
          },
          {
            "calculate": "isValid(datum['Growth (WDC)']) ? format(datum['Growth (WDC)'], '.1%') : ''",
            "as": "Growth (WDC) Tooltip"
          }

       

      Note - if you want it to show null or n/a, replace the '' with null or 'n/a'. As it is currently, it will just be blank

       

      2. Update the tooltip to the following:

       

            "tooltip": [
              {"field": "Category", "type": "nominal"},
              {"field": "Date", "type": "temporal"},
              {"field": "Growth (MoYaM) Tooltip", "title": "Growth (MoYaM)", "type": "nominal"},
              {"field": "Growth (WDC) Tooltip", "title": "Growth (WDC)", "type": "nominal"}
            ],

       

       

       

      Let me know if this works