Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add waterfall chart example #2621

Merged
merged 3 commits into from
Dec 17, 2022
Merged

Add waterfall chart example #2621

merged 3 commits into from
Dec 17, 2022

Conversation

yanghung
Copy link
Contributor

No description provided.

@yanghung yanghung mentioned this pull request Jun 21, 2022
Copy link
Contributor

@joelostblom joelostblom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for creating this PR @yanghung ! I made a few minor comments on coding style , but other than that this looks good to me! Could you address them and ping me after so that I can review again?

Comment on lines +14 to +15


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change



## Compared to the original example, we have to add some more fields to help with color labeling and ordering the bars
the_data=[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
the_data=[
the_data = [

Could you add spaces around all variable assignment = like this?

Comment on lines +56 to +57
calc_lead="datum.window_lead_label === null ? datum.label : datum.window_lead_label"
, calc_prev_sum="datum.label === 'End' ? 0 : datum.window_sum_amount - datum.amount"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
calc_lead="datum.window_lead_label === null ? datum.label : datum.window_lead_label"
, calc_prev_sum="datum.label === 'End' ? 0 : datum.window_sum_amount - datum.amount"
calc_lead="datum.window_lead_label === null ? datum.label : datum.window_lead_label",
calc_prev_sum="datum.label === 'End' ? 0 : datum.window_sum_amount - datum.amount
"

Could you make this change everywhere (having comma last instead of first) so that the style is consistent with the rest of the Altair documentation?

)

## layer everything together
(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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this line is so long I would write it like this instead:

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
)

)

## the "rule" chart is for the lines that connect bars each month
rule=base_chart.mark_rule(color='#404040', opacity=0.9, strokeWidth=2, xOffset=-25, x2Offset=25, strokeDash=[3,3]).encode(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rule=base_chart.mark_rule(color='#404040', opacity=0.9, strokeWidth=2, xOffset=-25, x2Offset=25, strokeDash=[3,3]).encode(
rule = base_chart.mark_rule(
color='#404040',
opacity=0.9,
strokeWidth=2,
xOffset=-25,
x2Offset=25,
strokeDash=[3,3]
).encode(

I would break this up since the line is really long

@joelostblom
Copy link
Contributor

@yanghung When you are addressing the comments I made, could you also rebase this on the latest main branch so that the CI tests above pass (I recently committed a fix)?

@binste
Copy link
Contributor

binste commented Dec 17, 2022

If you merge the PR in its current state I can create a follow-up one in the next few days to address the open points. If it doesn't work due to the failed checks I can also copy over the code from here and add @yanghung as an author.

@mattijn
Copy link
Contributor

mattijn commented Dec 17, 2022

Thanks @binste! Which category is this supposed to be? It's currently in other charts but that category is not there anymore.

@binste
Copy link
Contributor

binste commented Dec 17, 2022

As it contains quite a few transformations I'd suggest to place it into Advanced Calculations # category: advanced calculations.

@mattijn mattijn merged commit 09988e9 into vega:master Dec 17, 2022
@mattijn
Copy link
Contributor

mattijn commented Dec 17, 2022

thanks again @yanghung, and the floor is yours @binste;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants