Class: CTioga2::Graphics::Styles::ErrorBarStyle

Inherits:
BasicStyle
  • Object
show all
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

Instance Method Summary collapse

Methods inherited from BasicStyle

alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other, #use_defaults_from

Instance Attribute Details

#styleObject

The error bar style. For now, not much here.



37
38
39
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 37

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 ?



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/ctioga2/graphics/styles/errorbar.rb', line 47

def show_error_bar(t, x, xmin, xmax, y, ymin, ymax)
  d = { 'x' => x,
    'y' => y,
    'color' => @line.color || Tioga::ColorConstants::Black,
    'line_width' => @line.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)
    # We should stop relying on Tioga for that.
    # Probably this is the place to reimplement that ?
    t.show_error_bars(d)
  end
end