Skip to content

Commit

Permalink
style: Revert style changes in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
dangotbanned committed Nov 2, 2024
1 parent 45729d5 commit 1a8c59a
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@
# otherwise, use `"steelblue"`
color = alt.when(year=1810).then(alt.value("orange")).otherwise(alt.value("steelblue"))

chart = (
alt.Chart(source)
.mark_bar()
.encode(x="year:O", y="wheat:Q", color=color)
.properties(width=600)
)
chart
alt.Chart(source).mark_bar().encode(
x="year:O",
y="wheat:Q",
color=color
).properties(width=600)
12 changes: 5 additions & 7 deletions tests/examples_arguments_syntax/bar_chart_with_negatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
predicate = alt.datum.nonfarm_change > 0
color = alt.when(predicate).then(alt.value("steelblue")).otherwise(alt.value("orange"))

chart = (
alt.Chart(source)
.mark_bar()
.encode(x="month:T", y="nonfarm_change:Q", color=color)
.properties(width=600)
)
chart
alt.Chart(source).mark_bar().encode(
x="month:T",
y="nonfarm_change:Q",
color=color
).properties(width=600)
13 changes: 8 additions & 5 deletions tests/examples_arguments_syntax/scatter_point_paths_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@
.otherwise(alt.value(0.1))
)
# Points that are always visible (filtered by slider and search)
visible_points = (
base.mark_circle(size=100)
.encode(opacity=opacity)
.transform_filter(x_select)
.add_params(hover, hover_point_opacity, x_select)
visible_points = base.mark_circle(size=100).encode(
opacity=opacity
).transform_filter(
x_select
).add_params(
hover,
hover_point_opacity,
x_select
)

when_hover = alt.when(hover)
Expand Down
49 changes: 23 additions & 26 deletions tests/examples_arguments_syntax/waterfall_chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,19 @@
)

# The "base_chart" defines the transform_window, transform_calculate, and X axis
base_chart = (
alt.Chart(source)
.transform_window(window_sum_amount="sum(amount)", window_lead_label="lead(label)")
.transform_calculate(
calc_lead=alt.expr.if_((window_lead_label == None), label, window_lead_label),
calc_prev_sum=calc_prev_sum,
calc_amount=calc_amount,
calc_text_amount=calc_text_amount,
calc_center=(window_sum_amount + calc_prev_sum) / 2,
calc_sum_dec=alt.expr.if_(
window_sum_amount < calc_prev_sum, window_sum_amount, ""
),
calc_sum_inc=alt.expr.if_(
window_sum_amount > calc_prev_sum, window_sum_amount, ""
),
)
.encode(x=alt.X("label:O", axis=alt.Axis(title="Months", labelAngle=0), sort=None))
base_chart = alt.Chart(source).transform_window(
window_sum_amount="sum(amount)",
window_lead_label="lead(label)",
).transform_calculate(
calc_lead=alt.expr.if_((window_lead_label == None), label, window_lead_label),
calc_prev_sum=calc_prev_sum,
calc_amount=calc_amount,
calc_text_amount=calc_text_amount,
calc_center=(window_sum_amount + calc_prev_sum) / 2,
calc_sum_dec=alt.expr.if_(window_sum_amount < calc_prev_sum, window_sum_amount, ""),
calc_sum_inc=alt.expr.if_(window_sum_amount > calc_prev_sum, window_sum_amount, ""),
).encode(
x=alt.X("label:O", axis=alt.Axis(title="Months", labelAngle=0), sort=None)
)

color_coding = (
Expand Down Expand Up @@ -96,12 +92,13 @@
color=alt.value("white"),
)

waterfall = (
bar
+ rule
+ text_pos_values_top_of_bar
+ text_neg_values_bot_of_bar
+ text_bar_values_mid_of_bar
).properties(width=800, height=450)

waterfall
alt.layer(
bar,
rule,
text_pos_values_top_of_bar,
text_neg_values_bot_of_bar,
text_bar_values_mid_of_bar
).properties(
width=800,
height=450
)
13 changes: 8 additions & 5 deletions tests/examples_methods_syntax/scatter_point_paths_hover.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@
.otherwise(alt.value(0.1))
)
# Points that are always visible (filtered by slider and search)
visible_points = (
base.mark_circle(size=100)
.encode(opacity=opacity)
.transform_filter(x_select)
.add_params(hover, hover_point_opacity, x_select)
visible_points = base.mark_circle(size=100).encode(
opacity=opacity
).transform_filter(
x_select
).add_params(
hover,
hover_point_opacity,
x_select
)

when_hover = alt.when(hover)
Expand Down

0 comments on commit 1a8c59a

Please sign in to comment.