Class: Ccharts::Settings::PieSettings

Inherits:
Object
  • Object
show all
Defined in:
lib/ccharts/settings.rb

Overview

pie

Instance Method Summary collapse

Constructor Details

#initializePieSettings

Returns a new instance of PieSettings.



52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ccharts/settings.rb', line 52

def initialize
  @donut = false
  @colors = nil
  @show_legend = true
  @show_pct = false
  @slice_gap = 0.0
  @inner_radius_ratio = -1.0
  @legend_format = 0
  @start_angle = -1.0
  @counter_clockwise = false
  @center_text = nil
end

Instance Method Details

#_scalarsObject

Packed scalar arguments in ccharts_pie_from_slices order (the settings struct has no pie-specific fields; they are flat function arguments).



78
79
80
81
82
# File 'lib/ccharts/settings.rb', line 78

def _scalars
  [@donut ? 1 : 0, @show_legend ? 1 : 0, @show_pct ? 1 : 0,
   @slice_gap, @inner_radius_ratio, @legend_format, @start_angle,
   @counter_clockwise ? 1 : 0]
end

#center_text(v) ⇒ Object



74
# File 'lib/ccharts/settings.rb', line 74

def center_text(v); @center_text = v; self; end

#center_text_ptr(keep) ⇒ Object



88
89
90
91
92
93
# File 'lib/ccharts/settings.rb', line 88

def center_text_ptr(keep)
  return Fiddle::NULL if @center_text.nil?
  p = FFI.cstr(@center_text)
  keep << p
  p
end

#colors(v) ⇒ Object



66
# File 'lib/ccharts/settings.rb', line 66

def colors(v); @colors = v; self; end

#colors_countObject



84
85
86
# File 'lib/ccharts/settings.rb', line 84

def colors_count
  @colors ? @colors.length : 0
end

#colors_ptr(keep) ⇒ Object

Array of color escape pointers (index mod count), or Fiddle::NULL.



96
97
98
99
100
101
102
103
104
# File 'lib/ccharts/settings.rb', line 96

def colors_ptr(keep)
  return Fiddle::NULL if @colors.nil? || @colors.empty?
  ptrs = @colors.map do |c|
    p = FFI.color_ptr(c, false)
    keep << p
    p
  end
  Fiddle::Pointer[ptrs.pack("Q*")]
end

#counter_clockwise(v) ⇒ Object



73
# File 'lib/ccharts/settings.rb', line 73

def counter_clockwise(v); @counter_clockwise = !!v; self; end

#donut(v) ⇒ Object



65
# File 'lib/ccharts/settings.rb', line 65

def donut(v); @donut = !!v; self; end

#inner_radius_ratio(v) ⇒ Object



70
# File 'lib/ccharts/settings.rb', line 70

def inner_radius_ratio(v); @inner_radius_ratio = v; self; end

#legend_format(v) ⇒ Object



71
# File 'lib/ccharts/settings.rb', line 71

def legend_format(v); @legend_format = v; self; end

#show_legend(v) ⇒ Object



67
# File 'lib/ccharts/settings.rb', line 67

def show_legend(v); @show_legend = !!v; self; end

#show_pct(v) ⇒ Object



68
# File 'lib/ccharts/settings.rb', line 68

def show_pct(v); @show_pct = !!v; self; end

#slice_gap(v) ⇒ Object



69
# File 'lib/ccharts/settings.rb', line 69

def slice_gap(v); @slice_gap = v; self; end

#start_angle(v) ⇒ Object



72
# File 'lib/ccharts/settings.rb', line 72

def start_angle(v); @start_angle = v; self; end