diff --git a/src/dvc_render/vega_templates.py b/src/dvc_render/vega_templates.py index a30a546..7e2f0dd 100644 --- a/src/dvc_render/vega_templates.py +++ b/src/dvc_render/vega_templates.py @@ -513,6 +513,18 @@ class SmoothLinearTemplate(Template): "field": "rev", "type": "nominal", }, + "tooltip": [ + { + "field": Template.anchor("x"), + "title": Template.anchor("x_label"), + "type": "quantitative", + }, + { + "field": Template.anchor("y"), + "title": Template.anchor("y_label"), + "type": "quantitative", + }, + ], }, "transform": [ { @@ -523,18 +535,50 @@ class SmoothLinearTemplate(Template): }, ], }, + { + "mark": {"type": "line", "opacity": 0.2}, + "encoding": { + "x": { + "field": Template.anchor("x"), + "type": "quantitative", + "title": Template.anchor("x_label"), + }, + "y": { + "field": Template.anchor("y"), + "type": "quantitative", + "title": Template.anchor("y_label"), + "scale": {"zero": False}, + }, + "color": {"field": "rev", "type": "nominal"}, + "tooltip": [ + { + "field": Template.anchor("x"), + "title": Template.anchor("x_label"), + "type": "quantitative", + }, + { + "field": Template.anchor("y"), + "title": Template.anchor("y_label"), + "type": "quantitative", + }, + ], + }, + }, { "mark": { - "type": "point", - "tooltip": {"content": "data"}, + "type": "circle", + "size": 10, + "tooltip": {"content": "encoding"}, }, "encoding": { "x": { + "aggregate": "max", "field": Template.anchor("x"), "type": "quantitative", "title": Template.anchor("x_label"), }, "y": { + "aggregate": {"argmax": Template.anchor("x")}, "field": Template.anchor("y"), "type": "quantitative", "title": Template.anchor("y_label"), diff --git a/tests/test_vega.py b/tests/test_vega.py index 583fef5..69e111e 100644 --- a/tests/test_vega.py +++ b/tests/test_vega.py @@ -44,9 +44,12 @@ def test_default_template_mark(): assert plot_content["layer"][0]["mark"] == "line" - assert plot_content["layer"][1]["mark"] == { - "type": "point", - "tooltip": {"content": "data"}, + assert plot_content["layer"][1]["mark"] == {"type": "line", "opacity": 0.2} + + assert plot_content["layer"][2]["mark"] == { + "type": "circle", + "size": 10, + "tooltip": {"content": "encoding"}, }