[]
        
(Showing Draft Content)

GC.Spread.Sheets.Sparklines.Sparkline

类: Sparkline

Sheets.Sparklines.Sparkline

Table of contents

构造方法

属性

方法

构造方法

constructor

new Sparkline(row?, column?, dataReference?, dataOrientation?, type?, setting?)

迷你图类

参数

属性名 类型 说明
row? number 行索引
column? number 列索引
dataReference? Range 迷你图所引用的数据区域
dataOrientation? DataOrientation 数据区域的方向
type? SparklineType 迷你图的类型
setting? SparklineSetting 迷你图的设置

属性

column

column: number

获取列索引


row

row: number

获取行索引

方法

clone

clone(): Sparkline

克隆迷你图

代码示例

let sheet = spread.getActiveSheet();
sheet.setArray(0, 0, [-1,2,3,4,3,2,3,5]);
let dataRange = new GC.Spread.Sheets.Range(0, 0, 8, 1);
let sparkline = sheet.setSparkline(11, 0, dataRange, GC.Spread.Sheets.Sparklines.DataOrientation.Vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, new GC.Spread.Sheets.Sparklines.SparklineSetting());

let sparkline2 = sparkline.clone();

返回值

Sparkline

克隆的迷你图


data

data(value?): any

获取或设置数据对象

代码示例

