-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jonmmease/jonmmease/text
Add initial text mark support
- Loading branch information
Showing
17 changed files
with
1,311 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.