Method: Writexlsx::Chart#data_id
- Defined in:
- lib/write_xlsx/chart.rb
#data_id(full_formula, data) ⇒ Object
Assign an id to a each unique series formula or title/axis formula. Repeated formulas such as for categories get the same id. If the series or title has user specified data associated with it then that is also stored. This data is used to populate cached Excel data when creating a chart. If there is no user defined data then it will be populated by the parent workbook in Workbook::_add_chart_data
541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 |
# File 'lib/write_xlsx/chart.rb', line 541 def data_id(full_formula, data) # :nodoc: return unless full_formula # Strip the leading '=' from the formula. formula = full_formula.sub(/^=/, '') # Store the data id in a hash keyed by the formula and store the data # in a separate array with the same id. if @formula_ids.has_key?(formula) # Formula already seen. Return existing id. id = @formula_ids[formula] # Store user defined data if it isn't already there. @formula_data[id] ||= data else # Haven't seen this formula before. id = @formula_ids[formula] = @formula_data.size @formula_data << data end id end |