-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bar Chart
95 lines (92 loc) · 1.79 KB
/
Bar Chart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
Specifications:
{
"data": {"name": "dataset"},
"width": {"step": 60},
"params": [
{"name": "bwActual", "value": 0.8},
{"name": "bwDelta", "value": 0.5}
],
"transform": [
{
"calculate": "datum['Count_JC'] >= datum['Count_JC_SPLY']",
"as": "delta_positive"
},
{
"calculate": "datum['delta_positive'] ? '#83C79B' :'#8D1D1C'",
"as": "delta_bar_color"
}
],
"layer": [
{
"mark": {
"type": "bar",
"tooltip": true,
"width": {
"expr": "bandwidth('x') * bwActual"
},
"style": "bar_actual"
}
},
{
"description": "Delta Bar",
"mark": {
"type": "bar",
"tooltip": {"content": "data"},
"color":{
"expr":"datum['delta_bar_color']"
},
"xOffset": {
"expr": "bandwidth('x') * (bwActual - bwDelta)/2"
},
"width": {
"expr": "bandwidth('x') * bwDelta"
}
},
"encoding": {
"y2": {"field": "Count_JC_SPLY"}
}
}
],
"encoding": {
"x": {
"field": "End of Month",
"type": "nominal",
"sort": null,
"axis": {
"format": "MMM yy",
"formatType": "pbiFormat"
}
},
"y": {
"field": "Count_JC",
"type": "quantitative"
},
"opacity": {
"condition": {
"test": {
"field": "__selected__",
"equal": "off"
},
"value": 0.3
},
"value": 1
}
}
}
Config :
{
"view": {"stroke": "transparent"},
"font": "Segoe UI",
"axis": {
"title": "",
"grid": false,
"domainWidth": 2,
"domainColor": "black",
"labelAngle": 0,
"labelFontSize": 12
},
"axisY": {"disable": true},
"style": {
"bar_actual": {"color": "#404040"}
}
}