[]
        
(Showing Draft Content)

GC.Spread.Sheets.Charts.ChartCollection

Class: ChartCollection

Sheets.Charts.ChartCollection

Table of contents

Constructors

Methods

Constructors

constructor

new ChartCollection()

Represents a chart manager that managers all charts in a sheet.

Methods

add

add(name, chartType, x, y, width, height, dataRange?, dataOrientation?): Chart

Adds a chart to the sheet.

example

//This example shows how to add a chart.
var dataRange = "A1:D4";
var chart = activeSheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 20, 600, 400, dataRange);

Parameters

Name Type Description
name string The name of the chart that will be added to the sheet.
chartType ChartType The type of the chart.
x number The x location of the chart.
y number The y location of the chart.
width number The width of the chart.
height number The height of the chart.
dataRange? string The formula string of data range for the chart.
dataOrientation? RowCol The orientation of data for series.

Returns

Chart

The chart that has been added to the sheet.


all

all(): Chart[]

Gets all of the charts in the sheet.

example

var dataRange = "A1:D4";
activeSheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 20, 600, 180, dataRange);
var dataRange2 = "A20:D24";
activeSheet.charts.add('Chart2', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 220, 600, 180, dataRange2);
var charts = activeSheet.charts.all();
for (var i = 0; i < charts.length; i++) {
    alert("Name of chart " + i + " is:  " + charts[i].name())
}

Returns

Chart[]

The collection of all the charts in the sheet.


clear

clear(): void

Removes all charts in the sheet.

Returns

void


get

get(name): Chart

Gets a chart from the sheet by the indicate name.

example

var dataRange = "A1:D4";
activeSheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 20, 600, 400, dataRange);
//button
$("#button1").click(function () {
 var chart = activeSheet.charts.get("f2");
});

Parameters

Name Type Description
name string The name of the chart.

Returns

Chart

The chart in the sheet with the indicate name.


preserveUnsupportedChart

preserveUnsupportedChart(flag, paintCallBack?): undefined | boolean

Gets or sets if preserve unsupport chart when import.

example

sheet.charts.preserveUnsupportedChart(true, function(chartHost, chart){
var paintElement= document.createElement('div');
paintElement.innerHTML = '<span>to be continue</span>';
chartHost.appendChild(paintElement);
})

Parameters

Name Type Description
flag boolean indicates whether preserve unsupport chart when import, the default value is false, if set true, it will be painted as paintCallBack.
paintCallBack? IPaintCallBack the display content function for unsupport chart.

Returns

undefined | boolean

If no value is set, return the flag value, otherwise, return undefined;


remove

remove(name): void

Removes a chart from the sheet by the indicate name.

example

var dataRange = "A1:D4";
activeSheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 20, 600, 400, dataRange);
//button
$("#button1").click(function () {
     activeSheet.resumePaint();
     activeSheet.charts.remove("f2");
     activeSheet.repaint();
});

Parameters

Name Type Description
name string The name of the chart.

Returns

void


zIndex

zIndex(name, zIndex?): any

Gets or sets the z-index of chart.

example

var dataRange = "A1:D4";
activeSheet.charts.add('Chart1', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 20, 600, 180, dataRange);
var dataRange2 = "A20:D24";
activeSheet.charts.add('Chart2', GC.Spread.Sheets.Charts.ChartType.columnClustered, 250, 180, 600, 180, dataRange2);
activeSheet.charts.zIndex('Chart1', 897);
activeSheet.charts.zIndex('Chart2', 890);

Parameters

Name Type Description
name string The name of the chart.
zIndex? number The z-index of the chart.

Returns

any

If the parameter 'zIndex' is null or undefined,it will return the z-index of the chart with the indicate name.