Class: Goldendocx::Components::Chart
- Inherits:
-
Object
- Object
- Goldendocx::Components::Chart
- Includes:
- Document
- Defined in:
- lib/goldendocx/components/chart.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
Returns the value of attribute name.
-
#series ⇒ Object
readonly
Returns the value of attribute series.
Instance Method Summary collapse
- #add_series(name, categories, values) ⇒ Object
-
#initialize(chart_id, relationship_id, attributes = {}) ⇒ Chart
constructor
A new instance of Chart.
- #to_element(**context) ⇒ Object
- #to_xml ⇒ Object
- #write_to(zos) ⇒ Object
Methods included from Document
Methods included from Element
#build_element, #namespace, #tag, #tag_name
Methods included from HasChildren
#children, #read_child, #read_children
Methods included from HasAttributes
#assign_attributes, #attributes, #read_attributes
Constructor Details
#initialize(chart_id, relationship_id, attributes = {}) ⇒ Chart
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/goldendocx/components/chart.rb', line 21 def initialize(chart_id, relationship_id, attributes = {}) @id = chart_id @series = [] @paragraph = Goldendocx::Components::Paragraph.new inline_drawing = @paragraph.build_run.build_drawing.build_inline inline_drawing.build_non_visual_property(relationship_id:) inline_drawing.build_extents(width: attributes[:width], height: attributes[:height]) inline_drawing.build_graphic.build_data.build_chart(relationship_id:) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
19 20 21 |
# File 'lib/goldendocx/components/chart.rb', line 19 def id @id end |
#name ⇒ Object
Returns the value of attribute name.
18 19 20 |
# File 'lib/goldendocx/components/chart.rb', line 18 def name @name end |
#series ⇒ Object (readonly)
Returns the value of attribute series.
19 20 21 |
# File 'lib/goldendocx/components/chart.rb', line 19 def series @series end |
Instance Method Details
#add_series(name, categories, values) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/goldendocx/components/chart.rb', line 32 def add_series(name, categories, values) ser_id = series.size + 1 the_chart.build_series(categories:, values:, id: ser_id, name:) ser = Goldendocx::Charts::Series.new(categories:, values:, id: ser_id, name:) series << ser ser end |
#to_element(**context) ⇒ Object
44 45 46 |
# File 'lib/goldendocx/components/chart.rb', line 44 def to_element(**context) @paragraph.to_element(**context) end |
#to_xml ⇒ Object
40 41 42 |
# File 'lib/goldendocx/components/chart.rb', line 40 def to_xml @paragraph.to_xml end |
#write_to(zos) ⇒ Object
48 49 50 51 52 |
# File 'lib/goldendocx/components/chart.rb', line 48 def write_to(zos) entry_name = format(Goldendocx::Charts::RELATIONSHIP_NAME_PATTERN, id:) zos.put_next_entry "word/#{entry_name}" zos.write to_document_xml end |