class Axlsx::LineChart
@see Package#serialize
@see Series
@see Chart#add_series
@see Worksheet#add_row
@see Worksheet#add_chart
chart.add_series :data => [1, 9, 10], :labels => [“Slimy Reptiles”, “Fuzzy Bunnies”, “Rottweiler”]
chart = ws.add_chart(Axlsx::LineChart, :start_at=> [0,1], :end_at=>, :title=>“Most Popular Pets”)
ws.add_row [“This is a chart with no data in the sheet”]
ws = p.workbook.add_worksheet
p = Axlsx::Package.new
require “axlsx”
require “rubygems” # if that is your preferred way to manage gems!
# This example creates a line in a single sheet.
@example Creating a chart
The LineChart is a two dimentional line chart (who would have guessed?) that you can add to your worksheet.
def axes
-
(Axes)-
def axes @axes ||= Axes.new(:cat_axis => CatAxis, :val_axis => ValAxis) end
def cat_axis
-
(CatAxis)-
def cat_axis axes[:cat_axis] end
def grouping=(v)
- See: grouping -
def grouping=(v) RestrictionValidator.validate "LineChart.grouping", [:percentStacked, :standard, :stacked], v @grouping = v end
def initialize(frame, options = {})
- See: Chart -
Options Hash:
(**options)-
grouping(Symbol) -- -
show_legend(Boolean) -- -
title(Cell, String) --
Parameters:
-
frame(GraphicFrame) -- The workbook that owns this chart.
def initialize(frame, options = {}) @vary_colors = false @grouping = :standard super(frame, options) @series_type = LineSeries @d_lbls = nil end
def node_name
-
(String)-
def node_name path = self.class.to_s if i = path.rindex('::') path = path[(i + 2)..-1] end path[0] = path[0].chr.downcase path end
def to_xml_string(str = '')
-
(String)-
Parameters:
-
str(String) --
def to_xml_string(str = '') super(str) do str << ("<c:" << node_name << ">") str << ('<c:grouping val="' << grouping.to_s << '"/>') str << ('<c:varyColors val="' << vary_colors.to_s << '"/>') @series.each { |ser| ser.to_xml_string(str) } @d_lbls.to_xml_string(str) if @d_lbls yield if block_given? axes.to_xml_string(str, :ids => true) str << ("</c:" << node_name << ">") axes.to_xml_string(str) end end
def val_axis
-
(ValAxis)-
def val_axis axes[:val_axis] end