Class: RCharts::GraphHelper::Element
- Inherits:
-
Object
- Object
- RCharts::GraphHelper::Element
- Includes:
- ActiveModel::API, ActiveModel::Attributes
- Defined in:
- app/helpers/rcharts/graph_helper/element.rb
Overview
Element
The base class for all elements to inherit from. Elements are designed for cases where a tag helper alone would be unwieldy because of the complexity of determining content or attribute values e.g. for SVG positioning attributes like x and y.
To ensure rendering yields a predictable result every time, don’t mutate element state as part of the rendering process. If you need to track and mutate state, use ElementBuilder instead, which is designed for this situation.
By default, rendering an element produces no content. Subclasses should implement their own private #tags method to return actual content when rendered. All helpers and objects accessible in the parent view context are also accessible within #tags, so you can use tag helpers and other helpers to build markup.
To pass a value to an element, first declare an attribute using the ActiveModel::Attributes API and then pass the value to the element’s initializer (or use one of the other methods to set attributes). Already declared attributes are #id, #class_names (with writer alias #class=), #data, and #aria.
Direct Known Subclasses
Axes::AxisElement, Axes::LabelElement, Axes::TickElement, Categories::BarSegmentElement, Categories::BarsElement, RuleElement, Series::PathElement, Tooltips::ForeignObjectElement, Tooltips::HoverTargetElement, Tooltips::MarkerElement, Tooltips::TooltipElement
Instance Method Summary collapse
-
#aria ⇒ Object
:attr_accessor:.
-
#class_names ⇒ Object
:attr_accessor:.
-
#data ⇒ Object
:attr_accessor:.
-
#id ⇒ Object
:attr_accessor: id.
- #render_in(view_context) ⇒ Object
Instance Method Details
#aria ⇒ Object
:attr_accessor:
47 |
# File 'app/helpers/rcharts/graph_helper/element.rb', line 47 attribute :aria, default: -> { {} } |
#class_names ⇒ Object
:attr_accessor:
36 |
# File 'app/helpers/rcharts/graph_helper/element.rb', line 36 attribute :class_names |
#data ⇒ Object
:attr_accessor:
43 |
# File 'app/helpers/rcharts/graph_helper/element.rb', line 43 attribute :data, default: -> { {} } |
#id ⇒ Object
:attr_accessor: id
32 |
# File 'app/helpers/rcharts/graph_helper/element.rb', line 32 attribute :id, :string |
#render_in(view_context) ⇒ Object
51 52 53 54 55 |
# File 'app/helpers/rcharts/graph_helper/element.rb', line 51 def render_in(view_context, &) with view_context: do (&) end end |