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
@api public
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
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 172 def category_axis(*args, **kwargs) @options[:category_axis] = kwargs.empty? ? args.first : kwargs end
Configures the category axis properties for this chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 106 def chart_space(*args, **kwargs) @options[:chart_space] = kwargs.empty? ? args.first : kwargs end
Configures the chart_space property for this chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] The configured chart_space property. @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 128 def data_labels(*args, **kwargs) @options[:data_labels] = kwargs.empty? ? args.first : kwargs end
Configures data labels for this chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] The configured data_labels property. @api public
(*(String) args, **String | Integer | bool | nil kwargs) → String
Source
# File lib/xlsxrb/chart_builder.rb, line 150 def display_blanks_as(*args, **kwargs) @options[:display_blanks_as] = kwargs.empty? ? args.first : kwargs end
Configures how blank cells are displayed in the chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [String] @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 84 def legend(*args, **kwargs) @options[:legend] = kwargs.empty? ? args.first : kwargs end
Configures the legend property for this chart.
@param args [Array] Positional arguments (e.g. position string). @param kwargs [Hash] Keyword arguments for legend styling/layout. @return [Object] The configured legend property. @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 95 def plot_area(*args, **kwargs) @options[:plot_area] = kwargs.empty? ? args.first : kwargs end
(*(bool | String) args, **String | Integer | bool | nil kwargs) → (bool | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 139 def plot_visible_only(*args, **kwargs) @options[:plot_visible_only] = kwargs.empty? ? args.first : kwargs end
Configures whether to plot visible cells only.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Boolean, String] @api public
(?Hash[Symbol, untyped]? value) ?{ (SeriesBuilder) → void } → Array[Hash[Symbol, untyped]]
Source
# File lib/xlsxrb/chart_builder.rb, line 65 def series(value = nil) @options[:series] ||= [] if block_given? sb = SeriesBuilder.new yield sb @options[:series] << sb.options elsif value @options[:series] << value end @options[:series] end
Adds a data series to the chart.
@overload series(value)
Adds a pre-built series options hash.
@param value [Hash{Symbol => Object}] Series options hash.
@return [Array<Hash{Symbol => Object}>]
@overload series(&block)
Configures a series using a block.
@yield [series_builder]
@yieldparam series_builder [SeriesBuilder]
@return [Array<Hash{Symbol => Object}>]
@api public
(*(bool | String) args, **String | Integer | bool | nil kwargs) → (bool | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 194 def show_legend_key(*args, **kwargs) @options[:show_legend_key] = kwargs.empty? ? args.first : kwargs end
Configures whether to show the legend key in data labels.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Boolean, String] @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String | Integer) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String | Integer)
Source
# File lib/xlsxrb/chart_builder.rb, line 117 def style(*args, **kwargs) @options[:style] = kwargs.empty? ? args.first : kwargs end
Configures the style index/id for this chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] The configured style property. @api public
(String | Hash[Symbol, untyped] | nil value) → (String | Hash[Symbol, untyped] | nil)
Source
# File lib/xlsxrb/chart_builder.rb, line 46 def title(value) @options[:title] = value end
Sets the chart title.
@param value [String, Hash, nil] Chart title text or options hash. @return [String, Hash, nil] @api public
(Symbol | String value) → (Symbol | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 36 def type(value) @options[:type] = value end
Sets the chart type (e.g. :line, :bar, :pie, :area, :radar, :scatter).
@param value [Symbol, String] Chart type. @return [Symbol, String] @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 183 def value_axis(*args, **kwargs) @options[:value_axis] = kwargs.empty? ? args.first : kwargs end
Configures the value axis properties for this chart.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] @api public
(*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) → (Hash[Symbol, String | Integer | bool | nil] | String)
Source
# File lib/xlsxrb/chart_builder.rb, line 161 def view3d(*args, **kwargs) @options[:view3d] = kwargs.empty? ? args.first : kwargs end
Configures 3D view properties for 3D charts.
@param args [Array] Positional arguments. @param kwargs [Hash] Keyword arguments. @return [Object] @api public