aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2018-10-01 19:12:45 +0200
committerHarald Eilertsen <haraldei@anduin.net>2018-10-01 19:12:45 +0200
commit55c17939fe956772edbeba836d806138d02b3d19 (patch)
tree4a46d7efe84d4f3cc86f4827b30dd19d15e0d29b
parent99bab17980d9d3f02e9f538ff88a921869328049 (diff)
downloadramaskrik-program-55c17939fe956772edbeba836d806138d02b3d19.tar.gz
ramaskrik-program-55c17939fe956772edbeba836d806138d02b3d19.tar.bz2
ramaskrik-program-55c17939fe956772edbeba836d806138d02b3d19.zip
Fix text flow in event boxes.
Use the foreignObject tag to insert a small html-snippet with the text.
-rw-r--r--room-schedule.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/room-schedule.rb b/room-schedule.rb
index 40e94aa..bb6e677 100644
--- a/room-schedule.rb
+++ b/room-schedule.rb
@@ -73,14 +73,29 @@ module SVG
bar_width = (x_end - x_start) * scale
bar_start = x_start * scale
- @graph.add_element( "rect", {
+ event = @graph.add_element( "rect", {
"x" => bar_start.to_s,
"y" => y.to_s,
"width" => bar_width.to_s,
"height" => subbar_height.to_s,
"class" => "fill#{field_count+1}"
})
- t = @graph.add_element("text", {
+ switch = @graph.add_element("switch")
+ fo = switch.add_element("foreignObject", {
+ "x" => (bar_start + @font_size / 2).to_s,
+ "y" => y.to_s,
+ "width" => bar_width.to_s,
+ "height" => subbar_height.to_s,
+ "requiredExtensions" => "http://www.w3.org/1999/xhtml",
+ })
+ body = fo.add_element("body", {
+ "xmlns" => "http://www.w3.org/1999/xhtml",
+ })
+ p = body.add_element("p", {
+ "class" => "event-title",
+ })
+ p.add_text(entry.title)
+ t = switch.add_element("text", {
"x" => (bar_start + @font_size / 2).to_s,
"y" => (y + 2 * @font_size).to_s,
})
@@ -165,6 +180,9 @@ module SVG
stroke: none;
stroke-width: 1px;
}
+.event-title {
+ font-size: 80%;
+}
EOL
end