Class: JfreechartGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/libisi/chart/jfreechart_generator.rb

Overview

Copyright © 2007-2010 Logintas AG Switzerland

This file is part of Libisi.

Libisi is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

Libisi is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Libisi. If not, see <www.gnu.org/licenses/>.

Instance Method Summary collapse

Constructor Details

#initialize(chart, range_name, options = {}) ⇒ JfreechartGenerator

Returns a new instance of JfreechartGenerator.



20
21
22
23
24
# File 'lib/libisi/chart/jfreechart_generator.rb', line 20

def initialize(chart, range_name, options = {})
  @chart = chart
  @range_name = range_name
  @options = options
end

Instance Method Details

#generateToolTip(dataset, row, column) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/libisi/chart/jfreechart_generator.rb', line 26

def generateToolTip(dataset,row,column)
  row_key = dataset.getRowKey(row).toString
  col_key = dataset.getColumnKey(column).toString
    
  #p ["R", row, row_key,"C",column,col_key]
  "Range: #{@range_name} Row: #{row_key} Col: #{col_key}"
  

  case @options[:tooltip]
  when NilClass
    begin
	data = @chart.ranges[@range_name][row_key][col_key]      
	#p data
	ret = "#{row_key}/#{col_key}"
	ret += " #{data[:start]} - #{data[:end]}" if data[:start]
	ret += " (#{data[:percentage].to_s})" if data[:percentage]
	ret
    rescue
	"#{@range_name}/#{row_key}/#{col_key} (dnf)"
    end
  when Proc
    @options[:tooltip].call(range_name, row_key, col_key)
  when String
    @options[:tooltip]
  else
    raise "Unexpected tooltip class #{options[:tooltip]}"
  end
rescue
  $log.error($!)
  $log.error($!.backtrace.join("\n"))
  nil
end