Module: Charts::Renderer::SvgRenderer

Defined in:
lib/charts/renderer/svg_renderer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#svgObject (readonly)

Returns the value of attribute svg.



4
5
6
# File 'lib/charts/renderer/svg_renderer.rb', line 4

def svg
  @svg
end

Instance Method Details

#circle(cx, cy, radius, style = {}) ⇒ Object



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

def circle(cx, cy, radius, style = {})
  svg.circle style.merge(cx: cx, cy: cy, r: radius)
end

#line(x1, y1, x2, y2, style = {}) ⇒ Object



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

def line(x1, y1, x2, y2, style = {})
  svg.line style.merge(x1: x1, y1: y1, x2: x2, y2: y2)
end

#path(d, style = {}) ⇒ Object



30
31
32
# File 'lib/charts/renderer/svg_renderer.rb', line 30

def path(d, style = {})
  svg.path style.merge(d: d)
end

#pre_drawObject



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

def pre_draw
  @svg = SVG.new width: chart.width, height: chart.height
end


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

def print
  svg.render
end

#rect(x, y, width, height, style = {}) ⇒ Object



26
27
28
# File 'lib/charts/renderer/svg_renderer.rb', line 26

def rect(x, y, width, height, style = {})
  svg.rect style.merge(x: x, y: y, width: width, height: height)
end

#save(filename) ⇒ Object



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

def save(filename)
  svg.save filename
end

#text(text, x, y, style = {}) ⇒ Object



34
35
36
# File 'lib/charts/renderer/svg_renderer.rb', line 34

def text(text, x, y, style = {})
  svg.text text, font_style.merge(style).merge(x: x, y: y)
end