Skip to content

Instantly share code, notes, and snippets.

@trinker
Created May 30, 2024 14:52
Show Gist options
  • Save trinker/5f63025bfc0d9d32bc606d25b8615cae to your computer and use it in GitHub Desktop.
Save trinker/5f63025bfc0d9d32bc606d25b8615cae to your computer and use it in GitHub Desktop.
Vega-Lite spec from Thu May 30 2024
{
"width": 600,
"data": {
"values": [
{
"__row__": 0,
"calendar_month_year": "Dec-23",
"concentration_risk_monthly": 0.8
},
{
"__row__": 1,
"calendar_month_year": "Jan-24",
"concentration_risk_monthly": 0.7
},
{
"__row__": 2,
"calendar_month_year": "Feb-24",
"concentration_risk_monthly": 0.7
},
{
"__row__": 3,
"calendar_month_year": "Mar-24",
"concentration_risk_monthly": 0.8
},
{
"__row__": 4,
"calendar_month_year": "Apr-24",
"concentration_risk_monthly": 0.8
},
{
"__row__": 5,
"calendar_month_year": "May-24",
"concentration_risk_monthly": 0.8
}
]
},
"transform": [{"extent": "concentration_risk_monthly", "param": "myExtent"}],
"mark": {
"type": "area",
"fill": {
"expr": "{'gradient': 'linear', 'x1':0,'y1':1,'x2':0,'y2':0, 'stops': [{'offset': 0, 'color': scale('stroke', myExtent[0]>1?1:myExtent[0]>0.3?0.3:0)},{'offset': 0.3, 'color': scale('stroke', myExtent[1]>1?1:myExtent[1]>0.3?0.3:0)},{'offset': 1, 'color': scale('stroke', myExtent[1]>=1?1:myExtent[1]>0.3?1:0.3)}]}"
},
"strokeOpacity": 0
},
"encoding": {
"stroke": {
"field": "1",
"legend": null,
"scale": {
"type": "linear",
"range": ["#00800166", "#F7B50066", "#A9281F66"],
"domain": [0, 0.3, 1]
}
},
"x": {
"field": "calendar_month_year",
"type": "ordinal",
"sort": {"field": "__row__"},
"axis": {"title": null},
"scale": {"padding": 0}
},
"y": {
"field": "concentration_risk_monthly",
"type": "quantitative",
"axis": {"title": null}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment