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

VegaLite guide - point selections #2612

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 46 additions & 0 deletions lib/livebook/notebook/learn/intro_to_vega_lite.livemd
Original file line number Diff line number Diff line change
Expand Up @@ -998,6 +998,52 @@ Vl.new()
])
```

### Single point

Highlighting a single point by clicking on it.

```elixir
Vl.new(width: 400, height: 300)
|> Vl.data_from_url("https://vega.github.io/editor/data/cars.json")
|> Vl.param("pts", select: :point)
|> Vl.mark(:point)
|> Vl.encode_field(:x, "Horsepower", type: :quantitative)
|> Vl.encode_field(:y, "Miles_per_Gallon", type: :quantitative)
|> Vl.encode(:color,
condition: [
param: "pts",
field: "Cylinders",
type: :ordinal,
scale: [scheme: "yelloworangebrown"]
],
value: :gray
)
|> Vl.encode(:size, condition: [param: "pts", empty: false, value: 200], value: 50)
```

### Multiple points

Highlighting multiple points by clicking on one of them.

```elixir
Vl.new(width: 400, height: 300)
|> Vl.data_from_url("https://vega.github.io/editor/data/cars.json")
|> Vl.param("pts", select: [type: :point, fields: ["Cylinders"]])
|> Vl.mark(:point)
|> Vl.encode_field(:x, "Horsepower", type: :quantitative)
|> Vl.encode_field(:y, "Miles_per_Gallon", type: :quantitative)
|> Vl.encode(:color,
condition: [
param: "pts",
field: "Cylinders",
type: :ordinal,
scale: [scheme: "yelloworangebrown"]
],
value: :gray
)
|> Vl.encode(:size, condition: [param: "pts", value: 200], value: 50)
```

### Map connections

An interactive visualization of connections between locations on a map.
Expand Down