Class: RCharts::GraphHelper::Categories::CategoryBuilder
- Inherits:
-
ElementBuilder
- Object
- ElementBuilder
- RCharts::GraphHelper::Categories::CategoryBuilder
- Defined in:
- app/helpers/rcharts/graph_helper/categories/category_builder.rb
Overview
Category Builder
Instance Method Summary collapse
-
#bar ⇒ Object
Shortcut to render a bar for every series.
-
#index ⇒ Object
:attr_accessor: index.
-
#name ⇒ Object
:attr_accessor:.
-
#series(*names, axis: nil, inline_axis: nil) ⇒ Object
Renders one or more series present in the data.
Methods inherited from ElementBuilder
Instance Method Details
#bar ⇒ Object
Shortcut to render a bar for every series. Useful when you don’t need to differentiate between different series. Arguments and options are passed to #series, see there for more details.
23 24 25 |
# File 'app/helpers/rcharts/graph_helper/categories/category_builder.rb', line 23 def (*, **) series(*, **, &:bar) end |
#index ⇒ Object
:attr_accessor: index
14 |
# File 'app/helpers/rcharts/graph_helper/categories/category_builder.rb', line 14 attribute :index, :integer, default: 0 |
#name ⇒ Object
:attr_accessor:
10 |
# File 'app/helpers/rcharts/graph_helper/categories/category_builder.rb', line 10 attribute :name |
#series(*names, axis: nil, inline_axis: nil) ⇒ Object
Renders one or more series present in the data. For each series yields a BarBuilder which contains the series:
<%= graph_for @annual_sales do |graph| %>
<%= graph.category do |category| %>
<%= category.series do |series| %>
<%= series.bar %>
<% end %>
<% end %>
<% end %>
The default is to iterate over all series, but you can specify a subset by passing the series names as arguments.
Options
:axis-
The axis for the series. Defaults to the first continuous axis.
:inline_axis-
The axis for the categories. Defaults to the first discrete axis.
42 43 44 45 46 47 48 |
# File 'app/helpers/rcharts/graph_helper/categories/category_builder.rb', line 42 def series(*names, axis: nil, inline_axis: nil, **, &) (axis: inline_axis) do filtered_series(*names).each_with_index do |(name, value), index| concat (name, value, index, filtered_series(*names)&.count, axis:, **, &) end end end |