[]
• new ChartCollection()
Represents a chart manager that managers all charts in a sheet.
▸ 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);
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. |
The chart that has been added to the sheet.
▸ 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())
}
Chart
[]
The collection of all the charts in the sheet.
▸ clear(): void
Removes all charts in the sheet.
void
▸ 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");
});
Name | Type | Description |
---|---|---|
name |
string |
The name of the chart. |
The chart in the sheet with the indicate name.
▸ 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);
})
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. |
undefined
| boolean
If no value is set, return the flag value, otherwise, return undefined;
▸ 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();
});
Name | Type | Description |
---|---|---|
name |
string |
The name of the chart. |
void
▸ 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);
Name | Type | Description |
---|---|---|
name |
string |
The name of the chart. |
zIndex? |
number |
The z-index of the chart. |
any
If the parameter 'zIndex' is null or undefined,it will return the z-index of the chart with the indicate name.