Class: Birt::Core::LineChartReport
- Inherits:
-
BaseReport
- Object
- BaseReport
- Birt::Core::LineChartReport
- Defined in:
- lib/birt/core/chart/line_chart_report.rb
Instance Attribute Summary collapse
-
#data_set ⇒ Object
Returns the value of attribute data_set.
-
#horizontal_label ⇒ Object
Returns the value of attribute horizontal_label.
-
#horizontal_row ⇒ Object
Returns the value of attribute horizontal_row.
-
#legend_label ⇒ Object
Returns the value of attribute legend_label.
-
#series_rows ⇒ Object
Returns the value of attribute series_rows.
-
#title_label ⇒ Object
Returns the value of attribute title_label.
-
#vertical_label ⇒ Object
Returns the value of attribute vertical_label.
Attributes inherited from BaseReport
Instance Method Summary collapse
-
#initialize(xml_e) {|_self| ... } ⇒ LineChartReport
constructor
A new instance of LineChartReport.
- #json ⇒ Object
Methods inherited from BaseReport
Constructor Details
#initialize(xml_e) {|_self| ... } ⇒ LineChartReport
Returns a new instance of LineChartReport.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 14 def initialize(xml_e) @series_rows = [] super(xml_e) do @title_label = elem_text(xml_e, "/model:ChartWithAxes/Block/Children[@xsi:type='layout:TitleBlock']/Label/Caption/Value") @legend_label = elem_text(xml_e, "/model:ChartWithAxes/Block/Children[@xsi:type='layout:Legend']/Title/Caption/Value") @vertical_label = elem_text(xml_e, "/model:ChartWithAxes/Axes/AssociatedAxes/Title/Caption/Value") @horizontal_label = elem_text(xml_e, "/model:ChartWithAxes/Axes/Title/Caption/Value") @horizontal_row = elem_text(xml_e, "/model:ChartWithAxes/Axes/SeriesDefinitions/Series/DataDefinition/Definition").gsub("row[\"", '').gsub("\"]", '') xml_e.get_elements("/model:ChartWithAxes/Axes/AssociatedAxes/SeriesDefinitions/Series[@xsi:type='type:LineSeries']").each do |item| @series_rows << Birt::Core::SeriesRow.new(item) end end yield(self) if block_given? end |
Instance Attribute Details
#data_set ⇒ Object
Returns the value of attribute data_set.
2 3 4 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 2 def data_set @data_set end |
#horizontal_label ⇒ Object
Returns the value of attribute horizontal_label.
7 8 9 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 7 def horizontal_label @horizontal_label end |
#horizontal_row ⇒ Object
Returns the value of attribute horizontal_row.
10 11 12 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 10 def horizontal_row @horizontal_row end |
#legend_label ⇒ Object
Returns the value of attribute legend_label.
5 6 7 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 5 def legend_label @legend_label end |
#series_rows ⇒ Object
Returns the value of attribute series_rows.
11 12 13 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 11 def series_rows @series_rows end |
#title_label ⇒ Object
Returns the value of attribute title_label.
4 5 6 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 4 def title_label @title_label end |
#vertical_label ⇒ Object
Returns the value of attribute vertical_label.
8 9 10 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 8 def vertical_label @vertical_label end |
Instance Method Details
#json ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/birt/core/chart/line_chart_report.rb', line 34 def json @json = {} @json[:id] = @id @json[:title] = @title_label data_set_result = self.data_set.data_set_result _series_data = ->(data_result, series_name) { if series_name =~ /\// name = series_name.split("/")[0] num = series_name.split("/")[1].to_i data_result.columns[data_result.column_headers.index(name)].inject([]) { |acc, item| acc<<item/num; acc } else data_result.columns[data_result.column_headers.index(series_name)] end } @json[:x_data] = data_set_result.columns[data_set_result.column_headers.index(@horizontal_row)] @json[:series] = [] @series_rows.each { |series_row| @json[:series] << { name: series_row.display_name, data: _series_data.call(data_set_result, series_row.column_name) } } @json end |