Skip to content

Commit

Permalink
Merge pull request #29 from JuliaPlots/hw/rmhotfix
Browse files Browse the repository at this point in the history
remove code for single edgewidth per line
  • Loading branch information
hexaeder authored Aug 10, 2021
2 parents 9af5469 + c603a29 commit 5d4ac9b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NetworkLayout = "46757867-2c16-5918-afeb-47bfcb05e46a"

[compat]
LightGraphs = "1.3"
Makie = "0.14, 0.15"
Makie = "0.15"
NetworkLayout = "0.4"
julia = "1"

Expand Down
7 changes: 7 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ using Documenter
using Literate
using CairoMakie

# preload the deps from the examples to supress precompilation output in docs
using JSServe
using NetworkDynamics
using LayeredLayouts
using LightGraphs
using PkgDeps

DocMeta.setdocmeta!(GraphMakie, :DocTestSetup, :(using GraphMakie); recursive=true)

# generate examples
Expand Down
11 changes: 1 addition & 10 deletions src/recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,6 @@ function Makie.plot!(gp::GraphPlot)
edge_pos = @lift ([$node_pos[e.src] for e in edges(graph[])],
[$node_pos[e.dst] for e in edges(graph[])])

# in case the edge_with is same as the number of edges
# create a new observable which doubles the values for compat with line segments
# https://github.com/JuliaPlots/Makie.jl/pull/992
if length(gp.edge_width[]) == ne(graph[])
lineseg_width = @lift repeat($(gp.edge_width), inner=2)
else
lineseg_width = gp.edge_width
end

# calculate the vectors for each edge in pixel space
sc = Makie.parent_scene(gp)
edge_vec_px = lift(edge_pos, sc.px_area, sc.camera.projectionview) do epos, pxa, pv
Expand All @@ -150,7 +141,7 @@ function Makie.plot!(gp::GraphPlot)
edge_segments = @lift vec(permutedims(hcat($edge_pos[1], $edge_pos[2])))
edge_plot = linesegments!(gp, edge_segments;
color=gp.edge_color,
linewidth=lineseg_width,
linewidth=gp.edge_width,
gp.edge_attr...)

# plott arrow heads
Expand Down
22 changes: 22 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,28 @@ using Test
f, ax, p = graphplot(g, node_color=[rand([:blue,:red,:green]) for i in 1:nv(g[])])
end

@testset "self loop" begin
g = SimpleDiGraph(10)
add_edge!(g, 1, 1)
graphplot(g)
end

@testset "small graphs" begin
g = SimpleGraph(1)
fig, ax, p = graphplot(g)

g = complete_graph(2)
graphplot(g)
end

@testset "single line width per edge" begin
g = complete_graph(3)
graphplot(g)
graphplot(g; edge_width=10)
graphplot(g; edge_width=[5, 10, 15])
graphplot(g; edge_width=[5, 10, 5, 10, 5, 10])
end

@testset "Hover, click and drag Interaction" begin
g = wheel_graph(10)
f, ax, p = graphplot(g,
Expand Down

0 comments on commit 5d4ac9b

Please sign in to comment.