Spaces:
Runtime error
Runtime error
feat: white ruler in dark mode
Browse files- cafe_app.py +4 -3
cafe_app.py
CHANGED
@@ -26,7 +26,7 @@ lambdas = {s: sp.lambdify(inputs, sol[0][s]) for s in solve_for}
|
|
26 |
ld_total = sp.lambdify(inputs, sol[0][P1] + sol[0][P2])
|
27 |
|
28 |
|
29 |
-
def make_chart(df: pd.DataFrame) -> alt.Chart:
|
30 |
source = df.melt("PT", var_name="species", value_name="y")
|
31 |
|
32 |
# Create a selection that chooses the nearest point & selects based on x-value
|
@@ -54,10 +54,11 @@ def make_chart(df: pd.DataFrame) -> alt.Chart:
|
|
54 |
)
|
55 |
|
56 |
# Draw a rule at the location of the selection
|
|
|
57 |
rules = (
|
58 |
alt.Chart(source)
|
59 |
.transform_pivot("species", value="y", groupby=["PT"])
|
60 |
-
.mark_rule(color=
|
61 |
.encode(
|
62 |
x="PT:Q",
|
63 |
opacity=alt.condition(nearest, alt.value(0.3), alt.value(0)),
|
@@ -124,7 +125,7 @@ def Page():
|
|
124 |
|
125 |
# put the results in a dataframe, together with input PT values
|
126 |
df = pd.DataFrame(dict(PT=PT_values) | {k.name: v for k, v in ans.items()})
|
127 |
-
return make_chart(df)
|
128 |
|
129 |
chart = solara.use_memo(update, [vmin.value, vmax.value])
|
130 |
|
|
|
26 |
ld_total = sp.lambdify(inputs, sol[0][P1] + sol[0][P2])
|
27 |
|
28 |
|
29 |
+
def make_chart(df: pd.DataFrame, dark: bool) -> alt.Chart:
|
30 |
source = df.melt("PT", var_name="species", value_name="y")
|
31 |
|
32 |
# Create a selection that chooses the nearest point & selects based on x-value
|
|
|
54 |
)
|
55 |
|
56 |
# Draw a rule at the location of the selection
|
57 |
+
rule_color = "white" if dark else "black"
|
58 |
rules = (
|
59 |
alt.Chart(source)
|
60 |
.transform_pivot("species", value="y", groupby=["PT"])
|
61 |
+
.mark_rule(color=rule_color)
|
62 |
.encode(
|
63 |
x="PT:Q",
|
64 |
opacity=alt.condition(nearest, alt.value(0.3), alt.value(0)),
|
|
|
125 |
|
126 |
# put the results in a dataframe, together with input PT values
|
127 |
df = pd.DataFrame(dict(PT=PT_values) | {k.name: v for k, v in ans.items()})
|
128 |
+
return make_chart(df, dark_effective)
|
129 |
|
130 |
chart = solara.use_memo(update, [vmin.value, vmax.value])
|
131 |
|