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

Adding flow values #23

Open
Mastomaki opened this issue Feb 16, 2022 · 4 comments
Open

Adding flow values #23

Mastomaki opened this issue Feb 16, 2022 · 4 comments

Comments

@Mastomaki
Copy link

In addition to node labels, one should have the possibility to add flow values as labels.

@davide-f
Copy link
Collaborator

davide-f commented Feb 17, 2022

Thanks @Mastomaki for the suggestion, that may be interesting, let's keep the issue open.
Currently, I have no time to work on that, but feel free to add a pull request on that if you wish.

Anyway, it may not be easy to show the labels and make them readable; maybe a size legend may be more appropriate.

@Mastomaki
Copy link
Author

I don't know how to make a pull request. But adding edge_labels (bool) as new parameter, here is my suggestion:

code added to line 133:

               # add flow labels
                if edge_labels == true
                    y_flowlab1 = y[i] + h - src_offsets[i, j]
                    y_flowlab2 = y[j] + vw[j] / (2m) - dst_offsets[j, i]
                    @series begin
                        primary := :false
                        seriestype := :scatter
                        markeralpha := 0
                        flowlabel = @sprintf("%.2g", get_prop(g, edge_it, :weight))
                        series_annotations := text.([flowlabel],
                                                    :center,
                                                    label_size)                  
                        [(x[i] + x[j])/2], [(y_flowlab1 + y_flowlab2)/2]
                    end
                end

@davide-f
Copy link
Collaborator

@Mastomaki thank you for the suggestion; indeed it can be made; do you wish to make the contribution?
To do so, you just need to fork the repo, make the changes in your fork and then after doing the changes you can open the pull request.

This link may be in handy: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

What do you think?

@syou83syou83
Copy link

syou83syou83 commented May 19, 2023

Hi @davide-f and @Mastomaki , in the new version of the code, the line numbers have been changed. So I don't know where to put this snippet in.

I thought it should be 143line which might be 133 originally, like to following, but it doesn't pass the compiling. Please could you elaborate where to put this code. Or will the code work in the new version of SankeyPlots. Thank you very much!

`

           # add flow labels
        if edge_labels == true
            y_flowlab1 = y[i] + h - src_offsets[i, j]
            y_flowlab2 = y[j] + vw[j] / (2m) - dst_offsets[j, i]
            @series begin
                primary := :false
                seriestype := :scatter
                markeralpha := 0
                flowlabel = @sprintf("%.2g", get_prop(g, edge_it, :weight))
                series_annotations := text.([flowlabel],
                                            :center,
                                            label_size)                  
                [(x[i] + x[j])/2], [(y_flowlab1 + y_flowlab2)/2]
            end
        end            
        if label_position !== :legend
            xlab, orientation = if label_position in (:node, :top, :bottom)
                olab = if label_position === :top
                    :bottom

`

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

No branches or pull requests

3 participants