class Xlsxrb::ChartBuilder
Builder for block-style chart definitions.
@example Create a chart definition
builder = ChartBuilder.new builder.type = :bar builder.title = "Quarterly Sales" builder.series do |s| s.name = "2026" s.categories = "Sheet1!$A$2:$A$5" s.values = "Sheet1!$B$2:$B$5" end
Attributes
Hash[Symbol, untyped]
@return [Hash{Symbol => Object}]
Public Class Methods
() → void
Source
# File lib/xlsxrb/chart_builder.rb, line 22 def initialize @options = {} end
@return [Hash{Symbol => Object}] The configured chart options.
Public Instance Methods
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 329 def category_axis(**kwargs) if kwargs.empty? @options[:category_axis] else @options[:category_axis] = kwargs nil end end
Gets or configures the category axis properties for this chart.
@overload category_axis
Returns the configured category axis property. @return [Object]
@overload category_axis(**kwargs)
Configures category axis using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 344 def category_axis=(value) @options[:category_axis] = value end
Sets category axis properties.
@param value [Object] @return [Object] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 185 def chart_space(**kwargs) if kwargs.empty? @options[:chart_space] else @options[:chart_space] = kwargs nil end end
Gets or configures the chart_space property for this chart.
@overload chart_space
Returns the configured chart_space property. @return [Object]
@overload chart_space(**kwargs)
Configures chart_space using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 200 def chart_space=(value) @options[:chart_space] = value end
Sets the chart_space property.
@param value [Object] @return [Object] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 233 def data_labels(**kwargs) if kwargs.empty? @options[:data_labels] else @options[:data_labels] = kwargs nil end end
Gets or configures data labels for this chart.
@overload data_labels
Returns the configured data_labels property. @return [Object]
@overload data_labels(**kwargs)
Configures data_labels using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 248 def data_labels=(value) @options[:data_labels] = value end
Sets data labels.
@param value [Object] @return [Object] @api public
() → String?
Source
# File lib/xlsxrb/chart_builder.rb, line 276 def display_blanks_as @options[:display_blanks_as] end
Gets how blank cells are displayed in the chart.
@return [String, nil] @api public
(String? value) → String?
Source
# File lib/xlsxrb/chart_builder.rb, line 286 def display_blanks_as=(value) @options[:display_blanks_as] = value end
Sets display blanks as mode.
@param value [String, nil] @return [String, nil] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 127 def legend(**kwargs) if kwargs.empty? @options[:legend] else @options[:legend] = kwargs nil end end
Gets or configures the legend property for this chart.
@overload legend
Returns the configured legend property. @return [Object]
@overload legend(**kwargs)
Configures legend using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 142 def legend=(value) @options[:legend] = value end
Sets the legend property.
@param value [Object] @return [Object] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 156 def plot_area(**kwargs) if kwargs.empty? @options[:plot_area] else @options[:plot_area] = kwargs nil end end
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 171 def plot_area=(value) @options[:plot_area] = value end
Sets the plot_area property.
@param value [Object] @return [Object] @api public
(bool? value) → bool?
Source
# File lib/xlsxrb/chart_builder.rb, line 267 def plot_visible_only=(value) @options[:plot_visible_only] = value end
Sets whether to plot visible cells only.
@param value [Boolean, nil] @return [Boolean, nil] @api public
() → bool
Source
# File lib/xlsxrb/chart_builder.rb, line 257 def plot_visible_only? @options[:plot_visible_only] ? true : false end
Returns whether to plot visible cells only.
@return [Boolean] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 387 def secondary_value_axis(**kwargs) if kwargs.empty? @options[:secondary_value_axis] else @options[:secondary_value_axis] = kwargs nil end end
Gets or configures the secondary value axis properties for combo charts.
@overload secondary_value_axis
Returns the configured secondary value axis property. @return [Object]
@overload secondary_value_axis(**kwargs)
Configures secondary value axis using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 402 def secondary_value_axis=(value) @options[:secondary_value_axis] = value end
Sets secondary value axis properties.
@param value [Object] @return [Object] @api public
(**untyped kwargs) ?{ (SeriesBuilder) → void } → (Array[Hash[Symbol, untyped]] | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 93 def series(**kwargs, &) if block_given? sb = SeriesBuilder.new yield sb (@options[:series] ||= []) << sb.options nil elsif !kwargs.empty? (@options[:series] ||= []) << kwargs nil else @options[:series] || [] end end
Adds a data series to the chart or returns the configured series list.
@overload series
Returns the configured series options list.
@return [Array<Hash{Symbol => Object}>]
@overload series(**kwargs)
Adds a series configured via keyword arguments. @return [void]
@overload series(&block)
Configures a series using a block. @yield [series_builder] @yieldparam series_builder [SeriesBuilder] @return [void]
(Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped] value) → (Array[Hash[Symbol, untyped]] | Hash[Symbol, untyped])
Source
# File lib/xlsxrb/chart_builder.rb, line 113 def series=(value) @options[:series] = value.is_a?(Array) ? value : [value] end
Sets series array.
@param value [Array<Hash{Symbol => Object}>, Hash{Symbol => Object}] @return [Array<Hash{Symbol => Object}>] @api public
(bool? value) → bool?
Source
# File lib/xlsxrb/chart_builder.rb, line 421 def show_legend_key=(value) @options[:show_legend_key] = value end
Sets whether to show the legend key in data labels.
@param value [Boolean, nil] @return [Boolean, nil] @api public
() → bool
Source
# File lib/xlsxrb/chart_builder.rb, line 411 def show_legend_key? @options[:show_legend_key] ? true : false end
Returns whether to show the legend key in data labels.
@return [Boolean] @api public
() → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 209 def style @options[:style] end
Gets the style index/id for this chart.
@return [Integer, String, Hash, nil] The configured style property. @api public
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 219 def style=(value) @options[:style] = value end
Sets the style property.
@param value [Object] @return [Object] @api public
(**untyped kwargs) → (String | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 59 def title(**kwargs) if kwargs.empty? @options[:title] else @options[:title] = kwargs nil end end
Gets or configures the chart title.
@overload title
Returns the configured title options or text.
@return [String, Hash{Symbol => Object}, nil]
@overload title(**kwargs)
Configures title using keyword arguments. @return [void]
(String | Hash[Symbol, untyped] | nil value) → (String | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 74 def title=(value) @options[:title] = value end
Sets the chart title.
@param value [String, Hash{Symbol => Object}, nil] @return [String, Hash{Symbol => Object}, nil] @api public
() → (Symbol | String | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 35 def type @options[:type] end
Gets the chart type (e.g. :line, :bar, :pie, :area, :radar, :scatter).
@return [Symbol, String, nil] @api public
(Symbol | String | nil value) → (Symbol | String | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 45 def type=(value) @options[:type] = value end
Sets the chart type.
@param value [Symbol, String, nil] @return [Symbol, String, nil] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 358 def value_axis(**kwargs) if kwargs.empty? @options[:value_axis] else @options[:value_axis] = kwargs nil end end
Gets or configures the value axis properties for this chart.
@overload value_axis
Returns the configured value axis property. @return [Object]
@overload value_axis(**kwargs)
Configures value axis using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 373 def value_axis=(value) @options[:value_axis] = value end
Sets value axis properties.
@param value [Object] @return [Object] @api public
(**untyped kwargs) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 300 def view3d(**kwargs) if kwargs.empty? @options[:view3d] else @options[:view3d] = kwargs nil end end
Gets or configures 3D view properties for 3D charts.
@overload view3d
Returns the configured view3d property. @return [Object]
@overload view3d(**kwargs)
Configures view3d using keyword arguments. @return [void]
(untyped value) → untyped
Source
# File lib/xlsxrb/chart_builder.rb, line 315 def view3d=(value) @options[:view3d] = value end
Sets 3D view properties.
@param value [Object] @return [Object] @api public