Skip to content

Instantly share code, notes, and snippets.

@lcyraphael
Last active March 31, 2020 10:40
Show Gist options
  • Save lcyraphael/c124bbab34d45a494dbb9bab45deb703 to your computer and use it in GitHub Desktop.
Save lcyraphael/c124bbab34d45a494dbb9bab45deb703 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega/v5.json",
"background": "white",
"padding": 5,
"title": {
"anchor": "middle",
"text": "The majority of arts and cultural charities are small and may struggle in the current crisis.",
"frame": "group"
},
"style": "cell",
"data": [
{
"name": "data-c1ecfefd0c2b1ba05d4ef3ed9f49c425",
"values": [
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 7224,
"Beneficiary": "Children/ young people"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 5945,
"Beneficiary": "Children/ young people"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 2850,
"Beneficiary": "Children/ young people"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 618,
"Beneficiary": "Children/ young people"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 82,
"Beneficiary": "Children/ young people"
},
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 3829,
"Beneficiary": "People with disabilities"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 2889,
"Beneficiary": "People with disabilities"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 1793,
"Beneficiary": "People with disabilities"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 389,
"Beneficiary": "People with disabilities"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 46,
"Beneficiary": "People with disabilities"
},
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 3971,
"Beneficiary": "Other charities or voluntary bodies"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 2969,
"Beneficiary": "Other charities or voluntary bodies"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 1524,
"Beneficiary": "Other charities or voluntary bodies"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 376,
"Beneficiary": "Other charities or voluntary bodies"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 54,
"Beneficiary": "Other charities or voluntary bodies"
},
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 1679,
"Beneficiary": "Particular ethnic groups"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 1389,
"Beneficiary": "Particular ethnic groups"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 944,
"Beneficiary": "Particular ethnic groups"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 185,
"Beneficiary": "Particular ethnic groups"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 14,
"Beneficiary": "Particular ethnic groups"
},
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 5082,
"Beneficiary": "Elderly/ older people"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 3913,
"Beneficiary": "Elderly/ older people"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 1770,
"Beneficiary": "Elderly/ older people"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 363,
"Beneficiary": "Elderly/ older people"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 39,
"Beneficiary": "Elderly/ older people"
},
{
"Size": "Small (£10k-100k)",
"Number of ACHS charities": 8555,
"Beneficiary": "The general public"
},
{
"Size": "Micro (<£10k)",
"Number of ACHS charities": 7037,
"Beneficiary": "The general public"
},
{
"Size": "Medium (£100k-1m)",
"Number of ACHS charities": 2990,
"Beneficiary": "The general public"
},
{
"Size": "Large (£1m-10m)",
"Number of ACHS charities": 778,
"Beneficiary": "The general public"
},
{
"Size": "Very large (>£10m)",
"Number of ACHS charities": 126,
"Beneficiary": "The general public"
}
]
},
{
"name": "data_0",
"source": "data-c1ecfefd0c2b1ba05d4ef3ed9f49c425",
"transform": [
{
"type": "formula",
"expr": "datum[\"Size\"]===\"Micro (<£10k)\" ? 0 : datum[\"Size\"]===\"Small (£10k-100k)\" ? 1 : datum[\"Size\"]===\"Medium (£100k-1m)\" ? 2 : datum[\"Size\"]===\"Large (£1m-10m)\" ? 3 : datum[\"Size\"]===\"Very large (>£10m)\" ? 4 : 5",
"as": "x_Size_sort_index"
}
]
},
{
"name": "data_2",
"source": "data_0",
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"Number of ACHS charities\"]) && isFinite(+datum[\"Number of ACHS charities\"])"
}
]
},
{
"name": "data_3",
"source": "data_0",
"transform": [
{
"type": "filter",
"expr": "isValid(datum[\"Number of ACHS charities\"]) && isFinite(+datum[\"Number of ACHS charities\"])"
}
]
}
],
"signals": [
{
"name": "width",
"init": "isFinite(containerSize()[0]) ? containerSize()[0] : 400",
"on": [
{
"update": "isFinite(containerSize()[0]) ? containerSize()[0] : 400",
"events": "window:resize"
}
]
},
{
"name": "height",
"init": "isFinite(containerSize()[1]) ? containerSize()[1] : 300",
"on": [
{
"update": "isFinite(containerSize()[1]) ? containerSize()[1] : 300",
"events": "window:resize"
}
]
}
],
"marks": [
{
"name": "layer_0_marks",
"type": "rect",
"style": ["rect"],
"from": {"data": "data_2"},
"encode": {
"update": {
"fill": {"scale": "color", "field": "Number of ACHS charities"},
"tooltip": {
"signal": "{\"Size\": ''+datum[\"Size\"], \"Beneficiary\": ''+datum[\"Beneficiary\"], \"Number of ACHS charities\": format(datum[\"Number of ACHS charities\"], \"\")}"
},
"x": {"scale": "x", "field": "Size"},
"width": {"scale": "x", "band": true},
"y": {"scale": "y", "field": "Beneficiary"},
"height": {"scale": "y", "band": true}
}
}
},
{
"name": "layer_1_marks",
"type": "symbol",
"style": ["point"],
"from": {"data": "data_3"},
"encode": {
"update": {
"opacity": {"value": 0.5},
"fill": {"value": "#685BC7"},
"strokeWidth": {"value": 3},
"stroke": {"value": "#685BC7"},
"tooltip": {
"signal": "{\"Size\": ''+datum[\"Size\"], \"Beneficiary\": ''+datum[\"Beneficiary\"], \"Number of ACHS charities\": format(datum[\"Number of ACHS charities\"], \"\")}"
},
"x": {"scale": "x", "field": "Size", "band": 0.5},
"y": {"scale": "y", "field": "Beneficiary", "band": 0.5},
"size": {"scale": "size", "field": "Number of ACHS charities"}
}
}
}
],
"scales": [
{
"name": "x",
"type": "band",
"domain": {
"data": "data_0",
"field": "Size",
"sort": {"op": "min", "field": "x_Size_sort_index"}
},
"range": [0, {"signal": "width"}],
"paddingInner": 0,
"paddingOuter": 0
},
{
"name": "y",
"type": "band",
"domain": {
"fields": [
{"data": "data_2", "field": "Beneficiary"},
{"data": "data_3", "field": "Beneficiary"}
],
"sort": true
},
"range": [0, {"signal": "height"}],
"paddingInner": 0,
"paddingOuter": 0
},
{
"name": "color",
"type": "linear",
"domain": {"data": "data_2", "field": "Number of ACHS charities"},
"range": {"scheme": "redpurple"},
"interpolate": "hcl",
"zero": false
},
{
"name": "size",
"type": "linear",
"domain": {"data": "data_3", "field": "Number of ACHS charities"},
"range": [0, 361],
"zero": true
}
],
"axes": [
{
"scale": "x",
"orient": "bottom",
"grid": false,
"title": "Size (by annual income in 2018)",
"labelAlign": "right",
"labelBaseline": "middle",
"zindex": 1
},
{
"scale": "y",
"orient": "left",
"grid": false,
"title": "Who the charity helps",
"zindex": 1
}
],
"legends": [
{
"title": "Number of ACHS charities",
"fill": "color",
"gradientLength": {"signal": "clamp(height, 64, 200)"},
"symbolType": "square"
},
{
"size": "size",
"gradientLength": {"signal": "clamp(height, 64, 200)"},
"symbolType": "circle",
"encode": {
"symbols": {
"update": {
"fill": {"value": "#685BC7"},
"stroke": {"value": "#685BC7"},
"opacity": {"value": 0.5}
}
}
}
}
],
"config": {
"axis": {
"domain": false,
"grid": false,
"labelFont": "Century Gothic",
"labelFontSize": 14,
"labelFontWeight": 500,
"labelLimit": 0,
"labelPadding": 10,
"ticks": false,
"titleFont": "Century Gothic",
"titleFontSize": 14,
"titlePadding": 10
},
"axisLeft": {"titleAngle": 360, "titleX": -85, "titleY": -10},
"axisBottom": {"labelAngle": 300},
"legend": {
"labelFont": "Century Gothic",
"labelFontSize": 14,
"labelLimit": 0,
"titleFont": "Century Gothic",
"titleFontSize": 14,
"titleLimit": 0
},
"style": {
"cell": {"strokeOpacity": 0},
"group-title": {
"dx": -55,
"dy": -15,
"font": "Century Gothic",
"fontSize": 16
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment