Class: CTioga2::Graphics::Styles::ErrorBarStyle
- Inherits:
-
StrokeStyle
- Object
- BasicStyle
- LineStyle
- 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
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Attribute Summary collapse
-
#style ⇒ Object
The error bar style.
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 LineStyle
Methods inherited from BasicStyle
alias_for, attr_accessor, attribute_type, attribute_types, attributes, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other
Instance Attribute Details
#style ⇒ Object
The error bar style. For now, not much here.
32 33 34 |
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 32 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 ?
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 42 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 |