Class: Aio::Base::Toolkit::ExcelOffice::Chart
- Inherits:
-
Object
- Object
- Aio::Base::Toolkit::ExcelOffice::Chart
- Defined in:
- lib/aio/base/toolkit/excel_office.rb
Overview
图表
Constant Summary collapse
- ColumnClustered =
图形类型
51
- ColumnStacked =
簇状柱形图
52
- Doughnut =
堆积柱状图
-4120 # 圆环图
- Line =
圆环图
4
- Pie =
折线图
5
- BarClustered =
饼图
57
- DataLabelsShowLabel =
标签数据
4
- DataLabelsShowLabelAndPercent =
数据点所属的分类
5
- DataLabelsShowPercent =
占比百分比以及所属分类,仅饼图
3
- DataLabelsShowValue =
百分比, 仅饼图
2
Instance Method Summary collapse
-
#axes_x=(name) ⇒ Object
设置X轴名称, 只用于条形图.
-
#axes_y=(name) ⇒ Object
设置Y轴名称, 只用于条形图.
- #chart_work ⇒ Object
-
#data_label(type = DataLabelsShowLabelAndPercent) ⇒ Object
添加饼图的百分比.
-
#initialize(active) ⇒ Chart
constructor
A new instance of Chart.
-
#source=(range) ⇒ Object
这是原数据地址, 按列生成数据.
-
#style=(int) ⇒ Object
修改样式 通过录制宏可以查看样式编号 条形图中203 比较好看 饼图中 251, 254 比较好看.
-
#title=(name) ⇒ Object
修改标题.
-
#type=(c_type) ⇒ Object
更改图形类型.
Constructor Details
#initialize(active) ⇒ Chart
Returns a new instance of Chart.
356 357 358 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 356 def initialize(active) @chart = active end |
Instance Method Details
#axes_x=(name) ⇒ Object
设置X轴名称, 只用于条形图
381 382 383 384 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 381 def axes_x=(name) @chart.Axes(1,1).HasTitle = true @chart.Axes(1,1).AxisTitle.Characters.Text = name end |
#axes_y=(name) ⇒ Object
设置Y轴名称, 只用于条形图
387 388 389 390 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 387 def axes_y=(name) @chart.Axes(2,1).HasTitle = true @chart.Axes(2,1).AxisTitle.Characters.Text = name end |
#chart_work ⇒ Object
360 361 362 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 360 def chart_work @chart end |
#data_label(type = DataLabelsShowLabelAndPercent) ⇒ Object
添加饼图的百分比
402 403 404 405 406 407 408 409 410 411 412 413 414 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 402 def data_label(type=DataLabelsShowLabelAndPercent) # 应用标签选项 @chart.ApplyDataLabels(type) # 取消标签选项的系列名称 now = @chart.SeriesCollection(1).DataLabels now.ShowSeriesName = false # 将图例放到右边 now = @chart.Legend now.Position = -4152 end |
#source=(range) ⇒ Object
这是原数据地址, 按列生成数据
371 372 373 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 371 def source=(range) @chart.SetSourceData(range, 2) end |
#style=(int) ⇒ Object
修改样式通过录制宏可以查看样式编号条形图中203 比较好看饼图中 251, 254 比较好看
396 397 398 399 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 396 def style=(int) @chart.ChartStyle = int data_label end |
#title=(name) ⇒ Object
修改标题
365 366 367 368 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 365 def title=(name) @chart.HasTitle = true @chart.ChartTitle.Characters.Text = name end |
#type=(c_type) ⇒ Object
更改图形类型
376 377 378 |
# File 'lib/aio/base/toolkit/excel_office.rb', line 376 def type=(c_type) @chart.ChartType = c_type end |