Class: MotionPlot::Pie
- Inherits:
-
Base
- Object
- Base
- MotionPlot::Pie
show all
- Defined in:
- lib/motion-plot/chart/pie_plot.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#axes, #data_label, #graph, #layer_hosting_view, #legend, #major_grid_line_style, #plot_options, #plot_space, #plots, #series, #theme, #title, #xaxis, #yaxis
Instance Method Summary
collapse
Methods inherited from Base
#add_axis_title, #add_chart_title, #add_legend, #add_plot_space, #add_plot_symbol, #add_xy_range, #bootstrap, #initWithOptions
Instance Attribute Details
#selected_slice ⇒ Object
Returns the value of attribute selected_slice.
4
5
6
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 4
def selected_slice
@selected_slice
end
|
Instance Method Details
#add_series ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 6
def add_series
pie = CPTPieChart.alloc.init
pie.dataSource = self
pie.delegate = self
pie.pieRadius = pie_radius
pie.startAngle = Math::PI/4
pie.sliceDirection = CPTPieDirectionClockwise pie.identifier = plot_identifier
series_data.each_with_index {|obj, i| @selected_slice = i if(obj[:selected]) }
add_gradient(pie)
animate(pie)
@graph.addPlot(pie)
@plots << pie
end
|
#dataLabelForPlot(plot, recordIndex: index) ⇒ Object
60
61
62
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 60
def dataLabelForPlot(plot, recordIndex: index)
@data_label.annotation_text_style(series_data[index][:y].round(2))
end
|
#default_padding ⇒ Object
24
25
26
27
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 24
def default_padding
pie_series.style.paddings_for(@graph)
pie_series.style.plot_area.add_style(@graph.plotAreaFrame)
end
|
#legendTitleForPieChart(pie, recordIndex: index) ⇒ Object
37
38
39
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 37
def legendTitleForPieChart(pie, recordIndex: index)
series_data[index][:name]
end
|
#numberForPlot(plot, field: fieldEnum, recordIndex: index) ⇒ Object
33
34
35
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 33
def numberForPlot(plot, field: fieldEnum, recordIndex: index)
fieldEnum == CPTPieChartFieldSliceWidth ? series_data[index][:y] : index
end
|
#numberOfRecordsForPlot(plot) ⇒ Object
29
30
31
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 29
def numberOfRecordsForPlot(plot)
series_data.size
end
|
#pieChart(plot, sliceWasSelectedAtRecordIndex: index) ⇒ Object
55
56
57
58
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 55
def pieChart(plot, sliceWasSelectedAtRecordIndex: index)
@selected_slice = index
plot.reloadData
end
|
#radialOffsetForPieChart(plot, recordIndex: index) ⇒ Object
45
46
47
48
49
50
51
52
53
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 45
def radialOffsetForPieChart(plot, recordIndex: index)
offset = 0.0
if(@selected_slice == index)
offset = pie_radius / 25.0
end
offset
end
|
#sliceFillForPieChart(plot, recordIndex: index) ⇒ Object
41
42
43
|
# File 'lib/motion-plot/chart/pie_plot.rb', line 41
def sliceFillForPieChart(plot, recordIndex: index)
CPTFill.alloc.initWithColor Series::COLORS[index].to_color.to_cpt_color
end
|