I tried to make two area charts using the Deneb visual of power bi and vega lite language.
Two things I struggled to do :
- The values under 1000 (700 for example) I want to display them as 0.7K (The current format doesn't seem to convert them , it only formats the values above 1000)
- I want to highlight the maximum value in GREEN and minimum value in RED for both charts
Here's the full code:
{
"data": {"name": "dataset"},
"layer": [
{
"mark": {
"type": "area",
"line": {"color": "#063970"},
"color": {
"x1": 1,
"y1": 1,
"gradient": "linear",
"stops": [
{"offset": 0, "color": "white"},
{"offset": 1, "color": "#063970"}
]
}
}
},
{
"mark": {
"type": "area",
"line": {"color": "#2596be"},
"color": {
"x1": 1,
"y1": 1,
"gradient": "linear",
"stops": [
{"offset": 0, "color": "white"},
{"offset": 1, "color": "#2596be"}
]
}
},
"encoding": {
"y": {"field": "Variable 1", "type": "quantitative"}
}
},
{
"mark": {
"type": "text",
"yOffset": -10,
"size": 10,
"color": "#000000"
},
"encoding": {
"text": {"field": "Variable 2", "format": ".2s"},
"opacity": {
"condition": {"test": {"field": "MONTH", "equal": "off"}, "value": 0.1},
"value": 1
},
"y": {"field": "Variable 2", "type": "quantitative", "axis": null}
}
},
{
"mark": {
"type": "text",
"yOffset": -10,
"size": 10,
"color": "#000000"
},
"encoding": {
"text": {"field": "Variable 1", "format": ".2s"
},
"opacity": {
"condition": {"test": {"field": "MONTH", "equal": "off"}, "value": 0.1},
"value": 1
},
"y": {"field": "Variable 1", "type": "quantitative", "axis": null}
}
}
],
"encoding": {
"x": {
"field": "MONTH",
"type": "ordinal",
"axis": {"labelPadding": 0},
"title": null
},
"y": {
"field": "Variable 2",
"type": "quantitative",
"axis": null
}
}
}