diff --git a/CHANGELOG.md b/CHANGELOG.md index 09f51b33..028d9f3f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog -## [v1.9.0] - perhaps christmas 2019? +## [v1.9.0] - December 2019 + +- changed compatibility versions in Project.toml ### Added -- Bezier `arrow()`s can also be defined by height now +- Bezier `arrow()`s can also be defined by height of box ### Changed diff --git a/Project.toml b/Project.toml index 62e17aca..4544b3f7 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Luxor" uuid = "ae8d54c2-7ccd-5906-9d76-62fc9837b5bc" authors = ["cormullion "] -version = "1.8.0" +version = "1.9.0" [deps] Cairo = "159f3aea-2a34-519c-b102-8c37f9878175" @@ -21,9 +21,9 @@ test = ["Test"] [compat] julia = "1" -Cairo = "0.5.6, 0.6, 0.7" -Colors = "0.9" -FileIO = "1" -ImageMagick = "0.7.3" -Juno = "0.5.3, 0.7" -QuartzImageIO = "0.6" +Cairo = "0.5, 0.6, 0.7, 0.8, 1.0" +Colors = "0.6, 0.9, 1.0" +FileIO = "^1.0" +ImageMagick = "^0.7" +Juno = "^0.7" +QuartzImageIO = "^0.6" diff --git a/src/bars.jl b/src/bars.jl index 7f921612..2494f105 100644 --- a/src/bars.jl +++ b/src/bars.jl @@ -13,10 +13,10 @@ will fit in a box `yheight` high (even if there are negative values). To control the drawing of the text and bars, define functions that process the end points: -`mybarfunction(bottom::Point, top::Point, value; extremes=[a, b], barnumber=0, +`mybarfunction(bottom::Point, top::Point, value; extremes=[a, b], barnumber=1, bartotal=0)` -`mylabelfunction(bottom::Point, top::Point, value; extremes=[a, b], barnumber=0, +`mylabelfunction(bottom::Point, top::Point, value; extremes=[a, b], barnumber=1, bartotal=0)` and pass them like this: @@ -29,7 +29,28 @@ bars(v, xwidth=15, yheight=10, labelfunction=mylabelfunction) or: ``` -bars(v, labelfunction = (args...; extremes=[], barnumber=0, bartotal=0) -> setgray(rand())) +bars(v, labelfunction = (args...; extremes=[], barnumber=1, bartotal=0) -> setgray(rand())) +``` + +Draw some Fibonacci sequence numbers: + +``` +fib(n) = n > 2 ? fib(n - 1) + fib(n - 2) : 1 +fibs = fib.(1:15) +@draw begin + fontsize(12) + fontface("JuliaMono") + setline(20) + translate(boxbottomleft(BoundingBox() * 0.9)) + bars(fibs, + barfunction = (b, t, v; kwargs...) -> line(b, t, :stroke), + labelfunction = (b, t, v; extremes=[], barnumber=1, bartotal=1) -> + begin + text(string(fibs[barnumber]), t + (0, -20), halign=:center) + text(string(barnumber), b + (0, 20), halign=:center) + end, + xwidth=35) +end ``` To suppress the text labels, use optional keyword `labels=false`. @@ -37,14 +58,17 @@ To suppress the text labels, use optional keyword `labels=false`. function bars(values::Array; yheight = 200, xwidth = 25, + barfunction = (bottom::Point, top::Point, value; - extremes=extrema(values), barnumber=0, bartotal=0) -> begin + extremes=extrema(values), barnumber=1, bartotal=0) -> begin setline(xwidth) line(bottom, top, :stroke) end, + labels::Bool=true, + labelfunction = (bottom::Point, top::Point, value; - extremes=extrema(values), barnumber=0, bartotal=0) -> begin + extremes=extrema(values), barnumber=1, bartotal=0) -> begin t = string(round(value, digits=2)) textoffset = textextents(t)[4] fontsize(10) @@ -55,7 +79,7 @@ function bars(values::Array; end text(t, tp, halign=:center, valign=:middle) end) - + # end keyword args x = O.x mn, mx = extrema(values) isapprox(mn, mx, atol=0.00001) && (mx = mn + 100) # better show something than nothing diff --git a/src/graphlayout.jl b/src/graphlayout.jl index e9aa5bbb..fc3bee09 100644 --- a/src/graphlayout.jl +++ b/src/graphlayout.jl @@ -68,7 +68,7 @@ function layout_spring(adjmatrix::Array{T,2} where T; densityconstant = 2.0, maxiterations = 100, initialtemperature = 2.0, - boundingbox = BoundingBox() * 0.9) + boundingbox = BoundingBox(O - (250, 250), O + (250, 250))) N = size(adjmatrix, 1) if N != size(adjmatrix, 2)