Class: Xlsxrb::ChartBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/xlsxrb.rb

Overview

Builder for block-style chart definitions.

Defined Under Namespace

Classes: SeriesBuilder

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeChartBuilder

: () -> void



72
73
74
# File 'lib/xlsxrb.rb', line 72

def initialize
  @options = {}
end

Instance Attribute Details

#optionsObject (readonly)

: Hash[Symbol, String | Integer | bool | nil]



77
78
79
# File 'lib/xlsxrb.rb', line 77

def options
  @options
end

Instance Method Details

#category_axis(*args, **kwargs) ⇒ Object

Configures the category_axis property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



168
169
170
# File 'lib/xlsxrb.rb', line 168

def category_axis(*args, **kwargs)
  @options[:category_axis] = kwargs.empty? ? args.first : kwargs
end

#chart_space(*args, **kwargs) ⇒ Object

Configures the chart_space property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



120
121
122
# File 'lib/xlsxrb.rb', line 120

def chart_space(*args, **kwargs)
  @options[:chart_space] = kwargs.empty? ? args.first : kwargs
end

#data_labels(*args, **kwargs) ⇒ Object

Configures the data_labels property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



136
137
138
# File 'lib/xlsxrb.rb', line 136

def data_labels(*args, **kwargs)
  @options[:data_labels] = kwargs.empty? ? args.first : kwargs
end

#display_blanks_as(*args, **kwargs) ⇒ Object

Configures the display_blanks_as property for this chart. : (*(String) args, **String | Integer | bool | nil kwargs) -> String

Returns:

  • (Object)

    the configured property



152
153
154
# File 'lib/xlsxrb.rb', line 152

def display_blanks_as(*args, **kwargs)
  @options[:display_blanks_as] = kwargs.empty? ? args.first : kwargs
end

#legend(*args, **kwargs) ⇒ Object

Configures the legend property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



104
105
106
# File 'lib/xlsxrb.rb', line 104

def legend(*args, **kwargs)
  @options[:legend] = kwargs.empty? ? args.first : kwargs
end

#plot_area(*args, **kwargs) ⇒ Object

Configures the plot_area property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



112
113
114
# File 'lib/xlsxrb.rb', line 112

def plot_area(*args, **kwargs)
  @options[:plot_area] = kwargs.empty? ? args.first : kwargs
end

#plot_visible_only(*args, **kwargs) ⇒ Object

Configures the plot_visible_only property for this chart. : (*(bool | String) args, **String | Integer | bool | nil kwargs) -> (bool | String)

Returns:

  • (Object)

    the configured property



144
145
146
# File 'lib/xlsxrb.rb', line 144

def plot_visible_only(*args, **kwargs)
  @options[:plot_visible_only] = kwargs.empty? ? args.first : kwargs
end

#series(value = nil) ⇒ Object

: (?Hash[Symbol, String | Integer | bool | nil]? value) ?{ (SeriesBuilder) -> void } -> Array[Hash[Symbol, String | Integer | bool | nil]]



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/xlsxrb.rb', line 88

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

#show_legend_key(*args, **kwargs) ⇒ Object

Configures the show_legend_key property for this chart. : (*(bool | String) args, **String | Integer | bool | nil kwargs) -> (bool | String)

Returns:

  • (Object)

    the configured property



184
185
186
# File 'lib/xlsxrb.rb', line 184

def show_legend_key(*args, **kwargs)
  @options[:show_legend_key] = kwargs.empty? ? args.first : kwargs
end

#style(*args, **kwargs) ⇒ Object

Configures the style property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String | Integer) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String | Integer)

Returns:

  • (Object)

    the configured property



128
129
130
# File 'lib/xlsxrb.rb', line 128

def style(*args, **kwargs)
  @options[:style] = kwargs.empty? ? args.first : kwargs
end

#title(value) ⇒ Object

: (String value) -> String



84
# File 'lib/xlsxrb.rb', line 84

def title(value) = @options[:title] = value

#type(value) ⇒ Object

: (String value) -> String



81
82
83
# File 'lib/xlsxrb.rb', line 81

def type(value) = @options[:type] = value
# @api public
# : (String value) -> String

#value_axis(*args, **kwargs) ⇒ Object

Configures the value_axis property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



176
177
178
# File 'lib/xlsxrb.rb', line 176

def value_axis(*args, **kwargs)
  @options[:value_axis] = kwargs.empty? ? args.first : kwargs
end

#view3d(*args, **kwargs) ⇒ Object

Configures the view3d property for this chart. : (*(Hash[Symbol, String | Integer | bool | nil] | String) args, **String | Integer | bool | nil kwargs) -> (Hash[Symbol, String | Integer | bool | nil] | String)

Returns:

  • (Object)

    the configured property



160
161
162
# File 'lib/xlsxrb.rb', line 160

def view3d(*args, **kwargs)
  @options[:view3d] = kwargs.empty? ? args.first : kwargs
end