Class: Chart
- Inherits:
-
Worksheet
- Object
- BIFFWriter
- Worksheet
- Chart
- Defined in:
- lib/writeexcel/chart.rb,
lib/writeexcel/charts/bar.rb,
lib/writeexcel/charts/pie.rb,
lib/writeexcel/charts/area.rb,
lib/writeexcel/charts/line.rb,
lib/writeexcel/charts/stock.rb,
lib/writeexcel/charts/column.rb,
lib/writeexcel/charts/scatter.rb
Overview
Chart
Chart - A writer class for Excel Charts.
Defined Under Namespace
Classes: Area, Bar, Column, Line, Pie, Scatter, Stock
Constant Summary collapse
- NonAscii =
:nodoc:
/[^!"#\$%&'\(\)\*\+,\-\.\/\:\;<=>\?@0-9A-Za-z_\[\\\]^` ~\0\n]/
Constants inherited from Worksheet
Worksheet::Buffer, Worksheet::ColMax, Worksheet::RowMax, Worksheet::StrMax
Constants inherited from BIFFWriter
BIFFWriter::BIFF_Version, BIFFWriter::BigEndian
Instance Attribute Summary
Attributes inherited from BIFFWriter
Class Method Summary collapse
-
.factory(klass, *args) ⇒ Object
factory().
Instance Method Summary collapse
-
#add_series(params) ⇒ Object
Add a series and it’s properties to a chart.
-
#close ⇒ Object
_close(), overridden.
-
#data=(val) ⇒ Object
:nodoc:.
-
#embedded ⇒ Object
:nodoc:.
-
#embedded=(val) ⇒ Object
:nodoc:.
-
#encode_utf16(str, encoding = 0) ⇒ Object
_encode_utf16().
-
#get_color_indices(color) ⇒ Object
_get_color_indices().
-
#get_color_rbg(index) ⇒ Object
_get_color_rbg().
-
#get_line_pattern(value) ⇒ Object
_get_line_pattern().
-
#get_line_weight(value) ⇒ Object
_get_line_weight().
-
#initialize(*args) ⇒ Chart
constructor
:call-seq: new(filename, name, index, encoding, activesheet, firstsheet, external_bin = nil).
-
#parse_series_formula(formula) ⇒ Object
_parse_series_formula().
-
#prepend(*args) ⇒ Object
_prepend(), overridden.
-
#set_chartarea(params = {}) ⇒ Object
set_chartarea().
-
#set_default_config_data ⇒ Object
_set_default_config_data().
-
#set_default_properties ⇒ Object
_set_default_properties().
-
#set_embedded_config_data ⇒ Object
_set_embedded_config_data().
-
#set_legend(params = {}) ⇒ Object
set_legend().
-
#set_plotarea(params = {}) ⇒ Object
set_plotarea().
-
#set_title(params) ⇒ Object
The set_title() method is used to set properties of the chart title.
-
#set_x_axis(params) ⇒ Object
Set the properties of the X-axis.
-
#set_y_axis(params) ⇒ Object
Set the properties of the Y-axis.
-
#store_3dbarshape ⇒ Object
_store_3dbarshape().
-
#store_ai(id, type, formula, format_index = 0) ⇒ Object
_store_ai().
-
#store_areaformat(rgbFore, rgbBack, pattern, grbit, indexFore, indexBack) ⇒ Object
_store_areaformat().
-
#store_axcext ⇒ Object
_store_axcext().
-
#store_axesused(num_axes) ⇒ Object
_store_axesused().
-
#store_axis(type) ⇒ Object
_store_axis().
-
#store_axis_category_stream ⇒ Object
_store_axis_category_stream().
-
#store_axis_values_stream ⇒ Object
_store_axis_values_stream().
-
#store_axislineformat ⇒ Object
_store_axislineformat().
-
#store_axisparent(iax, x, y, dx, dy) ⇒ Object
_store_axisparent().
-
#store_axisparent_stream ⇒ Object
_store_axisparent_stream().
-
#store_begin ⇒ Object
_store_begin().
-
#store_catserrange ⇒ Object
_store_catserrange().
-
#store_chart(x_pos, y_pos, dx, dy) ⇒ Object
_store_chart().
-
#store_chart_stream ⇒ Object
_store_chart_stream().
-
#store_chart_type ⇒ Object
_store_chart_type().
-
#store_chartarea_frame_stream ⇒ Object
_store_chartarea_frame_stream().
-
#store_chartformat(grbit = 0) ⇒ Object
_store_chartformat().
-
#store_chartformat_stream ⇒ Object
_store_chartformat_stream().
-
#store_chartline ⇒ Object
_store_chartline().
-
#store_charttext ⇒ Object
_store_charttext().
-
#store_dataformat(series_index, series_number, point_number) ⇒ Object
_store_dataformat().
-
#store_dataformat_stream(series_index) ⇒ Object
_store_dataformat_stream().
-
#store_defaulttext ⇒ Object
_store_defaulttext().
-
#store_dropbar ⇒ Object
_store_dropbar().
-
#store_end ⇒ Object
_store_end().
-
#store_fbi(index, height, width_basis, height_basis, scale_basis) ⇒ Object
_store_fbi().
-
#store_fontx(index) ⇒ Object
_store_fontx().
-
#store_frame(frame_type, grbit) ⇒ Object
_store_frame().
-
#store_legend(x, y, width, height, wType, wSpacing, grbit) ⇒ Object
_store_legend().
-
#store_legend_stream ⇒ Object
_store_legend_stream().
-
#store_legend_text_stream ⇒ Object
_store_legend_text_stream().
-
#store_lineformat(rgb, lns, we, grbit, index) ⇒ Object
_store_lineformat().
-
#store_marker_dataformat_stream ⇒ Object
_store_marker_dataformat_stream().
-
#store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize) ⇒ Object
_store_markerformat().
-
#store_objectlink(link_type) ⇒ Object
_store_objectlink().
-
#store_pieformat ⇒ Object
_store_pieformat().
-
#store_plotarea ⇒ Object
_store_plotarea().
-
#store_plotarea_frame_stream ⇒ Object
_store_plotarea_frame_stream().
-
#store_plotgrowth ⇒ Object
_store_plotgrowth().
-
#store_pos(mdTopLt, mdBotRt, x1, y1, x2, y2) ⇒ Object
_store_pos().
-
#store_serauxtrend(reg_type, poly_order, equation, r_squared) ⇒ Object
_store_serauxtrend().
-
#store_series(category_count, value_count) ⇒ Object
_store_series().
-
#store_series_stream(params) ⇒ Object
_store_series_stream().
-
#store_series_text_stream(font_index) ⇒ Object
_store_series_text_stream().
-
#store_seriestext(str, encoding) ⇒ Object
_store_seriestext().
-
#store_serparent(series) ⇒ Object
_store_serparent().
-
#store_sertocrt ⇒ Object
_store_sertocrt().
-
#store_shtprops ⇒ Object
_store_shtprops().
-
#store_text(x, y, dx, dy, grbit1, grbit2, rotation = 0x00) ⇒ Object
_store_text().
-
#store_tick ⇒ Object
_store_tick().
-
#store_title_text_stream ⇒ Object
_store_title_text_stream().
-
#store_valuerange ⇒ Object
_store_valuerange().
-
#store_window2 ⇒ Object
_store_window2(), overridden.
-
#store_x_axis_text_stream ⇒ Object
_store_x_axis_text_stream().
-
#store_y_axis_text_stream ⇒ Object
_store_y_axis_text_stream().
-
#using_tmpfile=(val) ⇒ Object
:nodoc:.
Methods inherited from Worksheet
#activate, #active=, #add_write_handler, #autofilter, #center_horizontally, #center_vertically, #comment_params, #convert_date_time, #data_validation, #date_1904=, #encoding, #extract_filter_tokens, #filter_area, #filter_column, #filter_count, #fit_to_pages, #freeze_panes, #hidden, #hidden=, #hide, #hide_gridlines, #hide_zero, #image_mso_size, #image_mso_size=, #images_array, #index, #index=, #insert_chart, #insert_image, #keep_leading_zeros, #merge_cells, #merge_range, #name, #num_images, #num_images=, #object_ids=, #offset, #offset=, #outline_settings, #pack_dv_formula, #pack_dv_string, #parse_filter_expression, #position_object, #prepare_charts, #prepare_comments, #prepare_images, #print_across, #print_area, #print_colmax, #print_colmin, #print_row_col_headers, #print_rowmax, #print_rowmin, #protect, #repeat_columns, #repeat_formula, #repeat_rows, #right_to_left, #select, #selected, #selected=, #set_column, #set_comments_author, #set_first_row_column, #set_first_sheet, #set_footer, #set_h_pagebreaks, #set_header, #set_landscape, #set_margin_bottom, #set_margin_left, #set_margin_right, #set_margin_top, #set_margins, #set_margins_LR, #set_margins_TB, #set_page_view, #set_paper, #set_portrait, #set_print_scale, #set_row, #set_selection, #set_start_page, #set_tab_color, #set_v_pagebreaks, #set_zoom, #sheet_type, #show_comments, #split_panes, #store_autofilter, #store_colinfo, #store_dimensions, #store_dval, #store_filtermode, #store_formula, #store_mso_client_anchor, #store_mso_client_data, #store_mso_client_text_box, #store_mso_dg, #store_mso_dg_container, #store_mso_drawing_text_box, #store_mso_opt_chart, #store_mso_opt_comment, #store_mso_opt_filter, #store_mso_opt_image, #store_mso_sp, #store_mso_sp_container, #store_mso_spgr, #store_mso_spgr_container, #store_note, #store_obj_chart, #store_obj_comment, #store_obj_filter, #store_obj_image, #store_selection, #store_txo, #store_txo_continue_1, #store_txo_continue_2, #title_colmax, #title_colmin, #title_rowmax, #title_rowmin, #write, #write_blank, #write_col, #write_comment, #write_date_time, #write_formula, #write_number, #write_row, #write_string, #write_url, #write_url_range, #write_utf16be_string, #write_utf16le_string
Methods inherited from BIFFWriter
#add_continue, #add_mso_generic, #append, #clear_data_for_test, #get_data, #not_using_tmpfile, #set_byte_order, #store_bof, #store_eof
Constructor Details
#initialize(*args) ⇒ Chart
:call-seq:
new(filename, name, index, encoding, activesheet, firstsheet, external_bin = nil)
Default constructor for sub-classes.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/writeexcel/chart.rb', line 70 def initialize(*args) #:nodoc: super @sheet_type = 0x0200 @orientation = 0x0 @series = [] @embedded = false @external_bin = false @x_axis_formula = nil @x_axis_name = nil @y_axis_formula = nil @y_axis_name = nil @title_name = nil @title_formula = nil @vary_data_color = 0 set_default_properties set_default_config_data end |
Class Method Details
.factory(klass, *args) ⇒ Object
factory()
Factory method for returning chart objects based on their class type.
59 60 61 |
# File 'lib/writeexcel/chart.rb', line 59 def self.factory(klass, *args) #:nodoc: klass.new(*args) end |
Instance Method Details
#add_series(params) ⇒ Object
Add a series and it’s properties to a chart.
In an Excel chart a “series” is a collection of information such as values, x-axis labels and the name that define which data is plotted. These settings are displayed when you select the Chart -> Source Data… menu option.
With a WriteExcel chart object the add_series() method is used to set the properties for a series:
chart.add_series(
:categories => '=Sheet1!$A$2:$A$10',
:values => '=Sheet1!$B$2:$B$10',
:name => 'Series name',
:name_formula => '=Sheet1!$B$1'
)
The properties that can be set are:
:values (required)
:categories (optional for most chart types)
:name (optional)
:name_formula (optional)
* :values
This is the most important property of a series and must be set for
every chart object. It links the chart with the worksheet data that
it displays.
chart.add_series(:values => '=Sheet1!$B$2:$B$10')
Note the format that should be used for the formula. It is the same
as is used in Excel. You must also add the worksheet that you are
referring to before you link to it, via the workbook
add_worksheet() method.
* :categories
This sets the chart category labels. The category is more or less
the same as the X-axis. In most chart types the categories property
is optional and the chart will just assume a sequential series
from 1 .. n.
chart.add_series(
:categories => '=Sheet1!$A$2:$A$10',
:values => '=Sheet1!$B$2:$B$10'
)
* :name
Set the name for the series. The name is displayed in the chart
legend and in the formula bar. The name property is optional and
if it isn't supplied will default to Series 1 .. n.
chart.add_series(
...
:name => 'Series name'
)
* :name_formula
Optional, can be used to link the name to a worksheet cell.
See "Chart names and links".
chart.add_series(
...
:name => 'Series name',
:name_formula => '=Sheet1!$B$1'
)
You can add more than one series to a chart. The series numbering and order in the final chart is the same as the order in which that are added.
# Add the first series.
chart.add_series(
:categories => '=Sheet1!$A$2:$A$7',
:values => '=Sheet1!$B$2:$B$7',
:name => 'Test data series 1'
)
# Add another series. Category is the same but values are different.
chart.add_series(
:categories => '=Sheet1!$A$2:$A$7',
:values => '=Sheet1!$C$2:$C$7',
:name => 'Test data series 2'
)
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/writeexcel/chart.rb', line 179 def add_series(params) raise "Must specify 'values' in add_series()" if params[:values].nil? # Parse the ranges to validate them and extract salient information. value_data = parse_series_formula(params[:values]) category_data = parse_series_formula(params[:categories]) name_formula = parse_series_formula(params[:name_formula]) # Default category count to the same as the value count if not defined. category_data[1] = value_data[1] if category_data.size < 2 # Add the parsed data to the user supplied data. params[:values] = value_data params[:categories] = category_data params[:name_formula] = name_formula # Encode the Series name. name, encoding = encode_utf16(params[:name], params[:name_encoding]) params[:name] = name params[:name_encoding] = encoding @series << params end |
#close ⇒ Object
_close(), overridden.
Create and store the Chart data structures.
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File 'lib/writeexcel/chart.rb', line 492 def close # :nodoc: # Ignore any data that has been written so far since it is probably # from unwanted Worksheet method calls. @data = '' # TODO. Check for charts without a series? # Store the chart BOF. store_bof(0x0020) # Store the page header store_header # Store the page footer # Store the page horizontal centering store_hcenter # Store the page vertical centering store_vcenter # Store the left margin store_margin_left # Store the right margin store_margin_right # Store the top margin store_margin_top # Store the bottom margin store_margin_bottom # Store the page setup store_setup # Store the sheet password store_password # Start of Chart specific records. # Store the FBI font records. store_fbi(*@config[:font_numbers]) store_fbi(*@config[:font_series]) store_fbi(*@config[:font_title]) store_fbi(*@config[:font_axes]) # Ignore UNITS record. # Store the Chart sub-stream. store_chart_stream # Append the sheet dimensions store_dimensions # TODO add SINDEX and NUMBER records. store_window2 unless @embedded store_eof end |
#data=(val) ⇒ Object
:nodoc:
458 459 460 |
# File 'lib/writeexcel/chart.rb', line 458 def data=(val) # :nodoc: @data = val end |
#embedded ⇒ Object
:nodoc:
462 463 464 |
# File 'lib/writeexcel/chart.rb', line 462 def # :nodoc: @embedded end |
#embedded=(val) ⇒ Object
:nodoc:
466 467 468 |
# File 'lib/writeexcel/chart.rb', line 466 def (val) # :nodoc: @embedded = val end |
#encode_utf16(str, encoding = 0) ⇒ Object
_encode_utf16()
Convert UTF8 strings used in the chart to UTF16.
661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 |
# File 'lib/writeexcel/chart.rb', line 661 def encode_utf16(str, encoding = 0) # :nodoc: # Exit if the $string isn't defined, i.e., hasn't been set by user. return [nil, nil] if str.nil? string = str.dup # Return if encoding is set, i.e., string has been manually encoded. #return ( undef, undef ) if $string == 1; # Handle utf8 strings in perl 5.8. if string =~ NonAscii string = NKF.nkf('-w16B0 -m0 -W', string) encoding = 1 end # Chart strings are limited to 255 characters. limit = encoding != 0 ? 255 * 2 : 255 if string.length >= limit # truncate the string and raise a warning. string = string[0, limit] end [string, encoding] end |
#get_color_indices(color) ⇒ Object
_get_color_indices()
Convert the user specified colour index or string to an colour index and RGB colour number.
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
# File 'lib/writeexcel/chart.rb', line 693 def get_color_indices(color) # :nodoc: return [nil, nil] if color.nil? colors = { :aqua => 0x0F, :cyan => 0x0F, :black => 0x08, :blue => 0x0C, :brown => 0x10, :magenta => 0x0E, :fuchsia => 0x0E, :gray => 0x17, :grey => 0x17, :green => 0x11, :lime => 0x0B, :navy => 0x12, :orange => 0x35, :pink => 0x21, :purple => 0x14, :red => 0x0A, :silver => 0x16, :white => 0x09, :yellow => 0x0D, } # Check for the various supported colour index/name possibilities. color = color.downcase.to_sym if color.kind_of?(String) if color.kind_of?(Symbol) if colors.has_key?(color) # Colour matches one of the supported colour names. index = colors[color] else return [nil, nil] end elsif color < 8 || color > 63 # Return undef if index is out of range. return [nil, nil] else # We should have a valid color index in a valid range. index = color end rgb = get_color_rbg(index) return [index, rgb] end |
#get_color_rbg(index) ⇒ Object
_get_color_rbg()
Get the RedGreenBlue number for the colour index from the Workbook palette.
745 746 747 748 749 750 751 |
# File 'lib/writeexcel/chart.rb', line 745 def get_color_rbg(index) # :nodoc: # Adjust colour index from 8-63 (user range) to 0-55 (Excel range). index -= 8 red_green_blue = @palette[index] red_green_blue.pack('C*').unpack('V')[0] end |
#get_line_pattern(value) ⇒ Object
_get_line_pattern()
Get the Excel chart index for line pattern that corresponds to the user defined value.
760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 |
# File 'lib/writeexcel/chart.rb', line 760 def get_line_pattern(value) # :nodoc: value = value.downcase if value.kind_of?(String) default = 0 patterns = { 0 => 5, 1 => 0, 2 => 1, 3 => 2, 4 => 3, 5 => 4, 6 => 7, 7 => 6, 8 => 8, 'solid' => 0, 'dash' => 1, 'dot' => 2, 'dash-dot' => 3, 'dash-dot-dot' => 4, 'none' => 5, 'dark-gray' => 6, 'medium-gray' => 7, 'light-gray' => 8, } if patterns.has_key?(value) patterns[value] else default end end |
#get_line_weight(value) ⇒ Object
_get_line_weight()
Get the Excel chart index for line weight that corresponds to the user defined value.
799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 |
# File 'lib/writeexcel/chart.rb', line 799 def get_line_weight(value) # :nodoc: value = value.downcase if value.kind_of?(String) default = 0 weights = { 1 => -1, 2 => 0, 3 => 1, 4 => 2, 'hairline' => -1, 'narrow' => 0, 'medium' => 1, 'wide' => 2, } if weights.has_key?(value) weights[value] else default end end |
#parse_series_formula(formula) ⇒ Object
_parse_series_formula()
Parse the formula used to define a series. We also extract some range information required for _store_series() and the SERIES record.
614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
# File 'lib/writeexcel/chart.rb', line 614 def parse_series_formula(formula) # :nodoc: encoding = 0 length = 0 count = 0 tokens = [] return [''] if formula.nil? # Strip the = sign at the beginning of the formula string formula = formula.sub(/^=/, '') # Parse the formula using the parser in Formula.pm parser = @parser # In order to raise formula errors from the point of view of the calling # program we use an eval block and re-raise the error from here. # tokens = parser.parse_formula(formula) # Force ranges to be a reference class. tokens.collect! { |t| t.gsub(/_ref3d/, '_ref3dR') } tokens.collect! { |t| t.gsub(/_range3d/, '_range3dR') } tokens.collect! { |t| t.gsub(/_name/, '_nameR') } # Parse the tokens into a formula string. formula = parser.parse_tokens(tokens) # Return formula for a single cell as used by title and series name. return formula if formula[0] == 0x3A # Extract the range from the parse formula. if formula[0] == 0x3B ptg, ext_ref, row_1, row_2, col_1, col_2 = formula.unpack('Cv5') # TODO. Remove high bit on relative references. count = row_2 - row_1 + 1 end [formula, count] end |
#prepend(*args) ⇒ Object
_prepend(), overridden.
The parent Worksheet class needs to store some data in memory and some in temporary files for efficiency. The Chart* classes don’t need to do this since they are dealing with smaller amounts of data so we override _prepend() to turn it into an _append() method. This allows for a more natural method calling order.
480 481 482 483 484 |
# File 'lib/writeexcel/chart.rb', line 480 def prepend(*args) # :nodoc: @using_tmpfile = false print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(*args) end |
#set_chartarea(params = {}) ⇒ Object
set_chartarea()
Set the properties of the chart chartarea.
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 |
# File 'lib/writeexcel/chart.rb', line 398 def set_chartarea(params = {}) return if params.empty? area = @chartarea # Embedded automatic line weight has a different default value. area[:line_weight] = 0xFFFF if @embedded # Set the chart background colour. if params.has_key?(:color) index, rgb = get_color_indices(params[:color]) if !index.nil? area[:fg_color_index] = index area[:fg_color_rgb] = rgb area[:bg_color_index] = 0x08 area[:bg_color_rgb] = 0x000000 area[:area_pattern] = 1 area[:area_options] = 0x0000 if @embedded area[:visible] = 1 end end # Set the border line colour. if params.has_key?(:line_color) index, rgb = get_color_indices(params[:line_color]) if !index.nil? area[:line_color_index] = index area[:line_color_rgb] = rgb area[:line_pattern] = 0x00 area[:line_options] = 0x0000 area[:visible] = 1 end end # Set the border line pattern. if params.has_key?(:line_pattern) pattern = get_line_pattern(params[:line_pattern]) area[:line_pattern] = pattern area[:line_options] = 0x0000 area[:line_color_index] = 0x4F unless params.has_key?(:line_color) area[:visible] = 1 end # Set the border line weight. if params.has_key?(:line_weight) weight = get_line_weight(params[:line_weight]) area[:line_weight] = weight area[:line_options] = 0x0000 area[:line_pattern] = 0x00 unless params.has_key?(:line_pattern) area[:line_color_index] = 0x4F unless params.has_key?(:line_color) area[:visible] = 1 end end |
#set_default_config_data ⇒ Object
_set_default_config_data()
Setup the default configuration data for a chart.
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 |
# File 'lib/writeexcel/chart.rb', line 2234 def set_default_config_data # :nodoc: #<<< Perltidy ignore this. @config = { :axisparent => [ 0, 0x00F8, 0x01F5, 0x0E7F, 0x0B36 ], :axisparent_pos => [ 2, 2, 0x008C, 0x01AA, 0x0EEA, 0x0C52 ], :chart => [ 0x0000, 0x0000, 0x02DD51E0, 0x01C2B838 ], :font_numbers => [ 5, 10, 0x38B8, 0x22A1, 0x0000 ], :font_series => [ 6, 10, 0x38B8, 0x22A1, 0x0001 ], :font_title => [ 7, 12, 0x38B8, 0x22A1, 0x0000 ], :font_axes => [ 8, 10, 0x38B8, 0x22A1, 0x0001 ], :legend => [ 0x05F9, 0x0EE9, 0x047D, 0x9C, 0x00, 0x01, 0x0F ], :legend_pos => [ 5, 2, 0x05F9, 0x0EE9, 0, 0 ], :legend_text => [ 0xFFFFFF46, 0xFFFFFF06, 0, 0, 0x00B1, 0x0000 ], :legend_text_pos => [ 2, 2, 0, 0, 0, 0 ], :series_text => [ 0xFFFFFF46, 0xFFFFFF06, 0, 0, 0x00B1, 0x1020 ], :series_text_pos => [ 2, 2, 0, 0, 0, 0 ], :title_text => [ 0x06E4, 0x0051, 0x01DB, 0x00C4, 0x0081, 0x1030 ], :title_text_pos => [ 2, 2, 0, 0, 0x73, 0x1D ], :x_axis_text => [ 0x07E1, 0x0DFC, 0xB2, 0x9C, 0x0081, 0x0000 ], :x_axis_text_pos => [ 2, 2, 0, 0, 0x2B, 0x17 ], :y_axis_text => [ 0x002D, 0x06AA, 0x5F, 0x1CC, 0x0281, 0x00, 90 ], :y_axis_text_pos => [ 2, 2, 0, 0, 0x17, 0x44 ], } #>>> end |
#set_default_properties ⇒ Object
_set_default_properties()
Setup the default properties for a chart.
2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 |
# File 'lib/writeexcel/chart.rb', line 2190 def set_default_properties # :nodoc: @legend = { :visible => 1, :position => 0, :vertical => 0, } @chartarea = { :visible => 0, :fg_color_index => 0x4E, :fg_color_rgb => 0xFFFFFF, :bg_color_index => 0x4D, :bg_color_rgb => 0x000000, :area_pattern => 0x0000, :area_options => 0x0000, :line_pattern => 0x0005, :line_weight => 0xFFFF, :line_color_index => 0x4D, :line_color_rgb => 0x000000, :line_options => 0x0008, } @plotarea = { :visible => 1, :fg_color_index => 0x16, :fg_color_rgb => 0xC0C0C0, :bg_color_index => 0x4F, :bg_color_rgb => 0x000000, :area_pattern => 0x0001, :area_options => 0x0000, :line_pattern => 0x0000, :line_weight => 0x0000, :line_color_index => 0x17, :line_color_rgb => 0x808080, :line_options => 0x0000, } end |
#set_embedded_config_data ⇒ Object
_set_embedded_config_data()
Setup the default configuration data for an embedded chart.
2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 |
# File 'lib/writeexcel/chart.rb', line 2265 def # :nodoc: @embedded = true @chartarea = { :visible => 1, :fg_color_index => 0x4E, :fg_color_rgb => 0xFFFFFF, :bg_color_index => 0x4D, :bg_color_rgb => 0x000000, :area_pattern => 0x0001, :area_options => 0x0001, :line_pattern => 0x0000, :line_weight => 0x0000, :line_color_index => 0x4D, :line_color_rgb => 0x000000, :line_options => 0x0009, } #<<< Perltidy ignore this. @config = { :axisparent => [ 0, 0x01D8, 0x031D, 0x0D79, 0x07E9 ], :axisparent_pos => [ 2, 2, 0x010C, 0x0292, 0x0E46, 0x09FD ], :chart => [ 0x0000, 0x0000, 0x01847FE8, 0x00F47FE8 ], :font_numbers => [ 5, 10, 0x1DC4, 0x1284, 0x0000 ], :font_series => [ 6, 10, 0x1DC4, 0x1284, 0x0001 ], :font_title => [ 7, 12, 0x1DC4, 0x1284, 0x0000 ], :font_axes => [ 8, 10, 0x1DC4, 0x1284, 0x0001 ], :legend => [ 0x044E, 0x0E4A, 0x088D, 0x0123, 0x0, 0x1, 0xF ], :legend_pos => [ 5, 2, 0x044E, 0x0E4A, 0, 0 ], :legend_text => [ 0xFFFFFFD9, 0xFFFFFFC1, 0, 0, 0x00B1, 0x0000 ], :legend_text_pos => [ 2, 2, 0, 0, 0, 0 ], :series_text => [ 0xFFFFFFD9, 0xFFFFFFC1, 0, 0, 0x00B1, 0x1020 ], :series_text_pos => [ 2, 2, 0, 0, 0, 0 ], :title_text => [ 0x060F, 0x004C, 0x038A, 0x016F, 0x0081, 0x1030 ], :title_text_pos => [ 2, 2, 0, 0, 0x73, 0x1D ], :x_axis_text => [ 0x07EF, 0x0C8F, 0x153, 0x123, 0x81, 0x00 ], :x_axis_text_pos => [ 2, 2, 0, 0, 0x2B, 0x17 ], :y_axis_text => [ 0x0057, 0x0564, 0xB5, 0x035D, 0x0281, 0x00, 90 ], :y_axis_text_pos => [ 2, 2, 0, 0, 0x17, 0x44 ], } #>>> end |
#set_legend(params = {}) ⇒ Object
set_legend()
Set the properties of the chart legend.
331 332 333 334 335 336 337 |
# File 'lib/writeexcel/chart.rb', line 331 def set_legend(params = {}) if params.has_key?(:position) if params[:position].downcase == 'none' legend[:visible] = 0 end end end |
#set_plotarea(params = {}) ⇒ Object
set_plotarea()
Set the properties of the chart plotarea.
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 |
# File 'lib/writeexcel/chart.rb', line 345 def set_plotarea(params = {}) return if params.empty? area = @plotarea # Set the plotarea visibility. if params.has_key?(:visible) area[:visible] = params[:visible] return if area[:visible] == 0 end # TODO. could move this out of if statement. area[:bg_color_index] = 0x08 # Set the chart background colour. if params.has_key?(:color) index, rgb = get_color_indices(params[:color]) if !index.nil? area[:fg_color_index] = index area[:fg_color_rgb] = rgb area[:bg_color_index] = 0x08 area[:bg_color_rgb] = 0x000000 end end # Set the border line colour. if params.has_key?(:line_color) index, rgb = get_color_indices(params[:line_color]) if !index.nil? area[:line_color_index] = index area[:line_color_rgb] = rgb end end # Set the border line pattern. if params.has_key?(:line_pattern) pattern = get_line_pattern(params[:line_pattern]) area[:line_pattern] = pattern end # Set the border line weight. if params.has_key?(:line_weight) weight = get_line_weight(params[:line_weight]) area[:line_weight] = weight end end |
#set_title(params) ⇒ Object
The set_title() method is used to set properties of the chart title.
chart.set_title(:name => 'Year End Results')
The properties that can be set are:
:name (optional)
:name_formula (optional)
* :name
Set the name (title) for the chart. The name is displayed above the
chart. This property is optional. The default is to have no chart
title.
chart.set_title(:name => 'Year End Results')
* :name_formula
Optional, can be used to link the name to a worksheet cell.
See "Chart names and links".
chart.set_title(
:name => 'Year End Results',
:name_formula => '=Sheet1!$C$1'
)
315 316 317 318 319 320 321 322 323 |
# File 'lib/writeexcel/chart.rb', line 315 def set_title(params) name, encoding = encode_utf16( params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @title_name = name @title_encoding = encoding @title_formula = formula end |
#set_x_axis(params) ⇒ Object
Set the properties of the X-axis.
The set_x_axis() method is used to set properties of the X axis.
chart.set_x_axis(:name => 'Sample length (m)' )
The properties that can be set are:
:name (optional)
:name_formula (optional)
* :name
Set the name (title or caption) for the axis. The name is displayed
below the X axis. This property is optional. The default is to have
no axis name.
chart.set_x_axis( :name => 'Sample length (m)' )
* :name_formula
Optional, can be used to link the name to a worksheet cell.
See "Chart names and links".
chart.set_x_axis(
:name => 'Sample length (m)',
:name_formula => '=Sheet1!$A$1'
)
Additional axis properties such as range, divisions and ticks will be made available in later releases.
236 237 238 239 240 241 242 243 |
# File 'lib/writeexcel/chart.rb', line 236 def set_x_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @x_axis_name = name @x_axis_encoding = encoding @x_axis_formula = formula end |
#set_y_axis(params) ⇒ Object
Set the properties of the Y-axis.
The set_y_axis() method is used to set properties of the Y axis.
chart.set_y_axis(:name => 'Sample weight (kg)' )
The properties that can be set are:
:name (optional)
:name_formula (optional)
* :name
Set the name (title or caption) for the axis. The name is displayed
to the left of the Y axis. This property is optional. The default
is to have no axis name.
chart.set_y_axis(:name => 'Sample weight (kg)' )
* :name_formula
Optional, can be used to link the name to a worksheet cell.
See "Chart names and links".
chart.set_y_axis(
:name => 'Sample weight (kg)',
:name_formula => '=Sheet1!$B$1'
)
Additional axis properties such as range, divisions and ticks will be made available in later releases.
278 279 280 281 282 283 284 285 |
# File 'lib/writeexcel/chart.rb', line 278 def set_y_axis(params) name, encoding = encode_utf16(params[:name], params[:name_encoding]) formula = parse_series_formula(params[:name_formula]) @y_axis_name = name @y_axis_encoding = encoding @y_axis_formula = formula end |
#store_3dbarshape ⇒ Object
_store_3dbarshape()
Write the 3DBARSHAPE chart BIFF record.
1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 |
# File 'lib/writeexcel/chart.rb', line 1227 def # :nodoc: record = 0x105F # Record identifier. length = 0x0002 # Number of bytes to follow. riser = 0x00 # Shape of base. taper = 0x00 # Column taper type. header = [record, length].pack('vv') data = [riser].pack('C') data += [taper].pack('C') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_ai(id, type, formula, format_index = 0) ⇒ Object
_store_ai()
Write the AI chart BIFF record.
1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 |
# File 'lib/writeexcel/chart.rb', line 1247 def store_ai(id, type, formula, format_index = 0) # :nodoc: formula = '' if formula == [""] record = 0x1051 # Record identifier. length = 0x0008 # Number of bytes to follow. # id # Link index. # type # Reference type. # formula # Pre-parsed formula. # format_index # Num format index. grbit = 0x0000 # Option flags. formula_length = formula.length length += formula_length header = [record, length].pack('vv') data = [id].pack('C') data += [type].pack('C') data += [grbit].pack('v') data += [format_index].pack('v') data += [formula_length].pack('v') data += formula[0].kind_of?(String) ? formula[0] : formula print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_areaformat(rgbFore, rgbBack, pattern, grbit, indexFore, indexBack) ⇒ Object
_store_areaformat()
Write the AREAFORMAT chart BIFF record. Contains the patterns and colours of a chart area.
1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 |
# File 'lib/writeexcel/chart.rb', line 1280 def store_areaformat(rgbFore, rgbBack, pattern, grbit, indexFore, indexBack) # :nodoc: record = 0x100A # Record identifier. length = 0x0010 # Number of bytes to follow. # rgbFore # Foreground RGB colour. # rgbBack # Background RGB colour. # pattern # Pattern. # grbit # Option flags. # indexFore # Index to Foreground colour. # indexBack # Index to Background colour. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [pattern].pack('v') data += [grbit].pack('v') data += [indexFore].pack('v') data += [indexBack].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axcext ⇒ Object
_store_axcext()
Write the AXCEXT chart BIFF record.
1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 |
# File 'lib/writeexcel/chart.rb', line 1308 def store_axcext # :nodoc: record = 0x1062 # Record identifier. length = 0x0012 # Number of bytes to follow. catMin = 0x0000 # Minimum category on axis. catMax = 0x0000 # Maximum category on axis. catMajor = 0x0001 # Value of major unit. unitMajor = 0x0000 # Units of major unit. catMinor = 0x0001 # Value of minor unit. unitMinor = 0x0000 # Units of minor unit. unitBase = 0x0000 # Base unit of axis. catCrossDate = 0x0000 # Crossing point. grbit = 0x00EF # Option flags. header = [record, length].pack('vv') data = [catMin].pack('v') data += [catMax].pack('v') data += [catMajor].pack('v') data += [unitMajor].pack('v') data += [catMinor].pack('v') data += [unitMinor].pack('v') data += [unitBase].pack('v') data += [catCrossDate].pack('v') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axesused(num_axes) ⇒ Object
_store_axesused()
Write the AXESUSED chart BIFF record.
1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 |
# File 'lib/writeexcel/chart.rb', line 1342 def store_axesused(num_axes) # :nodoc: record = 0x1046 # Record identifier. length = 0x0002 # Number of bytes to follow. # num_axes # Number of axes used. header = [record, length].pack('vv') data = [num_axes].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axis(type) ⇒ Object
_store_axis()
Write the AXIS chart BIFF record to define the axis type.
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 |
# File 'lib/writeexcel/chart.rb', line 1360 def store_axis(type) # :nodoc: record = 0x101D # Record identifier. length = 0x0012 # Number of bytes to follow. # type # Axis type. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. header = [record, length].pack('vv') data = [type].pack('v') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axis_category_stream ⇒ Object
_store_axis_category_stream()
Write the AXIS chart substream for the chart category.
1072 1073 1074 1075 1076 1077 1078 1079 1080 |
# File 'lib/writeexcel/chart.rb', line 1072 def store_axis_category_stream # :nodoc: store_axis(0) store_begin store_catserrange store_axcext store_tick store_end end |
#store_axis_values_stream ⇒ Object
_store_axis_values_stream()
Write the AXIS chart substream for the chart values.
1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 |
# File 'lib/writeexcel/chart.rb', line 1088 def store_axis_values_stream # :nodoc: store_axis(1) store_begin store_valuerange store_tick store_axislineformat store_lineformat(0x00000000, 0x0000, 0xFFFF, 0x0009, 0x004D) store_end end |
#store_axislineformat ⇒ Object
_store_axislineformat()
Write the AXISLINEFORMAT chart BIFF record.
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 |
# File 'lib/writeexcel/chart.rb', line 1386 def store_axislineformat # :nodoc: record = 0x1021 # Record identifier. length = 0x0002 # Number of bytes to follow. line_format = 0x0001 # Axis line format. header = [record, length].pack('vv') data = [line_format].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axisparent(iax, x, y, dx, dy) ⇒ Object
_store_axisparent()
Write the AXISPARENT chart BIFF record.
1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 |
# File 'lib/writeexcel/chart.rb', line 1404 def store_axisparent(iax, x, y, dx, dy) # :nodoc: record = 0x1041 # Record identifier. length = 0x0012 # Number of bytes to follow. # iax # Axis index. # x # X-coord. # y # Y-coord. # dx # Length of x axis. # dy # Length of y axis. header = [record, length].pack('vv') data = [iax].pack('v') data += [x].pack('V') data += [y].pack('V') data += [dx].pack('V') data += [dy].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_axisparent_stream ⇒ Object
_store_axisparent_stream()
Write the AXISPARENT chart substream.
1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 |
# File 'lib/writeexcel/chart.rb', line 1042 def store_axisparent_stream # :nodoc: store_axisparent(*@config[:axisparent]) store_begin store_pos(*@config[:axisparent_pos]) store_axis_category_stream store_axis_values_stream if !@x_axis_name.nil? || !@x_axis_formula.nil? store_x_axis_text_stream end if !@y_axis_name.nil? || !@y_axis_formula.nil? store_y_axis_text_stream(); end if @plotarea[:visible] != 0 store_plotarea store_plotarea_frame_stream end store_chartformat_stream store_end end |
#store_begin ⇒ Object
_store_begin()
Write the BEGIN chart BIFF record to indicate the start of a sub stream.
1430 1431 1432 1433 1434 1435 1436 1437 1438 |
# File 'lib/writeexcel/chart.rb', line 1430 def store_begin # :nodoc: record = 0x1033 # Record identifier. length = 0x0000 # Number of bytes to follow. header = [record, length].pack('vv') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header) end |
#store_catserrange ⇒ Object
_store_catserrange()
Write the CATSERRANGE chart BIFF record.
1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 |
# File 'lib/writeexcel/chart.rb', line 1446 def store_catserrange # :nodoc: record = 0x1020 # Record identifier. length = 0x0008 # Number of bytes to follow. catCross = 0x0001 # Value/category crossing. catLabel = 0x0001 # Frequency of labels. catMark = 0x0001 # Frequency of ticks. grbit = 0x0001 # Option flags. header = [record, length].pack('vv') data = [catCross].pack('v') data += [catLabel].pack('v') data += [catMark].pack('v') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_chart(x_pos, y_pos, dx, dy) ⇒ Object
_store_chart()
Write the CHART BIFF record. This indicates the start of the chart sub-stream and contains dimensions of the chart on the display. Units are in 1/72 inch and are 2 byte integer with 2 byte fraction.
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
# File 'lib/writeexcel/chart.rb', line 1472 def store_chart(x_pos, y_pos, dx, dy) # :nodoc: record = 0x1002 # Record identifier. length = 0x0010 # Number of bytes to follow. # x_pos # X pos of top left corner. # y_pos # Y pos of top left corner. # dx # X size. # dy # Y size. header = [record, length].pack('vv') data = [x_pos].pack('V') data += [y_pos].pack('V') data += [dx].pack('V') data += [dy].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_chart_stream ⇒ Object
_store_chart_stream()
Store the CHART record and it’s substreams.
827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 |
# File 'lib/writeexcel/chart.rb', line 827 def store_chart_stream # :nodoc: store_chart(*@config[:chart]) store_begin # Store the chart SCL record. store_plotgrowth if @chartarea[:visible] != 0 store_chartarea_frame_stream end # Store SERIES stream for each series. index = 0 @series.each do |series| store_series_stream( :index => index, :value_formula => series[:values][0], :value_count => series[:values][1], :category_count => series[:categories][1], :category_formula => series[:categories][0], :name => series[:name], :name_encoding => series[:name_encoding], :name_formula => series[:name_formula] ) index += 1 end store_shtprops # Write the TEXT streams. (5..6).each do |font_index| store_defaulttext store_series_text_stream(font_index) end store_axesused(1) store_axisparent_stream if !@title_name.nil? || !@title_formula.nil? store_title_text_stream end store_end end |
#store_chart_type ⇒ Object
_store_chart_type()
This is an abstract method that is overridden by the sub-classes to define the chart types such as Column, Line, Pie, etc.
1185 1186 1187 |
# File 'lib/writeexcel/chart.rb', line 1185 def store_chart_type # :nodoc: end |
#store_chartarea_frame_stream ⇒ Object
_store_chartarea_frame_stream()
Write the FRAME chart substream for and embedded chart.
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 |
# File 'lib/writeexcel/chart.rb', line 1132 def store_chartarea_frame_stream # :nodoc: area = @chartarea store_frame(0x00, 0x02) store_begin store_lineformat( area[:line_color_rgb], area[:line_pattern], area[:line_weight], area[:line_options], area[:line_color_index] ) store_areaformat( area[:fg_color_rgb], area[:bg_color_rgb], area[:area_pattern], area[:area_options], area[:fg_color_index], area[:bg_color_index] ) store_end end |
#store_chartformat(grbit = 0) ⇒ Object
_store_chartformat()
Write the CHARTFORMAT chart BIFF record. The parent record for formatting of a chart group.
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 |
# File 'lib/writeexcel/chart.rb', line 1497 def store_chartformat(grbit = 0) # :nodoc: record = 0x1014 # Record identifier. length = 0x0014 # Number of bytes to follow. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. # grbit # Option flags. icrt = 0x0000 # Drawing order. header = [record, length].pack('vv') data = [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [icrt].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_chartformat_stream ⇒ Object
_store_chartformat_stream()
Write the CHARTFORMAT chart substream.
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 |
# File 'lib/writeexcel/chart.rb', line 1159 def store_chartformat_stream # :nodoc: # The _vary_data_color is set by classes that need it, like Pie. store_chartformat(@vary_data_color) store_begin # Store the BIFF record that will define the chart type. store_chart_type # Note, the CHARTFORMATLINK record is only written by Excel. if @legend[:visible] store_legend_stream end store_marker_dataformat_stream store_end end |
#store_chartline ⇒ Object
_store_chartline()
Write the CHARTLINE chart BIFF record.
1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
# File 'lib/writeexcel/chart.rb', line 1525 def store_chartline # :nodoc: record = 0x101C # Record identifier. length = 0x0002 # Number of bytes to follow. type = 0x0001 # Drop/hi-lo line type. header = [record, length].pack('vv') data = [type].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_charttext ⇒ Object
_store_charttext()
Write the TEXT chart BIFF record.
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 |
# File 'lib/writeexcel/chart.rb', line 1543 def store_charttext # :nodoc: record = 0x1025 # Record identifier. length = 0x0020 # Number of bytes to follow. horz_align = 0x02 # Horizontal alignment. vert_align = 0x02 # Vertical alignment. bg_mode = 0x0001 # Background display. text_color_rgb = 0x00000000 # Text RGB colour. text_x = 0xFFFFFF46 # Text x-pos. text_y = 0xFFFFFF06 # Text y-pos. text_dx = 0x00000000 # Width. text_dy = 0x00000000 # Height. grbit1 = 0x00B1 # Options text_color_index = 0x004D # Auto Colour. grbit2 = 0x0000 # Data label placement. rotation = 0x0000 # Text rotation. header = [record, length].pack('vv') data = [horz_align].pack('C') data += [vert_align].pack('C') data += [bg_mode].pack('v') data += [text_color_rgb].pack('V') data += [text_x].pack('V') data += [text_y].pack('V') data += [text_dx].pack('V') data += [text_dy].pack('V') data += [grbit1].pack('v') data += [text_color_index].pack('v') data += [grbit2].pack('v') data += [rotation].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_dataformat(series_index, series_number, point_number) ⇒ Object
_store_dataformat()
Write the DATAFORMAT chart BIFF record. This record specifies the series that the subsequent sub stream refers to.
1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 |
# File 'lib/writeexcel/chart.rb', line 1584 def store_dataformat(series_index, series_number, point_number) # :nodoc: record = 0x1006 # Record identifier. length = 0x0008 # Number of bytes to follow. # series_index # Series index. # series_number # Series number. (Same as index). # point_number # Point number. grbit = 0x0000 # Format flags. header = [record, length].pack('vv') data = [point_number].pack('v') data += [series_index].pack('v') data += [series_number].pack('v') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_dataformat_stream(series_index) ⇒ Object
_store_dataformat_stream()
Write the DATAFORMAT chart substream.
916 917 918 919 920 921 922 |
# File 'lib/writeexcel/chart.rb', line 916 def store_dataformat_stream(series_index) # :nodoc: store_dataformat(series_index, series_index, 0xFFFF) store_begin store_end end |
#store_defaulttext ⇒ Object
_store_defaulttext()
Write the DEFAULTTEXT chart BIFF record. Identifier for subsequent TEXT record.
1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 |
# File 'lib/writeexcel/chart.rb', line 1609 def store_defaulttext # :nodoc: record = 0x1024 # Record identifier. length = 0x0002 # Number of bytes to follow. type = 0x0002 # Type. header = [record, length].pack('vv') data = [type].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_dropbar ⇒ Object
_store_dropbar()
Write the DROPBAR chart BIFF record.
1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 |
# File 'lib/writeexcel/chart.rb', line 1627 def # :nodoc: record = 0x103D # Record identifier. length = 0x0002 # Number of bytes to follow. percent_gap = 0x0096 # Drop bar width gap (%). header = [record, length].pack('vv') data = [percent_gap].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_end ⇒ Object
_store_end()
Write the END chart BIFF record to indicate the end of a sub stream.
1645 1646 1647 1648 1649 1650 1651 1652 1653 |
# File 'lib/writeexcel/chart.rb', line 1645 def store_end # :nodoc: record = 0x1034 # Record identifier. length = 0x0000 # Number of bytes to follow. header = [record, length].pack('vv') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header) end |
#store_fbi(index, height, width_basis, height_basis, scale_basis) ⇒ Object
_store_fbi()
Write the FBI chart BIFF record. Specifies the font information at the time it was applied to the chart.
1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 |
# File 'lib/writeexcel/chart.rb', line 1661 def store_fbi(index, height, width_basis, height_basis, scale_basis) # :nodoc: record = 0x1060 # Record identifier. length = 0x000A # Number of bytes to follow. # index # Font index. height = height * 20 # Default font height in twips. # width_basis # Width basis, in twips. # height_basis # Height basis, in twips. # scale_basis # Scale by chart area or plot area. header = [record, length].pack('vv') data = [width_basis].pack('v') data += [height_basis].pack('v') data += [height].pack('v') data += [scale_basis].pack('v') data += [index].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_fontx(index) ⇒ Object
_store_fontx()
Write the FONTX chart BIFF record which contains the index of the FONT record in the Workbook.
1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 |
# File 'lib/writeexcel/chart.rb', line 1688 def store_fontx(index) # :nodoc: record = 0x1026 # Record identifier. length = 0x0002 # Number of bytes to follow. # index # Font index. header = [record, length].pack('vv') data = [index].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_frame(frame_type, grbit) ⇒ Object
_store_frame()
Write the FRAME chart BIFF record.
1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 |
# File 'lib/writeexcel/chart.rb', line 1706 def store_frame(frame_type, grbit) # :nodoc: record = 0x1032 # Record identifier. length = 0x0004 # Number of bytes to follow. # frame_type # Frame type. # grbit # Option flags. header = [record, length].pack('vv') data = [frame_type].pack('v') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_legend(x, y, width, height, wType, wSpacing, grbit) ⇒ Object
_store_legend()
Write the LEGEND chart BIFF record. The Marcus Horan method.
1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
# File 'lib/writeexcel/chart.rb', line 1726 def store_legend(x, y, width, height, wType, wSpacing, grbit) # :nodoc: record = 0x1015 # Record identifier. length = 0x0014 # Number of bytes to follow. # x # X-position. # y # Y-position. # width # Width. # height # Height. # wType # Type. # wSpacing # Spacing. # grbit # Option flags. header = [record, length].pack('vv') data = [x].pack('V') data += [y].pack('V') data += [width].pack('V') data += [height].pack('V') data += [wType].pack('C') data += [wSpacing].pack('C') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_legend_stream ⇒ Object
_store_legend_stream()
Write the LEGEND chart substream.
1206 1207 1208 1209 1210 1211 1212 1213 |
# File 'lib/writeexcel/chart.rb', line 1206 def store_legend_stream # :nodoc: store_legend(*@config[:legend]) store_begin store_pos(*@config[:legend_pos]) store_legend_text_stream store_end end |
#store_legend_text_stream ⇒ Object
_store_legend_text_stream()
Write the legend TEXT substream.
1001 1002 1003 1004 1005 1006 1007 1008 1009 |
# File 'lib/writeexcel/chart.rb', line 1001 def store_legend_text_stream # :nodoc: store_text(*@config[:legend_text]) store_begin store_pos(*@config[:legend_text_pos]) store_ai(0, 1, '') store_end end |
#store_lineformat(rgb, lns, we, grbit, index) ⇒ Object
_store_lineformat()
Write the LINEFORMAT chart BIFF record.
1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 |
# File 'lib/writeexcel/chart.rb', line 1756 def store_lineformat(rgb, lns, we, grbit, index) # :nodoc: record = 0x1007 # Record identifier. length = 0x000C # Number of bytes to follow. # rgb # Line RGB colour. # lns # Line pattern. # we # Line weight. # grbit # Option flags. # index # Index to colour of line. header = [record, length].pack('vv') data = [rgb].pack('V') data += [lns].pack('v') data += [we].pack('v') data += [grbit].pack('v') data += [index].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_marker_dataformat_stream ⇒ Object
_store_marker_dataformat_stream()
This is an abstract method that is overridden by the sub-classes to define properties of markers, linetypes, pie formats and other.
1196 1197 1198 |
# File 'lib/writeexcel/chart.rb', line 1196 def store_marker_dataformat_stream # :nodoc: end |
#store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize) ⇒ Object
_store_markerformat()
Write the MARKERFORMAT chart BIFF record.
1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 |
# File 'lib/writeexcel/chart.rb', line 1782 def store_markerformat(rgbFore, rgbBack, marker, grbit, icvFore, icvBack, miSize)# :nodoc: record = 0x1009 # Record identifier. length = 0x0014 # Number of bytes to follow. # rgbFore # Foreground RGB color. # rgbBack # Background RGB color. # marker # Type of marker. # grbit # Format flags. # icvFore # Color index marker border. # icvBack # Color index marker fill. # miSize # Size of line markers. header = [record, length].pack('vv') data = [rgbFore].pack('V') data += [rgbBack].pack('V') data += [marker].pack('v') data += [grbit].pack('v') data += [icvFore].pack('v') data += [icvBack].pack('v') data += [miSize].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_objectlink(link_type) ⇒ Object
_store_objectlink()
Write the OBJECTLINK chart BIFF record.
1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 |
# File 'lib/writeexcel/chart.rb', line 1812 def store_objectlink(link_type) # :nodoc: record = 0x1027 # Record identifier. length = 0x0006 # Number of bytes to follow. # link_type # Object text link type. link_index1 = 0x0000 # Link index 1. link_index2 = 0x0000 # Link index 2. header = [record, length].pack('vv') data = [link_type].pack('v') data += [link_index1].pack('v') data += [link_index2].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_pieformat ⇒ Object
_store_pieformat()
Write the PIEFORMAT chart BIFF record.
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 |
# File 'lib/writeexcel/chart.rb', line 1834 def store_pieformat # :nodoc: record = 0x100B # Record identifier. length = 0x0002 # Number of bytes to follow. percent = 0x0000 # Distance % from center. header = [record, length].pack('vv') data = [percent].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_plotarea ⇒ Object
_store_plotarea()
Write the PLOTAREA chart BIFF record. This indicates that the subsequent FRAME record belongs to a plot area.
1853 1854 1855 1856 1857 1858 1859 1860 1861 |
# File 'lib/writeexcel/chart.rb', line 1853 def store_plotarea # :nodoc: record = 0x1035 # Record identifier. length = 0x0000 # Number of bytes to follow. header = [record, length].pack('vv') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header) end |
#store_plotarea_frame_stream ⇒ Object
_store_plotarea_frame_stream()
Write the FRAME chart substream.
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 |
# File 'lib/writeexcel/chart.rb', line 1105 def store_plotarea_frame_stream # :nodoc: area = @plotarea store_frame(0x00, 0x03) store_begin store_lineformat( area[:line_color_rgb], area[:line_pattern], area[:line_weight], area[:line_options], area[:line_color_index] ) store_areaformat( area[:fg_color_rgb], area[:bg_color_rgb], area[:area_pattern], area[:area_options], area[:fg_color_index], area[:bg_color_index] ) store_end end |
#store_plotgrowth ⇒ Object
_store_plotgrowth()
Write the PLOTGROWTH chart BIFF record.
1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 |
# File 'lib/writeexcel/chart.rb', line 1869 def store_plotgrowth # :nodoc: record = 0x1064 # Record identifier. length = 0x0008 # Number of bytes to follow. dx_plot = 0x00010000 # Horz growth for font scale. dy_plot = 0x00010000 # Vert growth for font scale. header = [record, length].pack('vv') data = [dx_plot].pack('V') data += [dy_plot].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_pos(mdTopLt, mdBotRt, x1, y1, x2, y2) ⇒ Object
_store_pos()
Write the POS chart BIFF record. Generally not required when using automatic positioning.
1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 |
# File 'lib/writeexcel/chart.rb', line 1890 def store_pos(mdTopLt, mdBotRt, x1, y1, x2, y2) # :nodoc: record = 0x104F # Record identifier. length = 0x0014 # Number of bytes to follow. # mdTopLt # Top left. # mdBotRt # Bottom right. # x1 # X coordinate. # y1 # Y coordinate. # x2 # Width. # y2 # Height. header = [record, length].pack('vv') data = [mdTopLt].pack('v') data += [mdBotRt].pack('v') data += [x1].pack('V') data += [y1].pack('V') data += [x2].pack('V') data += [y2].pack('V') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_serauxtrend(reg_type, poly_order, equation, r_squared) ⇒ Object
_store_serauxtrend()
Write the SERAUXTREND chart BIFF record.
1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 |
# File 'lib/writeexcel/chart.rb', line 1918 def store_serauxtrend(reg_type, poly_order, equation, r_squared) # :nodoc: record = 0x104B # Record identifier. length = 0x001C # Number of bytes to follow. # reg_type # Regression type. # poly_order # Polynomial order. # equation # Display equation. # r_squared # Display R-squared. # intercept # Forced intercept. # forecast # Forecast forward. # backcast # Forecast backward. # TODO. When supported, intercept needs to be NAN if not used. # Also need to reverse doubles. intercept = ['FFFFFFFF0001FFFF'].pack('H*') forecast = ['0000000000000000'].pack('H*') backcast = ['0000000000000000'].pack('H*') header = [record, length].pack('vv') data = [reg_type].pack('C') data += [poly_order].pack('C') data += intercept data += [equation].pack('C') data += [r_squared].pack('C') data += forecast data += backcast print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_series(category_count, value_count) ⇒ Object
_store_series()
Write the SERIES chart BIFF record.
1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 |
# File 'lib/writeexcel/chart.rb', line 1954 def store_series(category_count, value_count) # :nodoc: record = 0x1003 # Record identifier. length = 0x000C # Number of bytes to follow. category_type = 0x0001 # Type: category. value_type = 0x0001 # Type: value. # category_count # Num of categories. # value_count # Num of values. bubble_type = 0x0001 # Type: bubble. bubble_count = 0x0000 # Num of bubble values. header = [record, length].pack('vv') data = [category_type].pack('v') data += [value_type].pack('v') data += [category_count].pack('v') data += [value_count].pack('v') data += [bubble_type].pack('v') data += [bubble_count].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_series_stream(params) ⇒ Object
_store_series_stream()
Write the SERIES chart substream.
886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
# File 'lib/writeexcel/chart.rb', line 886 def store_series_stream(params) # :nodoc: name_type = _formula_type_from_param(2, 1, params, :name_formula) value_type = _formula_type_from_param(2, 0, params, :value_formula) category_type = _formula_type_from_param(2, 0, params, :category_formula) store_series(params[:value_count], params[:category_count]) store_begin # Store the Series name AI record. store_ai(0, name_type, params[:name_formula]) unless params[:name].nil? store_seriestext(params[:name], params[:name_encoding]) end store_ai(1, value_type, params[:value_formula]) store_ai(2, category_type, params[:category_formula]) store_ai(3, 1, '' ) store_dataformat_stream(params[:index]) store_sertocrt store_end end |
#store_series_text_stream(font_index) ⇒ Object
_store_series_text_stream()
Write the series TEXT substream.
930 931 932 933 934 935 936 937 938 |
# File 'lib/writeexcel/chart.rb', line 930 def store_series_text_stream(font_index) # :nodoc: store_text(*@config[:series_text]) store_begin store_pos(*@config[:series_text_pos]) store_fontx( font_index ) store_ai( 0, 1, '' ) store_end end |
#store_seriestext(str, encoding) ⇒ Object
_store_seriestext()
Write the SERIESTEXT chart BIFF record.
1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 |
# File 'lib/writeexcel/chart.rb', line 1982 def store_seriestext(str, encoding) # :nodoc: record = 0x100D # Record identifier. length = 0x0000 # Number of bytes to follow. id = 0x0000 # Text id. # str # Text. # encoding # String encoding. cch = str.length # String length. encoding ||= 0 # Character length is num of chars not num of bytes cch /= 2 if encoding != 0 # Change the UTF-16 name from BE to LE str = str.unpack('v*').pack('n*') if encoding != 0 length = 4 + str.length header = [record, length].pack('vv') data = [id].pack('v') data += [cch].pack('C') data += [encoding].pack('C') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data, str) end |
#store_serparent(series) ⇒ Object
_store_serparent()
Write the SERPARENT chart BIFF record.
2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 |
# File 'lib/writeexcel/chart.rb', line 2015 def store_serparent(series) # :nodoc: record = 0x104A # Record identifier. length = 0x0002 # Number of bytes to follow. # series # Series parent. header = [record, length].pack('vv') data = [series].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_sertocrt ⇒ Object
_store_sertocrt()
Write the SERTOCRT chart BIFF record to indicate the chart group index.
2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 |
# File 'lib/writeexcel/chart.rb', line 2033 def store_sertocrt # :nodoc: record = 0x1045 # Record identifier. length = 0x0002 # Number of bytes to follow. chartgroup = 0x0000 # Chart group index. header = [record, length].pack('vv') data = [chartgroup].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_shtprops ⇒ Object
_store_shtprops()
Write the SHTPROPS chart BIFF record.
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 |
# File 'lib/writeexcel/chart.rb', line 2051 def store_shtprops # :nodoc: record = 0x1044 # Record identifier. length = 0x0004 # Number of bytes to follow. grbit = 0x000E # Option flags. empty_cells = 0x0000 # Empty cell handling. grbit = 0x000A if @embedded header = [record, length].pack('vv') data = [grbit].pack('v') data += [empty_cells].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_text(x, y, dx, dy, grbit1, grbit2, rotation = 0x00) ⇒ Object
_store_text()
Write the TEXT chart BIFF record.
2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 |
# File 'lib/writeexcel/chart.rb', line 2073 def store_text(x, y, dx, dy, grbit1, grbit2, rotation = 0x00)# :nodoc: record = 0x1025 # Record identifier. length = 0x0020 # Number of bytes to follow. at = 0x02 # Horizontal alignment. vat = 0x02 # Vertical alignment. wBkgMode = 0x0001 # Background display. rgbText = 0x0000 # Text RGB colour. # x # Text x-pos. # y # Text y-pos. # dx # Width. # dy # Height. # grbit1 # Option flags. icvText = 0x004D # Auto Colour. # grbit2 # Show legend. # rotation # Show value. header = [record, length].pack('vv') data = [at].pack('C') data += [vat].pack('C') data += [wBkgMode].pack('v') data += [rgbText].pack('V') data += [x].pack('V') data += [y].pack('V') data += [dx].pack('V') data += [dy].pack('V') data += [grbit1].pack('v') data += [icvText].pack('v') data += [grbit2].pack('v') data += [rotation].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_tick ⇒ Object
_store_tick()
Write the TICK chart BIFF record.
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 |
# File 'lib/writeexcel/chart.rb', line 2113 def store_tick # :nodoc: record = 0x101E # Record identifier. length = 0x001E # Number of bytes to follow. tktMajor = 0x02 # Type of major tick mark. tktMinor = 0x00 # Type of minor tick mark. tlt = 0x03 # Tick label position. wBkgMode = 0x01 # Background mode. rgb = 0x00000000 # Tick-label RGB colour. reserved1 = 0x00000000 # Reserved. reserved2 = 0x00000000 # Reserved. reserved3 = 0x00000000 # Reserved. reserved4 = 0x00000000 # Reserved. grbit = 0x0023 # Option flags. index = 0x004D # Colour index. reserved5 = 0x0000 # Reserved. header = [record, length].pack('vv') data = [tktMajor].pack('C') data += [tktMinor].pack('C') data += [tlt].pack('C') data += [wBkgMode].pack('C') data += [rgb].pack('V') data += [reserved1].pack('V') data += [reserved2].pack('V') data += [reserved3].pack('V') data += [reserved4].pack('V') data += [grbit].pack('v') data += [index].pack('v') data += [reserved5].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_title_text_stream ⇒ Object
_store_title_text_stream()
Write the title TEXT substream.
1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/writeexcel/chart.rb', line 1017 def store_title_text_stream # :nodoc: formula = @title_formula ai_type = _formula_type(2, 1, formula) store_text(*@config[:title_text]) store_begin store_pos(*@config[:title_text_pos]) store_fontx(7) store_ai(0, ai_type, formula) unless @title_name.nil? store_seriestext(@title_name, @title_encoding) end store_objectlink(1) store_end end |
#store_valuerange ⇒ Object
_store_valuerange()
Write the VALUERANGE chart BIFF record.
2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 |
# File 'lib/writeexcel/chart.rb', line 2153 def store_valuerange # :nodoc: record = 0x101F # Record identifier. length = 0x002A # Number of bytes to follow. numMin = 0x00000000 # Minimum value on axis. numMax = 0x00000000 # Maximum value on axis. numMajor = 0x00000000 # Value of major increment. numMinor = 0x00000000 # Value of minor increment. numCross = 0x00000000 # Value where category axis crosses. grbit = 0x011F # Format flags. # TODO. Reverse doubles when they are handled. header = [record, length].pack('vv') data = [numMin].pack('d') data += [numMax].pack('d') data += [numMajor].pack('d') data += [numMinor].pack('d') data += [numCross].pack('d') data += [grbit].pack('v') print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_window2 ⇒ Object
_store_window2(), overridden.
Write BIFF record Window2. Note, this overrides the parent Worksheet record because the Chart version of the record is smaller and is used mainly to indicate if the chart tab is selected or not.
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'lib/writeexcel/chart.rb', line 563 def store_window2 # :nodoc: record = 0x023E # Record identifier length = 0x000A # Number of bytes to follow grbit = 0x0000 # Option flags rwTop = 0x0000 # Top visible row colLeft = 0x0000 # Leftmost visible column rgbHdr = 0x0000 # Row/col heading, grid color # The options flags that comprise grbit fDspFmla = 0 # 0 - bit fDspGrid = 0 # 1 fDspRwCol = 0 # 2 fFrozen = 0 # 3 fDspZeros = 0 # 4 fDefaultHdr = 0 # 5 fArabic = 0 # 6 fDspGuts = 0 # 7 fFrozenNoSplit = 0 # 0 - bit fSelected = @selected # 1 fPaged = 0 # 2 fBreakPreview = 0 # 3 #<<< Perltidy ignore this. grbit = fDspFmla grbit |= fDspGrid << 1 grbit |= fDspRwCol << 2 grbit |= fFrozen << 3 grbit |= fDspZeros << 4 grbit |= fDefaultHdr << 5 grbit |= fArabic << 6 grbit |= fDspGuts << 7 grbit |= fFrozenNoSplit << 8 grbit |= fSelected << 9 grbit |= fPaged << 10 grbit |= fBreakPreview << 11 #>>> header = [record, length].pack("vv") data = [grbit, rwTop, colLeft, rgbHdr].pack("vvvV") print "sheet #{@name} : #{__FILE__}(#{__LINE__}) \n" if defined?($debug) append(header, data) end |
#store_x_axis_text_stream ⇒ Object
_store_x_axis_text_stream()
Write the X-axis TEXT substream.
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 |
# File 'lib/writeexcel/chart.rb', line 951 def store_x_axis_text_stream # :nodoc: formula = @x_axis_formula.nil? ? '' : @x_axis_formula ai_type = _formula_type(2, 1, formula) store_text(*@config[:x_axis_text]) store_begin store_pos(*@config[:x_axis_text_pos]) store_fontx(8) store_ai(0, ai_type, formula) unless @x_axis_name.nil? store_seriestext(@x_axis_name, @x_axis_encoding) end store_objectlink(3) store_end end |
#store_y_axis_text_stream ⇒ Object
_store_y_axis_text_stream()
Write the Y-axis TEXT substream.
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 |
# File 'lib/writeexcel/chart.rb', line 976 def store_y_axis_text_stream # :nodoc: formula = @y_axis_formula ai_type = _formula_type(2, 1, formula) store_text(*@config[:y_axis_text]) store_begin store_pos(*@config[:y_axis_text_pos]) store_fontx(8) store_ai(0, ai_type, formula) unless @y_axis_name.nil? store_seriestext(@y_axis_name, @y_axis_encoding) end store_objectlink(2) store_end end |
#using_tmpfile=(val) ⇒ Object
:nodoc:
454 455 456 |
# File 'lib/writeexcel/chart.rb', line 454 def using_tmpfile=(val) # :nodoc: @using_tmpfile = val end |