Class: YuiRestClient::Widgets::Bargraph
- Defined in:
- lib/yui_rest_client/widgets/bargraph.rb
Overview
Class representing a bar graph in the UI, namely YBarGraph.
Instance Method Summary collapse
-
#labels ⇒ Array
Returns the labels list of all segments in the bar graph.
-
#segments ⇒ Array
Returns the list of segments in the bar graph.
-
#values ⇒ Array
Returns the values list of all segments in the bar graph.
Methods inherited from Base
#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property
Methods included from YuiRestClient::Waitable
Constructor Details
This class inherits a constructor from YuiRestClient::Widgets::Base
Instance Method Details
#labels ⇒ Array
Returns the labels list of all segments in the bar graph.
48 49 50 |
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 48 def labels segments.map { |segment| segment[:label] } end |
#segments ⇒ Array
Returns the list of segments in the bar graph. Each segment is defined by label and value. Segment length is defined by proportional ratio of the segment value. For instance, if segment values are 100, 200, 700: it means first segment will take 100/1000=10%, second 20% and third one 70% accordingly. {
"class" : "YBarGraph",
"id" : "test_id",
"segments" :
[
{
"label" : "Windows\nused\n%1 MB",
"value" : 600
},
{
"label" : "Windows\nfree\n%1 MB",
"value" : 350
},
{
"label" : "Linux\n%1 MB",
"value" : 800
}
],
}
39 40 41 |
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 39 def segments property(:segments) end |
#values ⇒ Array
Returns the values list of all segments in the bar graph.
57 58 59 |
# File 'lib/yui_rest_client/widgets/bargraph.rb', line 57 def values segments.map { |segment| segment[:value] } end |