Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format of null data in tooltips. #6417

Closed
PhML opened this issue Apr 27, 2020 · 2 comments · Fixed by vega/vega#3926
Closed

Format of null data in tooltips. #6417

PhML opened this issue Apr 27, 2020 · 2 comments · Fixed by vega/vega#3926
Assignees
Labels
Milestone

Comments

@PhML
Copy link

PhML commented Apr 27, 2020

In the following example, I use a tooltip to display underlying data but I have troubles to have consistent behavior when displaying null values of different types.

Indeed, while missing quantitative data leads to display NaN (no c key in third value of values), temporal data is interpreted as zero (Jan 01, 1970 00:00:00). I expect to display null values for temporal data as null or NaT to be consistent with NaN display of quantitative data.

When values are explicitly null, behavior is consistent as both quantitative and temporal data are rendered as respectively 0 and Jan 01, 1970 00:00:00.

But I rather like to display null or N/A in such case. So having a way to specify how to handle null values. (Please, tell me how if it is possible).

{
  "data": {
    "values": [
      {
        "a": "A",
        "b": 28,
        "c": null,
        "d": null
      },
      {
        "a": "B",
        "b": 55,
        "c": "2020-04-27T14:15:18.586949+00:00",
        "d": 1000
      },
      {
        "a": "C",
        "b": 43
      }
    ]
  },
  "mark": "bar",
  "encoding": {
    "x": {
      "field": "a",
      "type": "ordinal"
    },
    "y": {
      "field": "b",
      "type": "quantitative"
    },
    "tooltip": [
      {
        "field": "a",
        "type": "ordinal"
      },
      {
        "field": "b",
        "type": "quantitative"
      },
      {
        "field": "c",
        "type": "temporal",
        "title": "c",
        "timeUnit": "yearmonthdatehoursminutesseconds",
        "scale": {
          "type": "utc"
        }
      },
      {
        "field": "d",
        "type": "quantitative"
      }
    ]
  }
}

Open the Chart in the Vega Editor

@PhML PhML added the Bug 🐛 label Apr 27, 2020
@kanitw kanitw added the P3 Should be fixed at some point label Apr 27, 2020
@kanitw kanitw self-assigned this Apr 27, 2020
@kanitw kanitw added P2 Important Issues that should be fixed soon and removed P3 Should be fixed at some point labels Apr 27, 2020
@kanitw
Copy link
Member

kanitw commented May 2, 2020

We need to adjust formatSignalRef to handle this consistently, while respecting config.mark.invalid.

@kanitw
Copy link
Member

kanitw commented Jul 1, 2022

@kanitw kanitw added P1 Critical -- to fix ASAP and removed P2 Important Issues that should be fixed soon labels Jul 1, 2022
@kanitw kanitw added this to the Null handling milestone May 9, 2024
kanitw added a commit that referenced this issue May 20, 2024
…valid data (e.g., nulls, NaNs) (#9342)

- Add more spec options for handling invalid data 
  - extend `mark.invalid`
  - add new `config.scale.invalid`

- See [docs's pdf file from
invalid.md](https://github.com/vega/vega-lite/files/15329038/Modes.for.Handling.Invalid.Data._.Vega-Lite.pdf)
or the actual doc for explanation of the behavior. (Given the complexity
of the PR, reviewers should check out the branch and test the spec
locally.)

refactor:
- Adjust how we generate rules for invalid data to handle these options,
per channel type.
    - data's invalid filter
    - `defined` encoding (for breaking paths)

- Make wrapCondition accept invalidValueRef for "include" mode.
- Remove the hidden/screen "hide" mode for invalid data (Given this is a
hidden feature, it's not a breaking change.)## PR Description

bug fixes:
- fix #8254  -- correctly place invalid point as zero, when included. 

Known issues / Follow up items: 
- Tooltip doesn't show null correctly
(#6417) -- I'll fix this
separately in a follow up PR
- Should Vega-lite always include color for invalid by default?
(#9351)


## Checklist

Tests:
- [x] Integration tests -- added a bunch of examples
- [x] Unit tests (in progress) -- I'll re-review the code and add more
unit tests.

Docs: 
- [x] Has documentation under `site/docs/` + examples.

---------

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
kanitw added a commit to vega/vega that referenced this issue May 23, 2024
Make default vega format null as "null".  

Context: I was trying to fix this in Vega-Lite, but then realize that it
seems instead of add conditional expression *everywhere* in Vega-Lite.
Better fix at the Vega level.

- partially fix vega/vega-lite#6417 (We'll
have to remove unnecessary expression that Vega-Lite generates if Vega
already formats `null`.

## Number Format

Before
([spec](https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQAEySYUqUAwBOgtCrVICCNsRpwIUmfIC+S5NoDW+nGxqzMikHFlQ2y9zI0UAAPYJAAM3NBZX0ASQBZABEAIQACACU1QK9MAE8cOH0ARwYkDzps0hA7EDzwqLgY-Qy2bB80gBU2ZEw2C0zs2SClfMKSsor1TBpq2r9BNm1wv1kAmblwzAtPdFVMBgQAbQByRNTBmeGTgF00gF5HtNkGQUE0gB8PtP3D09b2rIuj01P0IJdArcHk8Xm8vMQkIIGEV0ABiJAYmo2eZyKJBTQgBzOAnuBHCWKoWGCUZsNiCGY4NCYbTI7E2IA)):

<img width="414" alt="image"
src="https://github.com/vega/vega/assets/111269/122db8fe-3613-41d5-9dd9-a878fa4d8188">


After:

<img width="340" alt="image"
src="https://github.com/vega/vega/assets/111269/ad213932-0ed7-4de3-9cb3-2e2c7d2af214">


## Time Format

Before
([spec](https://vega.github.io/editor/#/url/vega-lite/N4IgJAzgxgFgpgWwIYgFwhgF0wBwqgegIDc4BzJAOjIEtMYBXAI0poHsDp5kTykBaADZ04JAKyUAVhDYA7EABoQAEySYUqUMSSCGcCGgDaoDSABSSWQAIAjAqsAmAAwvFIJmgcAOAL4KTaOaWjvbOrkoeqGJifgHoFtYAzKEuTm6RsgyCgrEgpglWACwp4e5oAGwx-nmBBWIlaRFohYm5GpnZTVFOPgC6fiBwslBsyjSyZGigAB5TIJg0CHAAqrJ0gQCecEgATghy9KqYcG4AZjRwgsqBKEqYGzgn6McIOGw7Om5I0zQGmiCnd7ITCBACkyisoI8PgGGzm50u13QHjuDyeIAAjgxLAt1AtSCAYUpBEgtjsjKBkDsANZze6PQJvcYgpTjbTCJEgCAwNgAdzcmDYbEECxwaEwOz0AyGIzGEzms3+CyWq3W6C2u32skOahOSgRVxuArRgRebw+gkJRMpu1pSpNzzg0xZIDZOhonO5fPSSAgl3G6KYbGwbAQhKUMtG40mSqdIKVixWa3jIA1ewOMCOeoBF0N6Fu8wd80Q5s+Sm+v3hQLUYIhUKtMP6QA)):

<img width="273" alt="image"
src="https://github.com/vega/vega/assets/111269/68cc8d2e-0c80-4fd4-b4a9-3ce29d5b05b1">

After:


![image](https://github.com/vega/vega/assets/111269/176b4b02-62d8-467e-a400-d009ed25be30)

---------

Co-authored-by: Dominik Moritz <domoritz@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants