Skip to content

Commit

Permalink
Merge pull request #6 from jonmmease/jonmmease/text
Browse files Browse the repository at this point in the history
Add initial text mark support
  • Loading branch information
jonmmease authored Dec 29, 2023
2 parents e27191f + 70c6dd7 commit 16922f3
Show file tree
Hide file tree
Showing 17 changed files with 1,311 additions and 29 deletions.
141 changes: 140 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

135 changes: 135 additions & 0 deletions gen-test-data/vega-specs/text/bar_axis_labels.vg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "A bar graph showing what activities consume what percentage of the day.",
"background": "white",
"padding": 5,
"width": 200,
"style": "cell",
"config": {"style": {"cell": {"stroke": "transparent"}}},
"data": [
{
"name": "source_0",
"values": [
{"Activity": "Sleeping", "Time": 8},
{"Activity": "Eating", "Time": 2},
{"Activity": "TV", "Time": 4},
{"Activity": "Work", "Time": 8},
{"Activity": "Exercise", "Time": 2}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "joinaggregate",
"as": ["TotalTime"],
"ops": ["sum"],
"fields": ["Time"]
},
{
"type": "formula",
"expr": "datum.Time/datum.TotalTime * 100",
"as": "PercentOfTotal"
},
{
"type": "stack",
"groupby": ["Activity"],
"field": "PercentOfTotal",
"sort": {"field": [], "order": []},
"as": ["PercentOfTotal_start", "PercentOfTotal_end"],
"offset": "zero"
},
{
"type": "filter",
"expr": "isValid(datum[\"PercentOfTotal\"]) && isFinite(+datum[\"PercentOfTotal\"])"
}
]
}
],
"signals": [
{"name": "y_step", "value": 12},
{
"name": "height",
"update": "bandspace(domain('y').length, 0.1, 0.05) * y_step"
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["bar"],
"from": {"data": "data_0"},
"encode": {
"update": {
"fill": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "bar"},
"description": {
"signal": "\"% of total Time: \" + (format(datum[\"PercentOfTotal\"], \"\")) + \"; Activity: \" + (isValid(datum[\"Activity\"]) ? datum[\"Activity\"] : \"\"+datum[\"Activity\"])"
},
"x": {"scale": "x", "field": "PercentOfTotal_end"},
"x2": {"scale": "x", "field": "PercentOfTotal_start"},
"y": {"scale": "y", "field": "Activity"},
"height": {"signal": "max(0.25, bandwidth('y'))"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "linear",
"domain": {
"data": "data_0",
"fields": ["PercentOfTotal_start", "PercentOfTotal_end"]
},
"range": [0, {"signal": "width"}],
"nice": true,
"zero": true
},
{
"name": "y",
"type": "band",
"domain": {"data": "data_0", "field": "Activity", "sort": true},
"range": {"step": {"signal": "y_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
}
],
"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": "x",
"orient": "bottom",
"grid": false,
"title": "% of total Time",
"labelFlush": true,
"labelOverlap": true,
"tickCount": {"signal": "ceil(width/40)"},
"labelFont": "Helvetica",
"titleFont": "Helvetica",
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"labelFont": "Helvetica",
"titleFont": "Helvetica",
"zindex": 0
}
]
}
1 change: 1 addition & 0 deletions vega-wgpu-renderer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ thiserror = "1.0.52"
csscolorparser = "0.6.2"
image = "0.24.7"
futures-intrusive = "^0.5"
glyphon = { git = "https://github.com/grovesNL/glyphon.git", rev="941309aed230d7110bfec0d4af502ecb4648cf90" }

[dev-dependencies]
dssim = "3.2.4"
Expand Down
Loading

0 comments on commit 16922f3

Please sign in to comment.