Sha256: d03d6a5f73190dd14136f4b2fafbaa1a89e2083abb47e1eb630f9a9ecde6b003
Contents?: true
Size: 1.74 KB
Versions: 2
Compression:
Stored size: 1.74 KB
Contents
# frozen_string_literal: true require 'goldendocx/charts' # It is weired because this will generate two parts of XMLs module Goldendocx module Components class Chart include Goldendocx::Document namespace :c tag :chartSpace concern_namespaces :c, :a, :r, :mc, :c14 embeds_one :rounded_corner, class_name: 'Goldendocx::Charts::Properties::RoundedCornerProperty', auto_build: true embeds_one :chart, class_name: 'Goldendocx::Charts::Properties::ChartProperty', auto_build: true attr_accessor :name attr_reader :id, :series 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: relationship_id) inline_drawing.build_extents(width: attributes[:width], height: attributes[:height]) inline_drawing.build_graphic.build_data.build_chart(relationship_id: relationship_id) end def add_series(name, categories, values) ser_id = series.size + 1 the_chart.build_series(categories: categories, values: values, id: ser_id, name: name) ser = Goldendocx::Charts::Series.new(categories: categories, values: values, id: ser_id, name: name) series << ser ser end def to_xml @paragraph.to_xml end def to_element(**context) @paragraph.to_element(**context) end def write_to(zos) entry_name = format(Goldendocx::Charts::RELATIONSHIP_NAME_PATTERN, id: id) zos.put_next_entry "word/#{entry_name}" zos.write to_document_xml end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
goldendocx-0.2.3 | lib/goldendocx/components/chart.rb |
goldendocx-0.2.2 | lib/goldendocx/components/chart.rb |