spreadsheetAddChart

Adds a chart to the active sheet of a spreadsheet workbook. The chart struct accepts type (line, line3d, bar, bar3d, pie, pie3d, doughnut or area, default line), series (an array or delimited list of sheet-qualified ranges such as "Sheet1!$A$2:$A$10"), from and to (anchor A1 cells) and an optional title. The fluent member form is addChart({...}).

spreadsheetAddChart(spreadsheetObj, { type, series, from, to, title }) → returns any

This function requires RustCFML.  Not supported on Lucee, Adobe ColdFusion, etc.

Argument Reference

spreadsheetObj any
Required

The spreadsheet workbook object to add the chart to.

chart struct
Required

Struct describing the chart: type (line|line3d|bar|bar3d|pie|pie3d|doughnut|area), series (array or list of sheet-qualified ranges), from (top-left anchor cell, default "C1"), to (bottom-right anchor cell, default "H15") and title.

Compatibility

RustCFML:

Not supported on wasm32.

Examples
Sample code invoking the spreadsheetAddChart function

Write scores to a sheet, then add a bar chart anchored at E1.

scores = queryNew("name,score", "varchar,integer");
queryAddRow(scores, {name: "Alice", score: 90});
queryAddRow(scores, {name: "Bob", score: 75});
Spreadsheet("xlsx")
	.sheet("Data")
	.fromQuery(scores, true)
	.addChart({
		type: "bar",
		series: ["Data!$B$2:$B$3"],
		from: "E1",
		to: "L15",
		title: "Scores"
	})
	.write(expandPath("/chart.xlsx"), true);

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub