forked from GiovineItalia/Gadfly.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hline.jl
38 lines (29 loc) · 1.13 KB
/
hline.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
immutable HLineGeometry <: Gadfly.GeometryElement
color::@compat(Union{Color, (@compat Void)})
size::@compat(Union{Measure, (@compat Void)})
tag::Symbol
function HLineGeometry(; color=nothing,
size::@compat(Union{Measure, (@compat Void)})=nothing,
tag::Symbol=empty_tag)
new(color === nothing ? nothing : Colors.color(color),
size, tag)
end
end
const hline = HLineGeometry
function element_aesthetics(::HLineGeometry)
[:yintercept]
end
# Generate a form for the hline geometry
function render(geom::HLineGeometry, theme::Gadfly.Theme, aes::Gadfly.Aesthetics)
Gadfly.assert_aesthetics_defined("Geom.hline", aes, :yintercept)
color = geom.color === nothing ? theme.default_color : geom.color
size = geom.size === nothing ? theme.line_width : geom.size
line_style = Gadfly.get_stroke_vector(theme.line_style)
return compose!(
context(),
Compose.line([[(0w, y), (1w, y)] for y in aes.yintercept], geom.tag),
stroke(color),
linewidth(size),
strokedash(line_style),
svgclass("xfixed"))
end