Skip to content

Commit 10a27de

Browse files
altair theme helpers
1 parent a2a6554 commit 10a27de

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

quarto/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
from quarto.quarto import path
77
from quarto.render import render
88
from quarto.metadata import metadata
9-
from quarto.theme import plotly_theme_colors, plotly_theme_brand
9+
from quarto.theme import plotly_theme_colors, plotly_theme_brand, altair_theme_colors, altair_theme_brand

quarto/theme.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import yaml
2-
import plotly.graph_objects as go
32
from functools import partial
43

54
def plotly_theme_colors(bg, fg):
5+
import plotly.graph_objects as go
66
return go.layout.Template({'layout': {
77
'paper_bgcolor': bg,
88
'plot_bgcolor': bg,
@@ -12,3 +12,26 @@ def plotly_theme_colors(bg, fg):
1212
def plotly_theme_brand(brand_yml):
1313
brand = yaml.safe_load(open(brand_yml).read())
1414
return plotly_theme_colors(brand["color"]["background"], brand["color"]["foreground"])
15+
16+
def altair_theme_colors(bg, fg):
17+
return {
18+
'config': {
19+
'view': {'stroke': 'transparent'},
20+
'axis': {
21+
'domainColor': fg,
22+
'labelColor': fg,
23+
'titleColor': fg,
24+
},
25+
'legend': {
26+
'labelColor': fg,
27+
'titleColor': fg,
28+
},
29+
'background': bg, # Background color
30+
}
31+
}
32+
33+
def altair_theme_brand(brand_yml):
34+
brand = yaml.safe_load(open(brand_yml).read())
35+
bg = brand["color"]["background"]
36+
fg = brand["color"]["foreground"]
37+
return partial(altair_theme_colors, bg, fg)

0 commit comments

Comments
 (0)