From 59776c310142f30ac2cdc97abded7732a3182550 Mon Sep 17 00:00:00 2001 From: David Bacci <86846675+PBI-David@users.noreply.github.com> Date: Thu, 8 Feb 2024 17:39:42 +0000 Subject: [PATCH] docs: Add dynamic axis example (#9253) --- examples/specs/line_dynamic_axis.vl.json | 29 ++++++++++++++++++++++++ site/_data/examples.json | 4 ++++ 2 files changed, 33 insertions(+) create mode 100644 examples/specs/line_dynamic_axis.vl.json diff --git a/examples/specs/line_dynamic_axis.vl.json b/examples/specs/line_dynamic_axis.vl.json new file mode 100644 index 0000000000..cc5e2c7181 --- /dev/null +++ b/examples/specs/line_dynamic_axis.vl.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "description": "Vega-Lite computes the minimum and maximum axes values automatically but this can be made more dynamic by using params to produce axes which are +/- 20% of the minimum and maximum values in the dataset.", + "data": { + "values": [ + {"x": 1, "y": 11}, + {"x": 2, "y": 10}, + {"x": 3, "y": 11.23}, + {"x": 4, "y": 10}, + {"x": 5, "y": 9.5}, + {"x": 6, "y": 10}, + {"x": 7, "y": 10} + ] + }, + "params": [ + {"name": "extents", "expr": "extent(pluck(data('source_0'), 'y'))"}, + {"name": "min", "expr": "extents[0] * 0.8"}, + {"name": "max", "expr": "extents[1] * 1.2"} + ], + "mark": {"type": "line", "point": true}, + "encoding": { + "x": {"field": "x", "type": "quantitative"}, + "y": { + "field": "y", + "type": "quantitative", + "scale": {"domain": {"expr": "[min,max]"}} + } + } +} diff --git a/site/_data/examples.json b/site/_data/examples.json index a04bc1af32..36a2e1d521 100644 --- a/site/_data/examples.json +++ b/site/_data/examples.json @@ -520,6 +520,10 @@ { "name": "layer_point_line_loess", "title": "Loess Regression" + }, + { + "name": "line_dynamic_axis", + "title": "Dynamic Minimum and Maximum Y Axis" } ] },