Giter VIP home page Giter VIP logo

Comments (2)

hexaeder avatar hexaeder commented on July 18, 2024

something like this is done in a hacky way for the node_pos. Hacky, because adds the observable to the attributes of the plot object from inside the recipe.

https://github.com/JuliaPlots/GraphMakie.jl/blob/a1ab3f931c6c023644fdd1f226b11b9a87eaa941/src/recipes.jl#L176

If i remember correctly, there were some difficulties. I.e it works like this

g[:attr] = @lift ...
local_attr = g[:attr]

but not like this

local_attr = @lift ...
g[:attr] = local_attr

should be fine to use the same strategy here

https://github.com/JuliaPlots/GraphMakie.jl/blob/a1ab3f931c6c023644fdd1f226b11b9a87eaa941/src/recipes.jl#L195-L200

from graphmakie.jl.

filchristou avatar filchristou commented on July 18, 2024

Yes, in order to draw the figure above, I followed the example of node_pos

diff --git a/src/recipes.jl b/src/recipes.jl
index 9714263..2881510 100644
--- a/src/recipes.jl
+++ b/src/recipes.jl
@@ -194,10 +194,11 @@ function Makie.plot!(gp::GraphPlot)
 
     # create array of pathes triggered by node_pos changes
     # in case of a graph change the node_position will change anyway
-    edge_paths = lift(node_pos, gp.selfedge_size,
+    gp[:edge_paths] = lift(node_pos, gp.selfedge_size,
                       gp.selfedge_direction, gp.selfedge_width) do pos, s, d, w
         find_edge_paths(graph[], gp.attributes, pos)
     end
+    edge_paths = gp[:edge_paths]
 
     # plot edges
     edge_plot = edgeplot!(gp, edge_paths;

"Hacky" is kind of a scary word.
My impression for "Hacky" stuff is that they tend to go unstable between releases and most of the times do not follow best practices.
Do you know if there is a better way to do it or it is indeed the suggested technique in the Makie ecosystem ?

from graphmakie.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.