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

feat: support datum in encoding #6150

Merged
merged 9 commits into from
Mar 25, 2020
Merged

feat: support datum in encoding #6150

merged 9 commits into from
Mar 25, 2020

Conversation

kanitw
Copy link
Member

@kanitw kanitw commented Mar 24, 2020

Replaces #4201

Fix #1601

Merge #6149 first!

TODO

  • check all
    • isFieldDef

    • getFieldDef

    • model.fieldDef

    • hasConditionalFieldDef

    • channelHasField

    • forEachFieldDef

    • reduceFieldDef

    • support datum for lat/long

    • repeat in datum

Examples

  • simple layer datum
  • repeat_layer
  • layer_bar_annotations

Later

@domoritz

This comment has been minimized.

@kanitw

This comment has been minimized.

@domoritz
Copy link
Member

domoritz commented Mar 25, 2020

I also just found the code to patch :-P

@domoritz
Copy link
Member

We are off the domain line by half a pixel here but I guess that's a known issue.

Screen Shot 2020-03-25 at 13 59 15

@kanitw
Copy link
Member Author

kanitw commented Mar 25, 2020

We are off the domain line by half a pixel here but I guess that's a known issue.

Screen Shot 2020-03-25 at 13 59 15

Yeah, and I'd rather suggest people to use conditional gridColor for the zero baseline. So I think that's not the point of this PR.

@domoritz
Copy link
Member

In the example above, we are drawing the rule for each item in the dataset. Can we optimize the spec when there is not field encoding?

Screen Shot 2020-03-25 at 14 02 11

@domoritz
Copy link
Member

It's actually more than an optimization if we use opacity for the rule.

@domoritz
Copy link
Member

domoritz commented Mar 25, 2020

Actually, the right spec is

{
  "$schema": "https://vega.github.io/schema/vega-lite/v4.json",
  "layer": [
    {
      "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": "line",
      "encoding": {
        "x": {"field": "a", "type": "ordinal"},
        "y": {"field": "b", "type": "quantitative"}
      }
    },
    {"data": {"values": [{}]}, "mark": "rule", "encoding": {"y": {"datum": 0}}}
  ]
}

src/channeldef.ts Outdated Show resolved Hide resolved
@domoritz domoritz merged commit 60d6e44 into master Mar 25, 2020
@domoritz domoritz deleted the kw/datum branch March 25, 2020 21:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encoding's datum for constant values in data domain that still pass through scales
2 participants