//本示例使用data方法
activeSheet.suspendPaint();
activeSheet.setValue(1, 0, 10);
activeSheet.setValue(2, 0, 0);
activeSheet.setValue(3, 0, -3);
activeSheet.setValue(4, 0, -5);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 4);
activeSheet.setValue(0, 3, 8);
activeSheet.setValue(0, 4, 6);
activeSheet.setValue(0, 5, new Date(2014, 1, 1));
activeSheet.setValue(1, 5, new Date(2014, 9, 1));
activeSheet.setValue(2, 5, new Date(2014, 7, 1));
activeSheet.setValue(3, 5, new Date(2014, 5, 1));
activeSheet.setValue(4, 5, new Date(2014, 3, 1));
var sparkline = activeSheet.setSparkline(5, 0, new GC.Spread.Sheets.Range(0, 0, 5, 5), GC.Spread.Sheets.Sparklines.DataOrientation.horizontal, GC.Spread.Sheets.Sparklines.SparklineType.line, new GC.Spread.Sheets.Sparklines.SparklineSetting(), new GC.Spread.Sheets.Range(0, 5, 5, 1), GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.data(new GC.Spread.Sheets.Range(0, 0, 5, 5));
sparkline.sparklineType(GC.Spread.Sheets.Sparklines.SparklineType.line);
sparkline.setting(new GC.Spread.Sheets.Sparklines.SparklineSetting());
sparkline.dateAxisData(new GC.Spread.Sheets.Range(0, 5, 5, 1));
sparkline.dataOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.dateAxisOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.row = 5;
sparkline.column = 0;
sparkline.displayDateAxis(true);
activeSheet.resumePaint();

参数

属性名 类型 说明
value? Range 迷你图数据

返回值

any

如果未设置任何值,则返回数据对象;否则,返回迷你图


dataOrientation

dataOrientation(value?): any

获取或设置数据方向

代码示例

//本示例使用垂直数据和日期区域创建迷你图
var setting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
setting.options.showMarkers = true;
setting.options.displayXAxis = true;
activeSheet.suspendPaint();
activeSheet.setValue(1, 0, 10);
activeSheet.setValue(2, 0, 0);
activeSheet.setValue(3, 0, -3);
activeSheet.setValue(4, 0, -5);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 4);
activeSheet.setValue(0, 3, 8);
activeSheet.setValue(0, 4, 6);
activeSheet.setValue(0, 5, new Date(2014, 1, 1));
activeSheet.setValue(1, 5, new Date(2014, 9, 1));
activeSheet.setValue(2, 5, new Date(2014, 7, 1));
activeSheet.setValue(3, 5, new Date(2014, 5, 1));
activeSheet.setValue(4, 5, new Date(2014, 3, 1));
var sparkline = activeSheet.setSparkline(5, 0, new GC.Spread.Sheets.Range(0, 0, 5, 5), GC.Spread.Sheets.Sparklines.DataOrientation.horizontal, GC.Spread.Sheets.Sparklines.SparklineType.line, setting, new GC.Spread.Sheets.Range(0, 5, 5, 1), GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.dataOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.displayDateAxis(true);
activeSheet.resumePaint();
activeSheet.addSpan(5, 0, 4, 3, null);

参数

属性名 类型 说明
value? DataOrientation 迷你图数据方向

返回值

any

如果未设置任何值,则返回迷你图数据方向 否则,返回迷你图


dateAxisData

dateAxisData(value?): any

获取或设置日期轴数据对象

代码示例

//本示例使用dateAxisData方法
activeSheet.suspendPaint();
activeSheet.setValue(1, 0, 10);
activeSheet.setValue(2, 0, 0);
activeSheet.setValue(3, 0, -3);
activeSheet.setValue(4, 0, -5);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 4);
activeSheet.setValue(0, 3, 8);
activeSheet.setValue(0, 4, 6);
activeSheet.setValue(0, 5, new Date(2014, 1, 1));
activeSheet.setValue(1, 5, new Date(2014, 9, 1));
activeSheet.setValue(2, 5, new Date(2014, 7, 1));
activeSheet.setValue(3, 5, new Date(2014, 5, 1));
activeSheet.setValue(4, 5, new Date(2014, 3, 1));
var sparkline = activeSheet.setSparkline(5, 0, new GC.Spread.Sheets.Range(0, 0, 5, 5), GC.Spread.Sheets.Sparklines.DataOrientation.horizontal, GC.Spread.Sheets.Sparklines.SparklineType.line, new GC.Spread.Sheets.Sparklines.SparklineSetting(), new GC.Spread.Sheets.Range(0, 5, 5, 1), GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.data(new GC.Spread.Sheets.Range(0, 0, 5, 5));
sparkline.sparklineType(GC.Spread.Sheets.Sparklines.SparklineType.line);
sparkline.setting(new GC.Spread.Sheets.Sparklines.SparklineSetting());
sparkline.dateAxisData(new GC.Spread.Sheets.Range(0, 5, 5, 1));
sparkline.dataOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.dateAxisOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.row = 5;
sparkline.column = 0;
sparkline.displayDateAxis(true);
activeSheet.resumePaint();

参数

属性名 类型 说明
value? Range 迷你图日期轴数据

返回值

any

如果未设置任何值,则返回迷你图日期轴数据 否则,返回迷你图


dateAxisOrientation

dateAxisOrientation(value?): any

获取或设置日期轴方向

代码示例

//本示例使用带有水平日期的垂直数据来创建迷你图
var setting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
setting.options.showMarkers = true;
setting.options.displayXAxis = true;
activeSheet.suspendPaint();
activeSheet.setValue(1, 0, 10);
activeSheet.setValue(2, 0, 0);
activeSheet.setValue(3, 0, -3);
activeSheet.setValue(4, 0, -5);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 4);
activeSheet.setValue(0, 3, 8);
activeSheet.setValue(0, 4, 6);
activeSheet.setValue(0, 5, new Date(2014, 1, 1));
activeSheet.setValue(1, 5, new Date(2014, 9, 1));
activeSheet.setValue(2, 5, new Date(2014, 7, 1));
activeSheet.setValue(3, 5, new Date(2014, 5, 1));
activeSheet.setValue(4, 5, new Date(2014, 3, 1));
activeSheet.setValue(11, 0, new Date(2014, 1, 1));
activeSheet.setValue(11, 1, new Date(2014, 9, 1));
activeSheet.setValue(11, 2, new Date(2014, 7, 1));
activeSheet.setValue(11, 3, new Date(2014, 5, 1));
activeSheet.setValue(11, 4, new Date(2014, 3, 1));
var sparkline = activeSheet.setSparkline(5, 0, new GC.Spread.Sheets.Range(0, 0, 5, 5), GC.Spread.Sheets.Sparklines.DataOrientation.vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, setting, new GC.Spread.Sheets.Range(11, 0, 1, 5), GC.Spread.Sheets.Sparklines.DataOrientation.horizontal);
sparkline.dataOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.dateAxisOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.horizontal);
sparkline.displayDateAxis(true);
activeSheet.resumePaint();
activeSheet.addSpan(5, 0, 4, 3, null);

参数

属性名 类型 说明
value? DataOrientation 迷你图日期轴方向

返回值

any

如果未设置任何值,则返回迷你图日期轴的方向;否则,返回迷你图


displayDateAxis

displayDateAxis(value?): any

获取或设置一个值,该值指示是否显示日期轴

代码示例

