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)

    高さ



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

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)

    目盛アトリビュート



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

def at_interval_marks
  @at_interval_marks
end

#at_labelsHash

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

Returns:

  • (Hash)

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



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

def at_labels
  @at_labels
end

#at_scale_lineHash

Returns 軸アトリビュート.

Returns:

  • (Hash)

    軸アトリビュート



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

def at_scale_line
  @at_scale_line
end

#labelsArray, Nil

Returns 目盛ラベル.

Returns:

  • (Array, Nil)

    目盛ラベル



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

def labels
  @labels
end

#mode_labelSymbol, Nil

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

Returns:

  • (Symbol, Nil)

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



481
482
483
# File 'lib/al_graph.rb', line 481

def mode_label
  @mode_label
end

Instance Method Details

#add_gridObject

(Axis) グリッド線の付与



590
591
592
# File 'lib/al_graph.rb', line 590

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

#clear_gridObject

(Axis) グリッド線の消去



598
599
600
# File 'lib/al_graph.rb', line 598

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

#clear_interval_marksObject

(Axis) 間隔マークの消去



614
615
616
# File 'lib/al_graph.rb', line 614

def clear_interval_marks()
  @at_interval_marks.clear
end

#clear_labelsObject

(Axis) 目盛ラベルの消去



632
633
634
# File 'lib/al_graph.rb', line 632

def clear_labels()
 @at_labels.clear
end

#clear_scale_lineObject

(Axis) 軸線の消去



606
607
608
# File 'lib/al_graph.rb', line 606

def clear_scale_line()
  @at_scale_line.clear
end

#do_scalingBoolean

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

Returns:

  • (Boolean)

    成功時、真

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



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

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時、対数目盛にする



582
583
584
# File 'lib/al_graph.rb', line 582

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

#maxNumeric

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

Returns:

  • (Numeric)

    現在の目盛り最大値



530
531
532
# File 'lib/al_graph.rb', line 530

def max()
  @scale_max
end

#minNumeric

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

Returns:

  • (Numeric)

    現在の目盛り最小値



551
552
553
# File 'lib/al_graph.rb', line 551

def min()
  @scale_min
end

#reverse(f = true) ⇒ Object

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

Parameters:

  • f (Boolean) (defaults to: true)

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



572
573
574
# File 'lib/al_graph.rb', line 572

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

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

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

Parameters:

  • v (Numeric, Array<Numeric>)

    目盛り幅



561
562
563
# File 'lib/al_graph.rb', line 561

def set_interval(v)
  @scale_interval_user = v
end

#set_labels(labels) ⇒ Object

(Axis) 目盛ラベルの設定

Parameters:

  • labels (Array)

    目盛ラベル



624
625
626
# File 'lib/al_graph.rb', line 624

def set_labels(labels)
  @labels = labels
end

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

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

Parameters:

  • v (Numeric)

    目盛り最大値



519
520
521
# File 'lib/al_graph.rb', line 519

def set_max(v)
  @scale_max_user = v
end

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

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

Parameters:

  • v (Numeric)

    目盛り最小値



540
541
542
# File 'lib/al_graph.rb', line 540

def set_min(v)
  @scale_min_user = v
end