Skip to content
Open
Show file tree
Hide file tree
Changes from 13 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
910 changes: 908 additions & 2 deletions build/vega-lite-schema.json

Large diffs are not rendered by default.

Binary file added examples/compiled/layer_text_background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions examples/compiled/layer_text_background.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
225 changes: 225 additions & 0 deletions examples/compiled/layer_text_background.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
{
"$schema": "https://vega.github.io/schema/vega/v6.json",
"description": "Google's stock price over time.",
"background": "white",
"padding": 5,
"width": 500,
"height": 300,
"style": ["cell", "view"],
"data": [
{
"name": "source_0",
"url": "data/stocks.csv",
"format": {"type": "csv", "parse": {"date": "date"}},
"transform": [{"type": "filter", "expr": "datum.symbol==='GOOG'"}]
},
{
"name": "data_1",
"source": "source_0",
"transform": [
{"type": "filter", "expr": "+datum.price === 286"},
{
"type": "filter",
"expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]))) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
]
},
{
"name": "data_2",
"source": "source_0",
"transform": [
{"type": "filter", "expr": "+datum.price === 707"},
{
"type": "filter",
"expr": "(isDate(datum[\"date\"]) || (isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]))) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
]
}
],
"marks": [
{
"name": "layer_0_marks",
"type": "line",
"style": ["line"],
"sort": {"field": "x"},
"from": {"data": "source_0"},
"encode": {
"update": {
"stroke": {"value": "#4c78a8"},
"description": {
"signal": "\"date: \" + (timeFormat(datum[\"date\"], \"%b %d, %Y\")) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"defined": {
"signal": "isValid(datum[\"date\"]) && isFinite(+datum[\"date\"]) && isValid(datum[\"price\"]) && isFinite(+datum[\"price\"])"
}
}
}
},
{
"name": "layer_1_layer_0_marks",
"type": "text",
"style": ["text"],
"from": {"data": "data_1"},
"encode": {
"update": {
"stroke": {"value": "white"},
"strokeWidth": {"value": 4},
"fontWeight": {"value": "bold"},
"fill": {"value": "black"},
"description": {
"signal": "\"date: \" + (timeFormat(datum[\"date\"], \"%b %d, %Y\")) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"text": {
"signal": "isValid(datum[\"price\"]) ? datum[\"price\"] : \"\"+datum[\"price\"]"
},
"align": {"value": "center"},
"baseline": {"value": "middle"}
}
}
},
{
"name": "layer_1_layer_1_marks",
"type": "text",
"style": ["text"],
"from": {"data": "data_1"},
"encode": {
"update": {
"fontWeight": {"value": "bold"},
"fill": {"value": "black"},
"description": {
"signal": "\"date: \" + (timeFormat(datum[\"date\"], \"%b %d, %Y\")) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"text": {
"signal": "isValid(datum[\"price\"]) ? datum[\"price\"] : \"\"+datum[\"price\"]"
},
"align": {"value": "center"},
"baseline": {"value": "middle"}
}
}
},
{
"name": "_fg_text_hm0ll1_marks",
"type": "text",
"style": ["text"],
"from": {"data": "data_2"},
"encode": {
"update": {
"dy": {"value": -12},
"fontWeight": {"value": "bold"},
"fill": {"value": "white"},
"description": {
"signal": "\"date: \" + (timeFormat(datum[\"date\"], \"%b %d, %Y\")) + \"; price: \" + (format(datum[\"price\"], \"\"))"
},
"x": {"scale": "x", "field": "date"},
"y": {"scale": "y", "field": "price"},
"text": {
"signal": "isValid(datum[\"price\"]) ? datum[\"price\"] : \"\"+datum[\"price\"]"
},
"align": {"value": "center"},
"baseline": {"value": "middle"}
}
},
"zindex": 1
},
{
"name": "_bg_text_hm0ll1_marks",
"type": "rect",
"style": ["rect"],
"from": {"data": "_fg_text_hm0ll1_marks"},
"encode": {
"update": {
"opacity": {"value": 0.8},
"fill": {"value": "red"},
"cornerRadius": {"value": 4},
"x": {"field": "bounds.x1", "offset": -6},
"x2": {"field": "bounds.x2", "offset": 6},
"y": {"field": "bounds.y1", "offset": -4},
"y2": {"field": "bounds.y2", "offset": 4}
}
}
}
],
"scales": [
{
"name": "x",
"type": "time",
"domain": {
"fields": [
{"data": "source_0", "field": "date"},
{"data": "data_1", "field": "date"},
{"data": "data_2", "field": "date"}
]
},
"range": [0, {"signal": "width"}]
},
{
"name": "y",
"type": "linear",
"domain": {
"fields": [
{"data": "source_0", "field": "price"},
{"data": "data_1", "field": "price"},
{"data": "data_2", "field": "price"}
]
},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"gridScale": "y",
"grid": true,
"tickCount": {"signal": "ceil(width/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"gridScale": "x",
"grid": true,
"tickCount": {"signal": "ceil(height/40)"},
"domain": false,
"labels": false,
"aria": false,
"maxExtent": 0,
"minExtent": 0,
"ticks": false,
"zindex": 0
},
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "date",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "price",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
]
}
73 changes: 73 additions & 0 deletions examples/specs/layer_text_background.vl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "Google's stock price over time.",
"width": 500,
"data": {
"url": "data/stocks.csv"
},
"transform": [
{
"filter": "datum.symbol==='GOOG'"
}
],
"encoding": {
"x": {
"field": "date",
"type": "temporal"
},
"y": {
"field": "price",
"type": "quantitative"
}
},
"layer": [
{
"mark": "line"
},
{
"mark": {
"type": "text",
"fontWeight": "bold",
"bgType": "outline",
"bgPadding": 4
},
"transform": [
{
"filter": "+datum.price === 286"
}
],
"encoding": {
"text": {
"field": "price"
}
}
},
{
"mark": {
"type": "text",
"color": "white",
"fontWeight": "bold",
"dy": -12,
"bgColor": "red",
"bgOpacity": 0.8,
"bgCornerRadius": 4,
"bgPadding": {
"left": 6,
"top": 4,
"right": 6,
"bottom": 4
}
},
"transform": [
{
"filter": "+datum.price === 707"
}
],
"encoding": {
"text": {
"field": "price"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v6.json",
"description": "Google's stock price over time.",
"width": 500,
"data": {"url": "data/stocks.csv"},
"layer": [
{
"mark": "line",
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"}
}
},
{
"layer": [
{
"mark": {
"type": "text",
"fontWeight": "bold",
"bgType": "outline",
"bgPadding": 4,
"stroke": "white",
"strokeWidth": 4
},
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"},
"text": {"field": "price"}
},
"transform": [{"filter": "+datum.price === 286"}]
},
{
"mark": {
"type": "text",
"fontWeight": "bold",
"bgType": "outline",
"bgPadding": 4
},
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"},
"text": {"field": "price"}
},
"transform": [{"filter": "+datum.price === 286"}]
}
]
},
{
"layer": [
{
"mark": {
"type": "text",
"color": "white",
"fontWeight": "bold",
"dy": -12,
"bgColor": "red",
"bgOpacity": 0.8,
"bgCornerRadius": 4,
"bgPadding": {"left": 6, "top": 4, "right": 6, "bottom": 4}
},
"encoding": {
"x": {"field": "date", "type": "temporal"},
"y": {"field": "price", "type": "quantitative"},
"text": {"field": "price"}
},
"transform": [{"filter": "+datum.price === 707"}],
"name": "_fg_text_hm0ll1"
},
{
"name": "_bg_text_hm0ll1",
"mark": {
"type": "rect",
"fill": "red",
"opacity": 0.8,
"cornerRadius": 4,
"bgPadding": {"left": 6, "top": 4, "right": 6, "bottom": 4}
}
}
]
}
],
"transform": [{"filter": "datum.symbol==='GOOG'"}]
}
Loading
Loading