//本示例使用垂直数据和日期区域创建迷你图
var setting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
setting.options.showMarkers = true;
setting.options.displayXAxis = true;
activeSheet.suspendPaint();
activeSheet.setValue(1, 0, 10);
activeSheet.setValue(2, 0, 0);
activeSheet.setValue(3, 0, -3);
activeSheet.setValue(4, 0, -5);
activeSheet.setValue(0, 0, 1);
activeSheet.setValue(0, 1, 2);
activeSheet.setValue(0, 2, 4);
activeSheet.setValue(0, 3, 8);
activeSheet.setValue(0, 4, 6);
activeSheet.setValue(0, 5, new Date(2014, 1, 1));
activeSheet.setValue(1, 5, new Date(2014, 9, 1));
activeSheet.setValue(2, 5, new Date(2014, 7, 1));
activeSheet.setValue(3, 5, new Date(2014, 5, 1));
activeSheet.setValue(4, 5, new Date(2014, 3, 1));
var sparkline = activeSheet.setSparkline(5, 0, new GC.Spread.Sheets.Range(0, 0, 5, 5), GC.Spread.Sheets.Sparklines.DataOrientation.horizontal, GC.Spread.Sheets.Sparklines.SparklineType.line, setting, new GC.Spread.Sheets.Range(0, 5, 5, 1), GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.dataOrientation(GC.Spread.Sheets.Sparklines.DataOrientation.vertical);
sparkline.displayDateAxis(true);
activeSheet.resumePaint();
activeSheet.addSpan(5, 0, 4, 3, null);

参数

属性名 类型 说明
value? boolean 是否显示日期轴

返回值

any

如果未设置任何值,则返回是否显示日期轴 否则,返回迷你图


group

group(value?): any

获取或设置迷你图组

代码示例

let sheet = spread.getActiveSheet();
sheet.setArray(0, 0, [1,2,3,4,3,2,3,5]);
let dataRange = new GC.Spread.Sheets.Range(0, 0, 8, 1);
let setting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
let sparkline1 = sheet.setSparkline(11, 0, dataRange, GC.Spread.Sheets.Sparklines.DataOrientation.Vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, setting);
let sparkline2 = sheet.setSparkline(11, 3, dataRange, GC.Spread.Sheets.Sparklines.DataOrientation.Vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, setting);
sheet.groupSparkline([sparkline1,sparkline2]);

let sparklineGroup = sparkline1.group();
console.log(sparklineGroup.count()) // 2

参数

属性名 类型 说明
value? SparklineGroup 迷你图组

返回值

any

如果未设置任何值,则返回迷你图组 否则,返回迷你图


paintSparkline

paintSparkline(ctx, x, y, w, h): void

在指定区域绘制迷你图

参数

属性名 类型 说明
ctx CanvasRenderingContext2D 画布的二维上下文
x number x 相对于画布的坐标
y number 相对于画布的 y 坐标
w number 包含迷你图的单元格的宽度
h number 包含迷你图的单元格的高度

返回值

void


setting

setting(value?): any

获取或设置单元格的迷你图设置

代码示例

let sheet = spread.getActiveSheet();
sheet.setArray(0, 0, [-1,2,3,4,3,2,3,5]);
let dataRange = new GC.Spread.Sheets.Range(0, 0, 8, 1);
let sparkline = sheet.setSparkline(11, 0, dataRange, GC.Spread.Sheets.Sparklines.DataOrientation.Vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, new GC.Spread.Sheets.Sparklines.SparklineSetting());

let setting = new GC.Spread.Sheets.Sparklines.SparklineSetting();
setting.options.showMarkers = true;
setting.options.displayXAxis = true;
setting.options.seriesColor = "Text 2 1";
setting.options.firstMarkerColor = "Text 2 3";
setting.options.axisColor ="Text 1 1";

sparkline.setting(setting);

参数

属性名 类型 说明
value? SparklineSetting 迷你图设置

返回值

any

如果未设置任何值,则返回迷你图设置 否则,返回迷你图


sparklineType

sparklineType(value?): any

获取或设置迷你图的类型

代码示例

let sheet = spread.getActiveSheet();
sheet.setArray(0, 0, [-1,2,3,4,3,2,3,5]);
let dataRange = new GC.Spread.Sheets.Range(0, 0, 8, 1);
let sparkline = sheet.setSparkline(11, 0, dataRange, GC.Spread.Sheets.Sparklines.DataOrientation.Vertical, GC.Spread.Sheets.Sparklines.SparklineType.line, new GC.Spread.Sheets.Sparklines.SparklineSetting());

sparkline.sparklineType(GC.Spread.Sheets.Sparklines.SparklineType.column);

参数

属性名 类型 说明
value? SparklineType 迷你图的类型

返回值

any

如果未设置任何值,则返回迷你图类型 否则,返回迷你图