Class: AlGraph::Axis

Inherits:
GraphView show all
Defined in:
lib/al_graph.rb

Overview

座標軸スーパークラス

Direct Known Subclasses

XAxis, YAxis

Constant Summary

Constants inherited from GraphView

GraphView::ATTR_NAMES

Instance Attribute Summary collapse

Attributes inherited from GraphView

#data_series, #height, #width

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ Axis

(Axis) constructor

Parameters:

  • width (Integer)

  • height (Integer)

    高さ



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
# File 'lib/al_graph.rb', line 489

def initialize(width, height)
  super

  # 軸アトリビュート
  @at_scale_line = {:stroke=>'black', :stroke_width=>1}
  # 目盛アトリビュート
  @at_interval_marks =
    {:length=>8, :stroke=>'#999999', :stroke_width=>1}
  # 目盛ラベルアトリビュート
  @at_labels = {:font_size=>10}

  @scale_mode = nil           # :ORDERED_LEFT :ORDERED_CENTER :LINER :LOGARITHMIC
  @scale_max = nil            # 目盛り最大値
  @scale_min = nil            # 目盛り最小値
  @scale_interval = nil       # 目盛り幅
  @scale_max_user = nil       # ユーザ設定目盛り最大値
  @scale_min_user = nil       # ユーザ設定目盛り最小値
  @scale_interval_user = nil  # ユーザ設定目盛り幅
  @scale_max_min= nil         # 最大値-最小値のキャッシュ
  @flag_reverse = false       # 目盛り逆方向(反転)フラグ
end

Instance Attribute Details

#at_interval_marksHash

Returns 目盛アトリビュート.

Returns:

  • (Hash)

    目盛アトリビュート



470
471
472
# File 'lib/al_graph.rb', line 470

def at_interval_marks
  @at_interval_marks
end

#at_labelsHash

Returns 目盛ラベルアトリビュート.

Returns:

  • (Hash)

    目盛ラベルアトリビュート



473
474
475
# File 'lib/al_graph.rb', line 473

def at_labels
  @at_labels
end

#at_scale_lineHash

Returns 軸アトリビュート.

Returns:

  • (Hash)

    軸アトリビュート



467
468
469
# File 'lib/al_graph.rb', line 467

def at_scale_line
  @at_scale_line
end

#labelsArray, Nil

Returns 目盛ラベル.

Returns:

  • (Array, Nil)

    目盛ラベル



476
477
478
# File 'lib/al_graph.rb', line 476

def labels
  @labels
end

#mode_labelSymbol, Nil

Returns 目盛ラベル描画モード :LABEL_NORMAL :LABEL_INTERVAL.

Returns:

  • (Symbol, Nil)

    目盛ラベル描画モード :LABEL_NORMAL :LABEL_INTERVAL



479
480
481
# File 'lib/al_graph.rb', line 479

def mode_label
  @mode_label
end

Instance Method Details

#add_gridObject

(Axis) グリッド線の付与



588
589
590
# File 'lib/al_graph.rb', line 588

def add_grid()
  @at_interval_marks[:grid] = true  if !@at_interval_marks.empty?
end

#clear_gridObject

(Axis) グリッド線の消去



596
597
598
# File 'lib/al_graph.rb', line 596

def clear_grid()
  @at_interval_marks[:grid] = false  if !@at_interval_marks.empty?
end

#clear_interval_marksObject

(Axis) 間隔マークの消去



612
613
614
# File 'lib/al_graph.rb', line 612

def clear_interval_marks()
  @at_interval_marks.clear
end

#clear_labelsObject

(Axis) 目盛ラベルの消去



630
631
632
# File 'lib/al_graph.rb', line 630

def clear_labels()
 @at_labels.clear
end

#clear_scale_lineObject

(Axis) 軸線の消去



604
605
606
# File 'lib/al_graph.rb', line 604

def clear_scale_line()
  @at_scale_line.clear
end

#do_scalingBoolean

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

Returns:

  • (Boolean)

    成功時、真

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



643
644
645
646
647
648
649
650
651
652
653
654
# File 'lib/al_graph.rb', line 643

def do_scaling()
  case @scale_mode
  when :ORDERED_LEFT, :ORDERED_CENTER
    do_scaling_ordered(:@x_data)
  when :LINER
    do_scaling_liner(:@y_data)
  when :LOGARITHMIC
    do_scaling_logarithmic(:@y_data)
  else
    raise
  end
end

#logarithmic(f = true) ⇒ Object

(Axis) 対数目盛の指示

Parameters:

  • f (Boolean) (defaults to: true)

    true時、対数目盛にする



580
581
582
# File 'lib/al_graph.rb', line 580

def logarithmic(f = true)
  @scale_mode = f ? :LOGARITHMIC : :LINER
end

#maxNumeric

(Axis) 目盛り最大値を取得する

Returns:

  • (Numeric)

    現在の目盛り最大値



528
529
530
# File 'lib/al_graph.rb', line 528

def max()
  @scale_max
end

#minNumeric

(Axis) 目盛り最小値を取得する

Returns:

  • (Numeric)

    現在の目盛り最小値



549
550
551
# File 'lib/al_graph.rb', line 549

def min()
  @scale_min
end

#reverse(f = true) ⇒ Object

(Axis) 目盛り逆方向(反転)指示

Parameters:

  • f (Boolean) (defaults to: true)

    true時、目盛りを反転させる



570
571
572
# File 'lib/al_graph.rb', line 570

def reverse(f = true)
  @flag_reverse = f
end

#set_interval(v) ⇒ Object Also known as: interval=

(Axis) 目盛り幅のユーザ指定

Parameters:

  • v (Numeric, Array<Numeric>)

    目盛り幅



559
560
561
# File 'lib/al_graph.rb', line 559

def set_interval(v)
  @scale_interval_user = v
end

#set_labels(labels) ⇒ Object

(Axis) 目盛ラベルの設定

Parameters:

  • labels (Array)

    目盛ラベル



622
623
624
# File 'lib/al_graph.rb', line 622

def set_labels(labels)
  @labels = labels
end

#set_max(v) ⇒ Object Also known as: max=

(Axis) 目盛り最大値のユーザ指定

Parameters:

  • v (Numeric)

    目盛り最大値



517
518
519
# File 'lib/al_graph.rb', line 517

def set_max(v)
  @scale_max_user = v
end

#set_min(v) ⇒ Object Also known as: min=

(Axis) 目盛り最小値のユーザ指定

Parameters:

  • v (Numeric)

    目盛り最小値



538
539
540
# File 'lib/al_graph.rb', line 538

def set_min(v)
  @scale_min_user = v
end