Class: Shadcn::Chart::Bar::Component

Inherits:
Cartesian::Component show all
Defined in:
app/components/shadcn/chart/bar/component.rb

Overview

Upstream's "Bar Chart" and "Bar Chart - Stacked", drawn on the server.

chart.with_bar(data: { "January" => { desktop: 186, mobile: 80 } })

data: is a Hash of category to a Hash of series to number — one each_with_object away from group(:month, :platform).sum(:visits).

Constant Summary collapse

RADIUS =

radius={4}, which upstream's bar examples pass at the call site in the docs. Nothing of recharts is vendored here, so unlike a class string this is checked against the rendered example and not against vendor/.

4

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from Cartesian::Component

#config, #label

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from Cartesian::Component

#call, #element_attributes

Methods inherited from ApplicationViewComponent

#call, #css_classes, default_tag, #element_attributes, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

#initialize(stacked: false, **attributes) ⇒ Component

stacked: lives here and not on the frame because it is a bar's question. A stacked line would need cumulative points, and Plot does not compute them — so the option is absent where it would lie.



26
27
28
29
# File 'app/components/shadcn/chart/bar/component.rb', line 26

def initialize(stacked: false, **attributes)
  @stacked = stacked
  super(**attributes)
end

Instance Attribute Details

#stackedObject (readonly)

Returns the value of attribute stacked.



21
22
23
# File 'app/components/shadcn/chart/bar/component.rb', line 21

def stacked
  @stacked
end