Class: Ccharts::Settings::HeatSettings
- Inherits:
-
Object
- Object
- Ccharts::Settings::HeatSettings
- Defined in:
- lib/ccharts/settings.rb
Overview
heatmap
Instance Method Summary collapse
- #background(v) ⇒ Object
- #col_labels(v) ⇒ Object
- #high_color(v) ⇒ Object
-
#initialize ⇒ HeatSettings
constructor
A new instance of HeatSettings.
- #label_ptr_array(labels, keep) ⇒ Object
- #low_color(v) ⇒ Object
- #mid_color(v) ⇒ Object
- #plain(v) ⇒ Object
- #row_labels(v) ⇒ Object
- #show_labels(v) ⇒ Object
- #to_ffi ⇒ Object
Constructor Details
#initialize ⇒ HeatSettings
Returns a new instance of HeatSettings.
284 285 286 287 288 289 290 291 292 293 |
# File 'lib/ccharts/settings.rb', line 284 def initialize @low = nil @high = nil @mid = nil @bg = nil @row_labels = nil @col_labels = nil @show_labels = false @plain = false end |
Instance Method Details
#background(v) ⇒ Object
298 |
# File 'lib/ccharts/settings.rb', line 298 def background(v); @bg = v; self; end |
#col_labels(v) ⇒ Object
300 |
# File 'lib/ccharts/settings.rb', line 300 def col_labels(v); @col_labels = v; self; end |
#high_color(v) ⇒ Object
296 |
# File 'lib/ccharts/settings.rb', line 296 def high_color(v); @high = v; self; end |
#label_ptr_array(labels, keep) ⇒ Object
304 305 306 307 308 309 310 311 312 |
# File 'lib/ccharts/settings.rb', line 304 def label_ptr_array(labels, keep) return Fiddle::NULL if labels.nil? || labels.empty? ptrs = labels.map do |l| p = FFI.cstr(l) keep << p p.to_i end Fiddle::Pointer[ptrs.pack("Q*")] end |
#low_color(v) ⇒ Object
295 |
# File 'lib/ccharts/settings.rb', line 295 def low_color(v); @low = v; self; end |
#mid_color(v) ⇒ Object
297 |
# File 'lib/ccharts/settings.rb', line 297 def mid_color(v); @mid = v; self; end |
#plain(v) ⇒ Object
302 |
# File 'lib/ccharts/settings.rb', line 302 def plain(v); @plain = !!v; self; end |
#row_labels(v) ⇒ Object
299 |
# File 'lib/ccharts/settings.rb', line 299 def row_labels(v); @row_labels = v; self; end |
#show_labels(v) ⇒ Object
301 |
# File 'lib/ccharts/settings.rb', line 301 def show_labels(v); @show_labels = !!v; self; end |
#to_ffi ⇒ Object
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/ccharts/settings.rb', line 314 def to_ffi s = FFI::HeatSettings.malloc keep = [] set = lambda do |field, val| p = FFI.color_ptr(val, @plain) keep << p s[field] = p.to_i end set.call(:low_color, @low) set.call(:high_color, @high) set.call(:mid_color, @mid) set.call(:bg_color, @bg) s[:row_labels] = label_ptr_array(@row_labels, keep).to_i s[:col_labels] = label_ptr_array(@col_labels, keep).to_i s[:show_labels] = @show_labels ? 1 : 0 [s, keep] end |