Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 43 additions & 35 deletions src/dvc_render/vega_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,10 @@ class BarHorizontalSortedTemplate(Template):
"title": Template.anchor("y_label"),
"sort": "-x",
},
"yOffset": {"field": "rev"},
"color": {
"field": "rev",
"type": "nominal",
},
"yOffset": {"field": "dvc_id"},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
}

Expand All @@ -143,11 +142,10 @@ class BarHorizontalTemplate(Template):
"type": "nominal",
"title": Template.anchor("y_label"),
},
"yOffset": {"field": "rev"},
"color": {
"field": "rev",
"type": "nominal",
},
"yOffset": {"field": "dvc_id"},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
}

Expand All @@ -158,7 +156,11 @@ class ConfusionTemplate(Template):
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"values": Template.anchor("data")},
"title": Template.anchor("title"),
"facet": {"field": "rev", "type": "nominal"},
"facet": {
"field": "dvc_id",
"type": "nominal",
"header": {"title": False},
},
"spec": {
"transform": [
{
Expand All @@ -167,13 +169,13 @@ class ConfusionTemplate(Template):
},
{
"impute": "xy_count",
"groupby": ["rev", Template.anchor("y")],
"groupby": ["dvc_id", Template.anchor("y")],
"key": Template.anchor("x"),
"value": 0,
},
{
"impute": "xy_count",
"groupby": ["rev", Template.anchor("x")],
"groupby": ["dvc_id", Template.anchor("x")],
"key": Template.anchor("y"),
"value": 0,
},
Expand Down Expand Up @@ -268,7 +270,11 @@ class NormalizedConfusionTemplate(Template):
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {"values": Template.anchor("data")},
"title": Template.anchor("title"),
"facet": {"field": "rev", "type": "nominal"},
"facet": {
"field": "dvc_id",
"type": "nominal",
"header": {"title": False},
},
"spec": {
"transform": [
{
Expand All @@ -277,13 +283,13 @@ class NormalizedConfusionTemplate(Template):
},
{
"impute": "xy_count",
"groupby": ["rev", Template.anchor("y")],
"groupby": ["dvc_id", Template.anchor("y")],
"key": Template.anchor("x"),
"value": 0,
},
{
"impute": "xy_count",
"groupby": ["rev", Template.anchor("x")],
"groupby": ["dvc_id", Template.anchor("x")],
"key": Template.anchor("y"),
"value": 0,
},
Expand Down Expand Up @@ -397,10 +403,9 @@ class ScatterTemplate(Template):
"type": "quantitative",
"title": Template.anchor("y_label"),
},
"color": {
"field": "rev",
"type": "nominal",
},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
}

Expand Down Expand Up @@ -428,10 +433,9 @@ class ScatterJitterTemplate(Template):
"field": Template.anchor("y"),
"title": Template.anchor("y_label"),
},
"color": {
"field": "rev",
"type": "nominal",
},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
"xOffset": {"field": "randomX", "type": "quantitative"},
"yOffset": {"field": "randomY", "type": "quantitative"},
},
Expand Down Expand Up @@ -460,7 +464,10 @@ class SmoothLinearTemplate(Template):
],
"layer": [
{
"mark": "line",
"mark": {
"type": "line",
"fill": "transparent",
},
"encoding": {
"x": {
"field": Template.anchor("x"),
Expand All @@ -473,16 +480,15 @@ class SmoothLinearTemplate(Template):
"title": Template.anchor("y_label"),
"scale": {"zero": False},
},
"color": {
"field": "rev",
"type": "nominal",
},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
"transform": [
{
"loess": Template.anchor("y"),
"on": Template.anchor("x"),
"groupby": ["rev", "filename", "field", "filename::field"],
"groupby": ["dvc_rev", "dvc_filename", "dvc_field"],
"bandwidth": {"signal": "smooth"},
},
],
Expand All @@ -504,7 +510,9 @@ class SmoothLinearTemplate(Template):
"title": Template.anchor("y_label"),
"scale": {"zero": False},
},
"color": {"field": "rev", "type": "nominal"},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
},
],
Expand All @@ -527,6 +535,7 @@ class SimpleLinearTemplate(Template):
"mark": {
"type": "line",
"tooltip": {"content": "data"},
"fill": "transparent",
},
"encoding": {
"x": {
Expand All @@ -540,10 +549,9 @@ class SimpleLinearTemplate(Template):
"title": Template.anchor("y_label"),
"scale": {"zero": False},
},
"color": {
"field": "rev",
"type": "nominal",
},
"color": {"field": "dvc_rev", "type": "nominal"},
"strokeDash": {"field": "dvc_filename", "type": "nominal"},
"shape": {"field": "dvc_field", "type": "nominal"},
},
}

Expand Down
2 changes: 1 addition & 1 deletion tests/test_vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_default_template_mark():

plot_content = json.loads(VegaRenderer(datapoints, "foo").partial_html())

assert plot_content["layer"][0]["mark"] == "line"
assert plot_content["layer"][0]["mark"] == {"type": "line", "fill": "transparent"}

assert plot_content["layer"][1]["mark"] == {
"type": "point",
Expand Down