Accountants in my organization are asked to reduce the amount of activities by performing medium-risk activities only quarterly instead of every month and low-risk accounts only annually (or never).
The visual on the left shows a working bubble graph, where size is count of Activities and color indicates adherence to policy (Low risk = Annually, Medium risk is Quarterly and High risk = Monthly). Deviations show orange to red.
Turns out that it is important to differentiate between automated activities and manual activities. I'd like to introduce that dimension in the visual, by turning the points into little pie-charts, where the colors are the same (red, orange, green), but the lightness value is different.
The first step was successful (middle visual): turning points into pie-charts by using a new DAX measure that always ads up to 100% per Risk/Frequency occurrence and using "scale": {"domain": [0, 1]} for the "theta" property.
% of activities (automation) =
DIVIDE(
[# of activities],
CALCULATE(
[# of activities],
REMOVEFILTERS('ActivityTable'[Automation])
)
)
The second step is where it got messy. I want to vary the size (with radius) of the pie-charts with the amount of Activities (higher values, bigger pies), preferably with a transformation or parameter to manually play with the size. I didn't get that to work so I resorted to a new measure, encoding that to the "radius". The pies did vary in size but now the "Manual" slice started at theta 0 (north) instead of continuing on where "Automatic" left off. This is the measure:
Activities_indep =
CALCULATE(
[# of activities],
REMOVEFILTERS('ActivityTable'[Automation])
)
I have two questions:
- How can I make the pie charts such that "Automatic" and "Manual" line up properly?
- How would I go about having Oranges and Reds also included with the respective light and dark values?
Below is the code as far as got. The data is inline, so can be used in the vega.github.io/editor (text marks, highlights and such I can figure out myself later).
Thank you!
(edited to improve readability)
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Pie charts on a grid",
"data": {
"values": [
{"Frequency": "1. Monthly", "Risk": "1. High", "Automation": "Automatic", "Activities": 1276, "% of activities (automation)": 0.6863905325443787, "Activities_indep": 1859},
{"Frequency": "1. Monthly", "Risk": "1. High", "Automation": "Manual", "Activities": 583, "% of activities (automation)": 0.3136094674556213, "Activities_indep": 1859},
{"Frequency": "1. Monthly", "Risk": "2. Medium", "Automation": "Automatic", "Activities": 113, "% of activities (automation)": 0.9826086956521739, "Activities_indep": 115},
{"Frequency": "1. Monthly", "Risk": "2. Medium", "Automation": "Manual", "Activities": 2, "% of activities (automation)": 0.017391304347826087, "Activities_indep": 115},
{"Frequency": "1. Monthly", "Risk": "3. Low", "Automation": "Automatic", "Activities": 2, "% of activities (automation)": 1, "Activities_indep": 2},
{"Frequency": "1. Monthly", "Risk": "3. Low", "Automation": "Manual", "Activities": null, "% of activities (automation)": null, "Activities_indep": 2},
{"Frequency": "2. Quarterly", "Risk": "1. High", "Automation": "Manual", "Activities": 8, "% of activities (automation)": 1, "Activities_indep": 8},
{"Frequency": "2. Quarterly", "Risk": "2. Medium", "Automation": "Automatic", "Activities": null, "% of activities (automation)": null, "Activities_indep": 97},
{"Frequency": "2. Quarterly", "Risk": "2. Medium", "Automation": "Manual", "Activities": 97, "% of activities (automation)": 1, "Activities_indep": 97},
{"Frequency": "3. Annually", "Risk": "3. Low", "Automation": "Manual", "Activities": 81, "% of activities (automation)": 1, "Activities_indep": 81}
]
},
"width": 300,
"height": 300,
"padding": {"top": 10, "bottom": 10},
"layer": [
{
"mark": {
"type": "arc",
"opacity": 0.6,
"tooltip": true
},
"encoding": {
"x": {
"field": "Risk",
"type": "ordinal"
},
"y": {
"field": "Frequency",
"type": "ordinal"
},
"theta": {
"field": "% of activities (automation)",
"type": "quantitative",
"scale": {"domain": [0, 1]}
},
"radius": {
"field": "Activities_indep",
"type": "quantitative",
"scale": {"range": [10, 70]}
},
"radius2": {"value": 0},
"color": {
"field": "Automation",
"type": "ordinal",
"scale": {
"domain": [
"Automatic",
"Manual"
],
"range": [
"lightgreen",
"green"
]
}
},
"order": {"field": "__row_"}
}
}
],
"encoding": {
"x": {
"field": "Risk",
"type": "ordinal",
"axis": {
"grid": true,
"labelAngle": 0,
"labelColor": "#605E5C",
"labelFontSize": 12,
"titleColor": "#605E5C",
"titleFontSize": 14,
"titleFontWeight": 600
}
},
"y": {
"field": "Frequency",
"type": "ordinal",
"axis": {
"grid": true,
"labelColor": "#605E5C",
"labelFontSize": 12,
"titleColor": "#605E5C",
"titleFontSize": 14,
"titleFontWeight": 600
}
}
},
"config":{
"view": {"stroke": "transparent"},
"font": "Segoe UI",
"arc": {},
"area": {
"line": true,
"opacity": 0.6
},
"bar": {},
"line": {
"strokeWidth": 3,
"strokeCap": "round",
"strokeJoin": "round"
},
"point": {"filled": true, "size": 75},
"rect": {},
"text": {
"font": "Segoe UI",
"fontSize": 12,
"fill": "#605E5C"
},
"axis": {
"ticks": false,
"grid": false,
"domain": false,
"labelColor": "#605E5C",
"labelFontSize": 12,
"titleFont": "wf_standard-font, helvetica, arial, sans-serif",
"titleColor": "#1A1A1A",
"titleFontSize": 16,
"titleFontWeight": "normal"
},
"axisQuantitative": {
"tickCount": 3,
"grid": true,
"gridColor": "#C8C6C4",
"gridDash": [1, 5],
"labelFlush": false
},
"axisX": {"labelPadding": 5},
"axisY": {"labelPadding": 10},
"header": {
"titleFont": "wf_standard-font, helvetica, arial, sans-serif",
"titleFontSize": 16,
"titleColor": "#1A1A1A",
"labelFont": "Segoe UI",
"labelFontSize": 13.333333333333332,
"labelColor": "#605E5C"
},
"legend": {
"orient": "none",
"legendX": -68,
"legendY": -68,
"direction": "horizontal",
"title": null,
"titleFont": "Segoe UI",
"titleFontWeight": "bold",
"titleColor": "#605E5C",
"labelFont": "Segoe UI",
"labelFontSize": 13.333333333333332,
"labelColor": "#605E5C",
"symbolType": "circle",
"symbolSize": 75
}
}
}