Skip to content

Instantly share code, notes, and snippets.

@duncdrum
Last active June 12, 2020 21:54
Show Gist options
  • Save duncdrum/d25436d8313327be2f1703b6e55547d6 to your computer and use it in GitHub Desktop.
Save duncdrum/d25436d8313327be2f1703b6e55547d6 to your computer and use it in GitHub Desktop.
ReadAct_views
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Textual works by creator excluding unknowns",
"background": "#333",
"padding": 5,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"url": "https://raw.githubusercontent.com/readchina/ReadingData/master/csv/views/view01a_txt-titles.csv",
"format": {"type": "csv", "delimiter": ","}
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "aggregate",
"groupby": ["title"],
"ops": ["count"],
"fields": [null],
"as": ["__count"]
}
]
}
],
"signals": [
{"name": "x_step", "value": 20},
{
"name": "width",
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["bar"],
"from": {"data": "data_0"},
"encode": {
"update": {
"tooltip": {"signal": "datum"},
"fill": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "bar"},
"description": {
"signal": "\"title\" + \": \" + (isValid(datum[\"title\"]) ? datum[\"title\"] : \"\"+datum[\"title\"]) + \"; \" + \"Count of Records\" + \": \" + (format(datum[\"__count\"], \"\"))"
},
"x": {"scale": "x", "field": "title"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "__count"},
"y2": {"scale": "y", "value": 0}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {
"data": "source_0",
"field": "title",
"sort": {"op": "count", "order": "descending"}
},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "y",
"type": "linear",
"domain": {"data": "data_0", "field": "__count"},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
}
],
"axes": [
{
"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": "title",
"labelAngle": 0,
"labelBaseline": "top",
"labelOverlap": true,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Count of Records",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
],
"config": {
"style": {
"guide-label": {"fill": "#fff"},
"guide-title": {"fill": "#fff"},
"group-title": {"fill": "#fff"}
},
"axis": {"domainColor": "#fff", "gridColor": "#888", "tickColor": "#fff"}
}
}
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Non-textual works by creator excluding unknowns",
"background": "#333",
"padding": 5,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"url": "https://raw.githubusercontent.com/readchina/ReadAct/master/csv/views/view01b_art-titles.csv",
"format": {"type": "csv"}
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "aggregate",
"groupby": ["title"],
"ops": ["count"],
"fields": [null],
"as": ["__count"]
}
]
}
],
"signals": [
{"name": "x_step", "value": 20},
{
"name": "width",
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["bar"],
"from": {"data": "data_0"},
"encode": {
"update": {
"tooltip": {"signal": "datum"},
"fill": {"value": "#4c78a8"},
"ariaRoleDescription": {"value": "bar"},
"description": {
"signal": "\"title\" + \": \" + (isValid(datum[\"title\"]) ? datum[\"title\"] : \"\"+datum[\"title\"]) + \"; \" + \"Count of Records\" + \": \" + (format(datum[\"__count\"], \"\"))"
},
"x": {"scale": "x", "field": "title"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "__count"},
"y2": {"scale": "y", "value": 0}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {
"data": "source_0",
"field": "title",
"sort": {"op": "count", "order": "descending"}
},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "y",
"type": "linear",
"domain": {"data": "data_0", "field": "__count"},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
}
],
"axes": [
{
"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": "title",
"labelAngle": 0,
"labelBaseline": "top",
"labelOverlap": true,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Count of Records",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
],
"config": {
"style": {
"guide-label": {"fill": "#fff"},
"guide-title": {"fill": "#fff"},
"group-title": {"fill": "#fff"}
},
"axis": {"domainColor": "#fff", "gridColor": "#888", "tickColor": "#fff"}
}
}
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"description": "Reading Objects by creator excluding anonymous works",
"background": "#333",
"padding": 5,
"height": 200,
"style": "cell",
"data": [
{
"name": "source_0",
"url": "https://raw.githubusercontent.com/readchina/ReadAct/master/csv/views/view02_creator-matrix.csv",
"format": {"type": "csv", "parse": {"creator": "string"}},
"transform": [
{"type": "filter", "expr": "!(datum[\"creator\"]===\"AG0626\")"}
]
},
{
"name": "data_0",
"source": "source_0",
"transform": [
{
"type": "aggregate",
"groupby": ["creator", "act_object", "title", "name"],
"ops": ["count"],
"fields": [null],
"as": ["__count"]
},
{
"type": "stack",
"groupby": ["creator"],
"field": "__count",
"sort": {"field": ["act_object"], "order": ["descending"]},
"as": ["__count_start", "__count_end"],
"offset": "zero"
}
]
}
],
"signals": [
{"name": "x_step", "value": 20},
{
"name": "width",
"update": "bandspace(domain('x').length, 0.1, 0.05) * x_step"
}
],
"marks": [
{
"name": "marks",
"type": "rect",
"style": ["bar"],
"from": {"data": "data_0"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "act_object"},
"tooltip": {
"signal": "{\"title\": isValid(datum[\"title\"]) ? datum[\"title\"] : \"\"+datum[\"title\"], \"name\": isValid(datum[\"name\"]) ? datum[\"name\"] : \"\"+datum[\"name\"], \"Count of Records\": format(datum[\"__count\"], \"\")}"
},
"ariaRoleDescription": {"value": "bar"},
"description": {
"signal": "\"Creator\" + \": \" + (isValid(datum[\"creator\"]) ? datum[\"creator\"] : \"\"+datum[\"creator\"]) + \"; \" + \"Count of Records\" + \": \" + (format(datum[\"__count\"], \"\")) + \"; \" + \"act_object\" + \": \" + (isValid(datum[\"act_object\"]) ? datum[\"act_object\"] : \"\"+datum[\"act_object\"]) + \"; \" + \"title\" + \": \" + (isValid(datum[\"title\"]) ? datum[\"title\"] : \"\"+datum[\"title\"]) + \"; \" + \"name\" + \": \" + (isValid(datum[\"name\"]) ? datum[\"name\"] : \"\"+datum[\"name\"])"
},
"x": {"scale": "x", "field": "creator"},
"width": {"scale": "x", "band": 1},
"y": {"scale": "y", "field": "__count_end"},
"y2": {"scale": "y", "field": "__count_start"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {
"data": "source_0",
"field": "creator",
"sort": {"op": "count", "order": "descending"}
},
"range": {"step": {"signal": "x_step"}},
"paddingInner": 0.1,
"paddingOuter": 0.05
},
{
"name": "y",
"type": "linear",
"domain": {"data": "data_0", "fields": ["__count_start", "__count_end"]},
"range": [{"signal": "height"}, 0],
"nice": true,
"zero": true
},
{
"name": "color",
"type": "ordinal",
"domain": {"data": "data_0", "field": "act_object", "sort": true},
"range": "category"
}
],
"axes": [
{
"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": "Creator",
"labelAngle": 0,
"labelBaseline": "top",
"labelOverlap": true,
"zindex": 0
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Count of Records",
"labelOverlap": true,
"tickCount": {"signal": "ceil(height/40)"},
"zindex": 0
}
],
"legends": [{"fill": "color", "symbolType": "square", "title": "act_object"}],
"config": {
"style": {
"guide-label": {"fill": "#fff"},
"guide-title": {"fill": "#fff"},
"group-title": {"fill": "#fff"}
},
"axis": {"domainColor": "#fff", "gridColor": "#888", "tickColor": "#fff"}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment