Class: Tiler::Widgets::PieChart
Instance Attribute Summary
#config, #panel
Class Method Summary
collapse
Instance Method Summary
collapse
#data, #initialize, #label, #partial, #query_class
Constructor Details
This class inherits a constructor from Tiler::Widget
Class Method Details
.example_config ⇒ Object
86
87
88
|
# File 'lib/tiler/widgets/pie_chart.rb', line 86
def self.example_config
{ "group_column" => "status", "aggregation" => "count", "limit" => 6 }
end
|
.example_payload ⇒ Object
90
91
92
|
# File 'lib/tiler/widgets/pie_chart.rb', line 90
def self.example_payload
{ "status" => "ok" }
end
|
.example_preview ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/tiler/widgets/pie_chart.rb', line 94
def self.example_preview
{
"labels" => %w[ok warn error],
"datasets" => [
{ "data" => [ 70, 20, 10 ],
"backgroundColor" => [ "#3b82f6cc", "#f59e0bcc", "#ef4444cc" ],
"borderColor" => [ "#3b82f6", "#f59e0b", "#ef4444" ],
"borderWidth" => 2 }
],
"options" => { "plugins" => { "legend" => { "position" => "right" } } }
}
end
|
.supports_color_config? ⇒ Boolean
83
|
# File 'lib/tiler/widgets/pie_chart.rb', line 83
def self.supports_color_config?; true; end
|
.supports_palette_config? ⇒ Boolean
84
|
# File 'lib/tiler/widgets/pie_chart.rb', line 84
def self.supports_palette_config?; true; end
|
Instance Method Details
#empty?(data) ⇒ Boolean
77
78
79
80
81
|
# File 'lib/tiler/widgets/pie_chart.rb', line 77
def empty?(data)
return true if super
data.nil? || data[:labels].blank? || data[:datasets].blank? ||
data[:datasets].all? { |ds| Array(ds[:data]).all? { |v| v.nil? || v.zero? } }
end
|