Class: Clowk::Phlex::Charts::ChartShape

Inherits:
Clowk::Phlex::Component show all
Defined in:
lib/clowk/phlex/charts/chart_shape.rb

Overview

Components::Metrics::ChartShape — the little glyph for a chart TYPE (area / bars / line / radial / linear). ONE source of truth for the shape icons, shared by the dashboard builder's shape chips and the expand modal's chart-type dropdown (and whatever comes next).

css sizes it: the default "w-full h-full" fills the big builder chip preview; a small "w-6 h-4" sits inline before a dropdown label.

Everything draws with currentColor so the glyph inherits the surrounding text color — the builder sets it live to the metric hue, a dropdown row uses its own text/accent color.

Constant Summary collapse

METRIC_TYPES =

[label, gauge] for the time-series + gauge shapes, in display order. The canonical list the ChartTypePicker and the builder's metric shape chips both iterate. gauge: true ones need a metric with a ceiling.

[
  {value: "area", label: "Area", gauge: false},
  {value: "bars", label: "Bar", gauge: false},
  {value: "line", label: "Line", gauge: false},
  {value: "gauge_radial", label: "Radial", gauge: true},
  {value: "gauge_linear", label: "Linear", gauge: true}
].freeze
LABELS =
METRIC_TYPES.to_h { |t| [t[:value], t[:label]] }.freeze

Instance Method Summary collapse

Constructor Details

#initialize(type:, css: "w-full h-full") ⇒ ChartShape

Returns a new instance of ChartShape.



28
29
30
31
# File 'lib/clowk/phlex/charts/chart_shape.rb', line 28

def initialize(type:, css: "w-full h-full")
  @type = type.to_s
  @css = css
end

Instance Method Details

#view_templateObject



33
34
35
36
37
38
39
40
41
# File 'lib/clowk/phlex/charts/chart_shape.rb', line 33

def view_template
  case @type
  when "bars" then bars
  when "line" then line
  when "gauge_radial" then radial
  when "gauge_linear" then linear
  else area
  end
end