Class: AlGraph::DataContainer

Inherits:
Object
  • Object
show all
Defined in:
lib/al_graph.rb

Overview

データコンテナ スーパークラス

Direct Known Subclasses

ContainerBar, ContainerLine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ydata, legend = nil) ⇒ DataContainer

(DataContainer) constructor

Parameters:

  • ydata (Array<Numeric>)

    Y値データ

  • legend (String) (defaults to: nil)

    凡例文字列



1793
1794
1795
1796
# File 'lib/al_graph.rb', line 1793

def initialize(ydata, legend = nil)
  @y_data = ydata
  @legend = legend
end

Instance Attribute Details

#at_data_labelsHash, Nil

Returns データラベルアトリビュート.

Returns:

  • (Hash, Nil)

    データラベルアトリビュート



1768
1769
1770
# File 'lib/al_graph.rb', line 1768

def at_data_labels
  @at_data_labels
end

#idString

Returns ID.

Returns:

  • (String)

    ID



1762
1763
1764
# File 'lib/al_graph.rb', line 1762

def id
  @id
end

#labelsArray, Nil

Returns データラベル.

Returns:

  • (Array, Nil)

    データラベル



1771
1772
1773
# File 'lib/al_graph.rb', line 1771

def labels
  @labels
end

#legendString

Returns 凡例文字列.

Returns:

  • (String)

    凡例文字列



1774
1775
1776
# File 'lib/al_graph.rb', line 1774

def legend
  @legend
end

#plotLinePlot, BarPlot

Returns 使用するプロットオブジェクト.

Returns:



1783
1784
1785
# File 'lib/al_graph.rb', line 1783

def plot
  @plot
end

#x_axisXAxis

Returns 使用するX軸オブジェクト.

Returns:

  • (XAxis)

    使用するX軸オブジェクト



1777
1778
1779
# File 'lib/al_graph.rb', line 1777

def x_axis
  @x_axis
end

#y_axisYAxis

Returns 使用するY軸オブジェクト.

Returns:

  • (YAxis)

    使用するY軸オブジェクト



1780
1781
1782
# File 'lib/al_graph.rb', line 1780

def y_axis
  @y_axis
end

#y_dataArray<Numeric>

Returns Y値データ.

Returns:

  • (Array<Numeric>)

    Y値データ



1765
1766
1767
# File 'lib/al_graph.rb', line 1765

def y_data
  @y_data
end

Instance Method Details

#add_data_labels(pos = :ABOVE) ⇒ Object

(DataContainer) 値ラベルを表示

Parameters:

  • pos (String, Symbol) (defaults to: :ABOVE)

    値ラベルの位置 (ABOVE|BELOW|LEFT|RIGHT|CENTER)

    位置以外は、デフォルト値で表示するよう設定。



1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
# File 'lib/al_graph.rb', line 1806

def add_data_labels(pos = :ABOVE)
  pos = pos.to_sym
  case pos
  when :ABOVE, :BELOW, :CENTER
    @at_data_labels = {position:pos, font_size:9, text_anchor:'middle'}
  when :LEFT
    @at_data_labels = {position:pos, font_size:9, text_anchor:'end'}
  when :RIGHT
    @at_data_labels = {position:pos, font_size:9, text_anchor:'start'}
  else
    raise "Illegal parameter #{pos}"
  end
end

#eachObject

(DataContainer) イテレータ



1832
1833
1834
1835
1836
# File 'lib/al_graph.rb', line 1832

def each()
  @y_data.each_with_index {|yd, i|
    yield( i, yd ,i )
  }
end

#sizeObject

(DataContainer) データ数を返す



1824
1825
1826
# File 'lib/al_graph.rb', line 1824

def size()
  return @y_data.size()
end