Class: CTioga2::Graphics::Styles::ErrorBarStyle
- Inherits:
-
StrokeStyle
- Object
- BasicStyle
- StrokeStyle
- CTioga2::Graphics::Styles::ErrorBarStyle
- Defined in:
- lib/ctioga2/graphics/styles/errorbar.rb
Overview
This class represents the stylistic information necessary to draw an error bar. It derives from StrokeStyle, as it is essentially a stroke.
Constant Summary
Constants inherited from BasicStyle
Instance Attribute Summary collapse
-
#style ⇒ Object
The error bar style.
Attributes inherited from StrokeStyle
Instance Method Summary collapse
-
#show_error_bar(t, x, xmin, xmax, y, ymin, ymax) ⇒ Object
Shows an error bar with the appropriate stylistic information.
Methods inherited from StrokeStyle
Methods inherited from BasicStyle
attr_accessor, attributes, from_hash, #instance_variable_defined?, #set_from_hash, #to_hash, #update_from_other
Instance Attribute Details
#style ⇒ Object
The error bar style. For now, not much here.
34 35 36 |
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 34 def style @style end |
Instance Method Details
#show_error_bar(t, x, xmin, xmax, y, ymin, ymax) ⇒ Object
Shows an error bar with the appropriate stylistic information. x and y are the coordinates of the data point. The corresponding min and max are the minimum and maximum values for the error bars. If either is nil, no error bar on that direction is drawn.
todo maybe make provisions (one day) for complex error bars showing min/max and stddev as well ?
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 44 def (t, x, xmin, xmax, y, ymin, ymax) d = { 'x' => x, 'y' => y, 'color' => @color || Tioga::ColorConstants::Black, 'line_width' => @width || 1.0, } has = false if (xmin && xmax && (xmax - xmin != 0)) d['dx_plus'] = xmax - x d['dx_minus'] = x - xmin has = true end if (ymin && ymax && (ymax - ymin != 0)) d['dy_plus'] = ymax - y d['dy_minus'] = y - ymin has = true end # We won't draw something when there isn't anything to draw # ! if(has) t.(d) end end |