Class: AlGraphXY::XAxisReal

Inherits:
AlGraph::XAxis show all
Defined in:
lib/al_graph_xy.rb

Overview

XYグラフ及び散布図用 X軸クラス

Constant Summary

Constants inherited from AlGraph::GraphView

AlGraph::GraphView::ATTR_NAMES

Instance Attribute Summary

Attributes inherited from AlGraph::Axis

#at_interval_marks, #at_labels, #at_scale_line, #labels, #mode_label

Attributes inherited from AlGraph::GraphView

#data_series, #height, #width

Instance Method Summary collapse

Methods inherited from AlGraph::XAxis

#change_mode, #set_max, #set_min

Methods inherited from AlGraph::Axis

#add_grid, #clear_grid, #clear_interval_marks, #clear_labels, #clear_scale_line, #logarithmic, #max, #min, #reverse, #set_interval, #set_labels, #set_max, #set_min

Constructor Details

#initialize(width, height) ⇒ XAxisReal

(XAxisReal) constructor

Parameters:

  • width (Integer)

  • height (Integer)

    高さ



106
107
108
109
110
111
# File 'lib/al_graph_xy.rb', line 106

def initialize(width, height)
  super

  @scale_mode = :LINER
  @at_interval_marks[:grid] = true
end

Instance Method Details

#calc_pixcel_position(v) ⇒ Integer

(XAxisReal) 軸上のピクセル位置を計算する。

Parameters:

  • v (Numeric)

    実数

Returns:

  • (Integer)

    ピクセル位置

    引数が軸上にない場合、返り値も軸上にはないピクセル位置が返る。



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/al_graph_xy.rb', line 142

def calc_pixcel_position(v)
  case @scale_mode
  when :LINER
    x = (@width * (v - @scale_min) / @scale_max_min).to_i
  when :LOGARITHMIC
    x = (@width * Math.log10(v/@scale_min) / @scale_max_min).to_i
  else
    raise "Not support #{@scale_mode} mode."
  end
  return @flag_reverse ? @width - x : x
end

#do_scalingBoolean

(XAxisReal) 目盛りスケーリング

Returns:

  • (Boolean)

    成功時、真

    あらかじめ与えられているデータ系列情報などを元に、 オートスケール処理など、内部データの整合性をとる。



122
123
124
125
126
127
128
129
130
131
# File 'lib/al_graph_xy.rb', line 122

def do_scaling()
  case @scale_mode
  when :LINER
    do_scaling_liner(:@x_data)
  when :LOGARITHMIC
    do_scaling_logarithmic(:@x_data)
  else
    raise "Not support #{@scale_mode} mode."
  end
end