Class: Tiler::Widgets::LineChart
- Inherits:
-
Tiler::Widget
- Object
- Tiler::Widget
- Tiler::Widgets::LineChart
- Defined in:
- lib/tiler/widgets/line_chart.rb
Instance Attribute Summary
Attributes inherited from Tiler::Widget
Class Method Summary collapse
- .example_config ⇒ Object
- .example_payload ⇒ Object
- .example_preview ⇒ Object
- .supports_color_config? ⇒ Boolean
- .supports_palette_config? ⇒ Boolean
Instance Method Summary collapse
Methods inherited from Tiler::Widget
#data, #initialize, #label, #partial, #query_class
Constructor Details
This class inherits a constructor from Tiler::Widget
Class Method Details
.example_config ⇒ Object
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/tiler/widgets/line_chart.rb', line 104 def self.example_config { "time_window" => "7d", "bucket" => "1d", "series" => [ { "label" => "requests", "column" => "rpm", "agg" => "sum" }, { "label" => "errors", "column" => "errors", "agg" => "sum" } ] } end |
.example_payload ⇒ Object
115 116 117 |
# File 'lib/tiler/widgets/line_chart.rb', line 115 def self.example_payload { "rpm" => 2_847, "errors" => 4 } end |
.example_preview ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/tiler/widgets/line_chart.rb', line 119 def self.example_preview { "labels" => %w[Mon Tue Wed Thu Fri Sat Sun], "datasets" => [ { "label" => "requests", "data" => [ 1800, 2200, 2050, 2600, 2950, 2400, 2847 ], "borderColor" => "#3b82f6", "backgroundColor" => "#3b82f633", "tension" => 0.3, "fill" => false }, { "label" => "errors×100", "data" => [ 12, 8, 15, 10, 5, 7, 4 ], "borderColor" => "#10b981", "backgroundColor" => "#10b98133", "tension" => 0.3, "fill" => false } ], "options" => {} } end |
.supports_color_config? ⇒ Boolean
101 |
# File 'lib/tiler/widgets/line_chart.rb', line 101 def self.supports_color_config?; true; end |
.supports_palette_config? ⇒ Boolean
102 |
# File 'lib/tiler/widgets/line_chart.rb', line 102 def self.supports_palette_config?; true; end |
Instance Method Details
#empty?(data) ⇒ Boolean
95 96 97 98 99 |
# File 'lib/tiler/widgets/line_chart.rb', line 95 def empty?(data) return true if super data.nil? || data[:datasets].blank? || data[:datasets].all? { |ds| Array(ds[:data]).all? { |v| v.nil? || v.zero? } } end |