Module: SVGElements

Included in:
SVGCharts::Bar, SVGCharts::Line
Defined in:
lib/charts/elements.rb

Instance Method Summary collapse

Instance Method Details

#circle(params = {}) ⇒ Object



10
11
12
# File 'lib/charts/elements.rb', line 10

def circle(params = {})
  "<circle cx=\"#{params[:x]}\" cy=\"#{params[:y]}\" r=\"#{params[:radius]}\" stroke=\"#{params[:line_color]}\" stroke-width=\"#{params[:line_width]}\" fill=\"#{params[:background]}\" />"
end

#line(params = {}) ⇒ Object



2
3
4
# File 'lib/charts/elements.rb', line 2

def line(params = {})
  "<line x1=\"#{params[:x1]}\" y1=\"#{params[:y1]}\" x2=\"#{params[:x2]}\" y2=\"#{params[:y2]}\" stroke-width=\"#{params[:line_width]}\" stroke=\"#{params[:color]}\" />"
end

#line_dashed(params = {}) ⇒ Object



6
7
8
# File 'lib/charts/elements.rb', line 6

def line_dashed(params = {})
  "<line x1=\"#{params[:x1]}\" y1=\"#{params[:y1]}\" x2=\"#{params[:x2]}\" y2=\"#{params[:y2]}\" stroke-width=\"#{params[:line_width]}\" stroke=\"#{params[:color]}\" stroke-dasharray=\"5,5\" />"
end

#rect(params = {}) ⇒ Object



14
15
16
# File 'lib/charts/elements.rb', line 14

def rect(params = {})
  "<rect x=\"#{params[:x]}\" y=\"#{params[:y]}\" width=\"#{params[:width]}\" height=\"#{params[:height]}\" fill=\"#{params[:color]}\" />"
end

#text(params = {}) ⇒ Object



18
19
20
# File 'lib/charts/elements.rb', line 18

def text(params = {})
  "<text x=\"#{params[:x]}\" y=\"#{params[:y]}\" fill=\"#{params[:color]}\" font-size=\"#{params[:font_size]}\" font-weight=\"#{params[:font_weight]}\">#{params[:value]}</text>"
end

#text_with_rotation(params = {}) ⇒ Object



22
23
24
# File 'lib/charts/elements.rb', line 22

def text_with_rotation(params = {})
  "<text x=\"#{params[:x]}\" y=\"#{params[:y]}\" fill=\"#{params[:color]}\" font-size=\"#{params[:font_size]}\" font-weight=\"#{params[:font_weight]}\" transform=\"rotate(#{params[:rotate]})\">#{params[:value]}</text>"
end