Class: AlGraphXY::GraphXY
- Inherits:
-
AlGraph::Graph
- Object
- AlGraph::GraphView
- AlGraph::GraphBase
- AlGraph::Graph
- AlGraphXY::GraphXY
- Defined in:
- lib/al_graph_xy.rb
Overview
XYグラフ用クラス
Direct Known Subclasses
Constant Summary
Constants inherited from AlGraph::Graph
Constants inherited from AlGraph::GraphBase
AlGraph::GraphBase::COLOR_LIST
Constants inherited from AlGraph::GraphView
AlGraph::GraphView::ATTR_NAMES
Instance Attribute Summary
Attributes inherited from AlGraph::Graph
#at_xaxis_title, #at_xaxis_unit, #at_y2axis_unit, #at_yaxis_title, #at_yaxis_unit, #bar_plot, #line_plot, #shape_list, #x_axis, #y2_axis, #y_axis
Attributes inherited from AlGraph::GraphBase
#at_graph_area, #at_legend, #at_main_title, #at_plot_area, #color_list, #output
Attributes inherited from AlGraph::GraphView
Instance Method Summary collapse
-
#add_data(data1, data2, legend = nil) ⇒ ContainerXY
(GraphXY) データ追加.
-
#add_data_pair(data, legend = nil) ⇒ ContainerXY
(GraphXY) データペア追加.
-
#initialize(width = 320, height = 240) ⇒ GraphXY
constructor
(GraphXY) constructor.
Methods inherited from AlGraph::Graph
#add_data_bar, #add_data_line, #add_data_line_y2, #add_xaxis_title, #add_xaxis_unit, #add_y2axis_unit, #add_yaxis_title, #add_yaxis_unit, #draw, #set_margin
Methods inherited from AlGraph::GraphBase
#add_aux_tag, #add_legend, #add_main_title, #add_text, #draw_buffer, #set_margin, #set_mode
Constructor Details
Instance Method Details
#add_data(data1, data2, legend = nil) ⇒ ContainerXY
(GraphXY) データ追加
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/al_graph_xy.rb', line 49 def add_data(data1, data2, legend = nil) add_legend() if legend @line_plot = AlGraph::LinePlot.new(@width, @height) if ! @line_plot data_obj = ContainerXY.new(data1, data2, legend) data_obj.x_axis = @x_axis data_obj.y_axis = @y_axis data_obj.plot = @line_plot data_obj.at_marker[:shape] = @shape_list[ @data_series.size % @shape_list.size ] data_obj.at_marker[:fill] = @color_list[ @data_series.size % @color_list.size ] data_obj.at_plot_line[:stroke] = data_obj.at_marker[:fill] add_data_series(data_obj) @line_plot.add_data_series(data_obj) @x_axis.add_data_series(data_obj) @y_axis.add_data_series(data_obj) return data_obj end |
#add_data_pair(data, legend = nil) ⇒ ContainerXY
(GraphXY) データペア追加
[[x1,y1],…] もしくは [x1,y1,x2,y2…] の型式でデータを与える
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/al_graph_xy.rb', line 79 def add_data_pair(data, legend = nil) data1 = [] data2 = [] data.flatten.each_slice(2) {|d1, d2| data1 << d1 data2 << d2 } return add_data(data1, data2, legend) end |