[{"id":"29a4ab0f-edd1-45e1-87df-0b8b4bb068b3","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"64b61a79-5817-4746-b591-28d4d5462c0a","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6edef660-641f-4cd8-84f6-571130f37ae2","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"89a3ee5c-06c4-49c4-ac61-8325ba4bcca1","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"1e898427-e706-440e-9077-b35c7a5b8f46","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"4266ec12-a87a-444b-a8af-beff39a7defe","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"fd867fe6-72e0-4e45-bbac-edc72e608b08","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"fad338cd-7c96-48b9-a12d-1b979ba886b2","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6fb42249-b832-4656-9137-35d9948bea1c","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6e353a93-c1d4-4387-bad5-4a07fd18ed3a","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"acbe820e-65b4-4bd6-bcf3-a9d5b16163da","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"167a076a-6a93-49f6-8bf8-adee9abd9817","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"7fb1e240-d39d-4391-986f-c2d40adfb011","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"09cc5e9f-99c9-4258-b69c-ca5bb09a6b16","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"0b4ea8fb-4e7b-4028-9393-d1177a68ec17","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"35b8ea08-9ca6-49eb-a021-0c806de4ff96","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"7bace066-1638-4034-82eb-0db8c15f5bd1","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"7ec5ea8e-419f-40aa-b67d-301fa3e7b025","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"38f78942-4ca0-4631-a2d8-32dcfd6157a6","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"fc1d5e2a-5d1c-4479-ac87-c726c03d49aa","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"dd70702b-48a7-4896-b92d-db78ff9e52b0","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"cda2a866-9746-4790-9942-13c450ece8a1","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"3239f53b-81be-4d67-ae63-7ca0d6ce0f91","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"74c2daa1-efb0-4d3e-bd0c-8d11b297c92d","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"a4268f67-693d-4933-9e22-a77d68880a13","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"9f17896b-55b4-4627-8b6d-b01fdabdffe7","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e45c5458-c148-4de7-a471-e2e3808d841e","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"ac44f25f-d7e5-46a3-a247-33e23e20e956","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"feb10296-b21e-4506-8d7e-567ed4dda994","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"ebba2e23-2c8d-4948-8cca-91ce71b3183d","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"ebdc80a9-26fc-4420-af7f-e576e4f12820","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2cb68b65-34df-4322-911c-ead14627af13","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"0f2df6ef-74f6-42d5-a6ff-fb830bac6bc1","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"1feb74f5-775b-4809-80bb-1757ff6070f9","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d8afaaaf-0174-4a14-8ba1-59043a985e91","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"7fd72fd2-933b-4816-81d1-b9e9d86b7c2c","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"9cf8d438-a37d-4dea-b0dd-e15d187e19ed","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"01561aea-2cd9-4883-a29a-1a7b9df2e432","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"ec2f2f29-d5a6-4fa0-aa61-353d48af9d1b","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"efb477ff-7d55-4163-a55e-a3c64415f6a4","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"c2302058-2cde-443c-a67f-e77cfd399c2e","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"a61a4e1a-eaea-4814-a424-e3c1ca6e3818","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"cb0d722f-fb48-45b5-a612-ff2df9b2e56e","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"50d0749d-1dde-4d8d-8963-e605f3a89b7a","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"900c820c-2909-4065-be81-72d3ca7733de","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"fac7dd69-11b1-42ee-8c1e-a41c97f4c3ee","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"9a357d48-c648-4ddb-8c79-2dc97bea6bc9","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d5de4b91-714d-4c4c-8619-4b88fae85046","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"3741b662-b556-4859-8720-4c79fd48d48a","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"72db3e84-44c5-4d07-86b1-5f866a897e83","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2a701ccf-5692-4ff9-9e44-62d6ec379397","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d2087e5d-f90d-4827-a383-ff828bd65c69","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"bbf41a2c-98d3-4b54-82fb-a51c8441957e","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"477eb38f-0505-42fc-85ee-7456d81833e8","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d9f37084-fcee-49d5-a192-8c41ee5615ed","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"067eb4be-9082-4153-8754-3bd0106a16ef","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e943752e-d665-4133-ab1e-b6089d61b68a","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d573ae98-998d-4070-b089-620789e0738b","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]}]
Axes refer to the lines on a chart that help you understand the scales and dimensions of the data being displayed. The horizontal (x-axis) and vertical (y-axis) axes are used to plot data like time, quantities, percentages, and so on. Use the IAxisOption
interface to define the appearance and behavior of a axes in a Data Chart.
The primary configurable properties of axes available in the IAxisOption
interface are listed below.
Property | Description | Sample Preview |
---|---|---|
type | Defines the axis type as either a "Category Axis" or a "Value Axis". Behavior can vary based on chart types and coordinate system (e.g., Cartesian or Polar). | |
labels | Controls the visibility of axis labels. Default behavior may vary depending on chart types. Explicit settings are required to override defaults. | |
axisLine | Determines whether the axis line is displayed. Data Chart provides different default values for various chart types. Explicit settings are required to override defaults. | |
reversed | Reverses the direction of the axis. | |
title | Specifies the axis title, including units or other descriptions. | |
max & min | Sets the maximum and minimum values for the axis range. | |
position | Determines the location of the axis on the Data Chart. | |
format | Sets the format information of axis, including the data units and format string. | |
majorUnit & minorUnit | Sets the interval between scale markings.
| |
labelAngle | Sets the rotation angle of axis labels (range: -90 to 90 degrees). Note that, currently, this property only works on the first element of the array. | |
labelStyle | Defines the text style of axis labels. | |
titleStyle | Specifies the style for axis titles. | |
lineStyle | Configures the axis line appearance. | |
majorTickSize & minorTickSize | Sets the length of the major and minor tick marks for the current axis. Major and minor tick marks help locate data points on the axis.
Supported values: none, inside, outside, and cross | |
majorGrid & minorGrid | Sets to enhance data interpretation. They typically depict finer number intervals, allowing users to view data more precisely. Default values may vary depending on the chart types; for example, grid lines are not shown by default in a "pie" chart.
Major grid lines and tick marks are drawn for each major unit. Minor grid lines and tick marks are drawn for each minor unit. By default, each major unit is separated by one minor grid line and a tick mark. | |
majorGridStyle & minorGridStyle | Configures the style information for major grid lines and minor grid lines. | |
dateMode | Sets time spans of the axis in Data Charts like scatter and bubble charts. |
Refer to the following sample code to configure and customize axes on Data Chats.
Note that this sample uses the "salesTable" data mentioned on the Create Data Charts page. Therefore, make sure you have completed the primary steps outlined on that page to set up a data chart. Once done, you can use the following codes to configure the axes. Additionally, you also have the flexibility to customize the data source according to your specific needs.
// 1. Types of Axis
const sheet = spread.getSheet(0);
sheet.name("Axis Type");
sheet.setValue(4, 0, "Cartesian Coordinate System");
sheet.setValue(23, 0, "Polar coordinate system");
const dataChart = sheet.dataCharts.add('data-chart', 200, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.x, // GC.Spread.Sheets.DataCharts.AxisType
title: "X-Axis Title" // string
}, {
type: GC.Spread.Sheets.DataCharts.AxisType.y,
title: "Y-Axis Title"
}
]
}]
}
});
const dataChart2 = sheet.dataCharts.add('data-chart-2', 200, 320, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart2.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.polarCoordinatesBar,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' },
},
}
]
});
// 2. Labels
let sheet2 = spread.getSheet(1);
sheet2.name("Labels");
sheet2.setValue(16, 0, "The X-Axis Labels are Hidden");
const dataChart3 = sheet2.dataCharts.add('data-chart-3', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart3.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
// Hide the Labels on X - Axis
labels: false // boolean
},
]
}]
}
});
// 3. Axis Line
let sheet3 = spread.getSheet(2);
sheet3.name("Axis Line");
sheet3.setValue(16, 0, "AxisLine is hidden for X-Axis");
const dataChart4 = sheet3.dataCharts.add('data-chart-4', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart4.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
// Hide the AxisLine for X-Axis
axisLine: false // Boolean
},
]
}]
}
});
//4. Axis Reversed
let sheet4 = spread.getSheet(3);
sheet4.name("Axis Reversed");
sheet4.setValue(16, 0, "The direction of the Y-Axis is Reversed");
const dataChart5 = sheet4.dataCharts.add('data-chart-5', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart5.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
// The direction of the Y-Axis is Reversed
reversed: true // Boolean
},
]
}]
}
});
//5. Axis Title
let sheet5 = spread.getSheet(4);
sheet5.name("Axis Title");
sheet5.setValue(16, 0, "The title 'Sales (in USD)' is set for the Y-Axis.");
const dataChart6 = sheet5.dataCharts.add('data-chart-6', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart6.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
// Set the Title for the Y-Axis
title: "Sales (in USD)" // string
},
]
}]
}
});
//6. Max and Min
let sheet6 = spread.getSheet(5);
sheet6.name("Max and Min");
sheet6.setValue(16, 0, "No Max and Min");
sheet6.setValue(16, 10, "Y-Axis Max Value: 4500");
sheet6.setValue(17, 10, "Y-Axis Min Value: 3000");
const dataChart7 = sheet6.dataCharts.add('data-chart-7', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart7.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
});
const dataChart8 = sheet6.dataCharts.add('data-chart-8', 610, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart8.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
max: { // Set the Maximum Value for Y-Axis
type: GC.Spread.Sheets.DataCharts.ValueOptionType.number, // ValueOptionType
value: 4500 // number
},
min: { // Set the Minimum Value for X-Axis
type: GC.Spread.Sheets.DataCharts.ValueOptionType.number,
value: 3000
}
}]
}]
}
});
//7. Position
let sheet7 = spread.getSheet(6);
sheet7.name("Position");
sheet7.setValue(16, 0, "Axis Position of the X-Axis is set to 'Far'")
const dataChart9 = sheet7.dataCharts.add('data-chart-9', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart9.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
position: GC.Spread.Sheets.DataCharts.AxisPosition.far
}]
}]
}
});
//8. Origin
let sheet8 = spread.getSheet(7);
sheet8.name("Origin");
sheet8.setValue(17, 0, "The Origin of the X-Axis is set to 2000");
sheet8.setValue(17, 10, "The Origin of the Y-Axis is set to 2.3");
const dataChart10 = sheet8.dataCharts.add('data-chart-10', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart10.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
// When the Position of the X-Axis is set, the data set corresponds to the scale of the Y-Axis
origin: 2000, // Number
}]
}]
}
});
const dataChart11 = sheet8.dataCharts.add('data-chart-11', 610, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart11.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
// When positioning the "y" axis, the dataset aligns with the "x" axis scale.
// However, since the "x" axis often represents non-numeric categories, it is evenly divided based on the number of categories.
// The scale is then set such that the starting item's position is 1, with a spacing of 1 unit between each item.
origin: 2.3, // Sets the Origin of the Y-Axis
}]
}]
}
});
// 9. Format
let sheet9 = spread.getSheet(8);
sheet9.name("Format");
sheet9.setValue(17, 0, "The format of the Y-Axis is $0.0 K");
const dataChart12 = sheet9.dataCharts.add('data-chart-12', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart12.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
format: {
type: GC.Spread.Sheets.DataCharts.FormatType.thousands,
value: "$0.0 K"
}
}]
}]
}
});
// 10. Major and Minor Unit
let sheet10 = spread.getSheet(9);
sheet10.name("Major and Minor Unit");
sheet10.setValue(17, 0, "Y-Axis Major Unit: 1000");
sheet10.setValue(18, 0, "X-Axis Major Unit: 2");
const dataChart13 = sheet10.dataCharts.add('data-chart-13', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart13.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
// If the current scale is of type "Number," set the value directly.
majorUnit: {
value: 1000
},
},
{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
// If the scale is not of type "Number" or "Date" set the value directly as well,
// with the rule that each category value is spaced by 1 unit.
majorUnit: {
value: 2
},
}]
}]
}
});
// 11. Label Angle And Label Style
let sheet11 = spread.getSheet(10);
sheet11.name("Label Angle And Label Style");
sheet11.setValue(17, 0, "For X-Axis, the Label Angle is 50");
const dataChart14 = sheet11.dataCharts.add('data-chart-14', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart14.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
labelAngle: [50], // Rotation Angle, Value Range is -90~90
labelStyle: { // ILabelStyleOption
color: "red",
fontSize: 16,
fontStyle: GC.Spread.Sheets.DataCharts.FontStyle.italic,
overflow: GC.Spread.Sheets.DataCharts.TextOverflow.ellipsis
},
}]
}]
}
});
// 12. Title Style
let sheet12 = spread.getSheet(11);
sheet12.name("Title Style");
sheet12.setValue(17, 0, "Title Style Has Been Applied");
const dataChart15 = sheet12.dataCharts.add('data-chart-15', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart15.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
title: "Category Title", // string
// Apply Title Style To X-Axis
titleStyle: { // ILabelStyleOption
color: "red",
fontSize: 16,
fontStyle: GC.Spread.Sheets.DataCharts.FontStyle.italic,
fontWeight: "Bold",
}
}]
}]
}
});
// 13. Line Style
let sheet13 = spread.getSheet(12);
sheet13.name("Line Style");
sheet13.setValue(17, 0, "Line Style Has Been Applied To X-Axis");
const dataChart16 = sheet13.dataCharts.add('data-chart-16', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart16.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
// Apply Line Style to X-Axis
lineStyle: {
stroke: { type: "CssColor", color: "#9f3434" },
strokeWidth: 2,
strokeDasharray: "5,5",
}
}]
}]
}
});
// 14. MajorTickSize and MinorTickSize
let sheet14 = spread.getSheet(13);
sheet14.setColumnCount(30);
sheet14.name("MajorTickSize and MinorTickSize");
sheet14.setValue(17, 0, "For X-Axis: ");
sheet14.setValue(18, 0, "MinorTickSize: 10");
sheet14.setValue(19, 0, "MinorTick: Inside");
sheet14.setValue(20, 0, "Major Tick: None");
sheet14.setValue(17, 10, "For X-Axis: ");
sheet14.setValue(18, 10, "MinorTickSize: 10");
sheet14.setValue(19, 10, "MinorTick: Outside");
sheet14.setValue(20, 10, "Major Tick: None");
sheet14.setValue(17, 19, "For X-Axis: ");
sheet14.setValue(18, 19, "MinorTickSize: 10");
sheet14.setValue(19, 19, "MinorTick: Cross");
sheet14.setValue(20, 19, "Major Tick: None");
const dataChart17 = sheet14.dataCharts.add('data-chart-17', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart17.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
minorTickSize: 10,
minorTicks: GC.Spread.Sheets.DataCharts.TickMark.inside,
majorTicks: GC.Spread.Sheets.DataCharts.TickMark.none
}]
}]
}
});
const dataChart18 = sheet14.dataCharts.add('data-chart-18', 600, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart18.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
minorTickSize: 10,
minorTicks: GC.Spread.Sheets.DataCharts.TickMark.outside,
majorTicks: GC.Spread.Sheets.DataCharts.TickMark.none
}]
}]
}
});
const dataChart19 = sheet14.dataCharts.add('data-chart-19', 1150, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart19.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
minorTickSize: 10,
minorTicks: GC.Spread.Sheets.DataCharts.TickMark.cross,
majorTicks: GC.Spread.Sheets.DataCharts.TickMark.none
}]
}]
}
});
// 15. Major Grid and Minor Grid
let sheet15 = spread.getSheet(14);
sheet15.setColumnCount(30);
sheet15.name("Major Grid Line and Minor Grid Line");
sheet15.setValue(17, 0, "For Y-Axis: ");
sheet15.setValue(18, 0, "MajorGridLine: False");
sheet15.setValue(19, 0, "MinorGridLine: true");
const dataChart20 = sheet15.dataCharts.add('data-chart-20', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart20.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
// Set the Major Grid Line and Minor Grid Line
majorGrid: false, // boolean
minorGrid: true, // boolean
}]
}]
}
});
// 16. MajorGridStyle and MinorGridStyle
let sheet16 = spread.getSheet(15);
sheet16.setColumnCount(30);
sheet16.name("MajorGridStyle and MinorGridStyle");
sheet16.setValue(17, 0, "Major Grid Style has been applied");
const dataChart21 = sheet16.dataCharts.add('data-chart-21', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart21.setChartConfig({
tableName: 'Sales',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.column,
encodings: {
values: [{ field: 'Sales', aggregate: GC.Spread.Sheets.DataCharts.Aggregate.sum }],
category: { field: 'Product' },
color: { field: 'Product' }
},
}
],
config: {
plotAreas: [{
axes: [{
type: GC.Spread.Sheets.DataCharts.AxisType.y,
majorGridStyle: {
stroke: { type: "CssColor", color: "red" },
strokeWidth: 2,
strokeDasharray: "5,5",
}
}]
}]
}
});
// 17. Date Mode
// Add A Table to The Data Manager
const sales2Table = createSales2Table(dataManager);
await sales2Table.fetch();
let sheet17 = spread.getSheet(16);
sheet17.setColumnCount(30);
sheet17.name("Date Mode");
sheet17.setValue(17, 0, "Major Unit Value: 2");
sheet17.setValue(18, 0, "Date Type: Year");
sheet17.setValue(17, 10, "Major Unit Value: 5");
sheet17.setValue(18, 10, "Date Type: Month");
const dataChart22 = sheet17.dataCharts.add('data-chart-22', 10, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart22.setChartConfig({
tableName: 'Sales2',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.scatter,
config: {
palette: ['#CEB966', '#9CB084', '#6BB1C9', '#6585CF', '#7E6BC9', '#A379BB'],
},
encodings: {
values: [{ field: "Date" }, { field: 'Expenses' }],
category: { field: 'Date' },
color: { field: 'Date' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
majorUnit: {
value: 2,
dateMode: GC.Spread.Sheets.DataCharts.DateMode.year
},
title: "Date"
}, {
type: GC.Spread.Sheets.DataCharts.AxisType.y,
title: "Expenses"
}
]
}]
}
});
const dataChart23 = sheet17.dataCharts.add('data-chart-23', 610, 10, 480, 300, GC.Spread.Sheets.DataCharts.DataChartType.column);
dataChart23.setChartConfig({
tableName: 'Sales2',
plots: [
{
type: GC.Spread.Sheets.DataCharts.DataChartType.scatter,
config: {
palette: ['#CEB966', '#9CB084', '#6BB1C9', '#6585CF', '#7E6BC9', '#A379BB'],
},
encodings: {
values: [{ field: "Date" }, { field: 'Expenses' },],
color: { field: 'Date' }
},
}
],
config: {
plotAreas: [{
axes: [
{
type: GC.Spread.Sheets.DataCharts.AxisType.x,
majorUnit: {
value: 5,
dateMode: GC.Spread.Sheets.DataCharts.DateMode.month
},
title: "Date"
}, {
type: GC.Spread.Sheets.DataCharts.AxisType.y,
title: "Expenses"
}
]
}]
}
});
function createSales2Table(dataManager) {
const records = [
{
"Country": "US1",
"Company": "Amazon",
"Date": new Date("2022-01-15T03:10:25.000Z"),
"Downloads": 6230,
"Sales": 1,
"Expenses": 3456.45,
"NewCustomer": true,
"Salesman": "Alice"
},
{
"Country": "US2",
"Company": "Google",
"Date": new Date("2022-02-18T06:30:50.000Z"),
"Downloads": 4020,
"Sales": 2,
"Expenses": 2450.75,
"NewCustomer": false,
"Salesman": "Bob"
},
{
"Country": "CHINA",
"Company": "Tencent",
"Date": new Date("2022-03-21T10:15:30.000Z"),
"Downloads": 15470,
"Sales": 3,
"Expenses": 5200.60,
"NewCustomer": true,
"Salesman": "Chen"
},
{
"Country": "UK",
"Company": "BP",
"Date": new Date("2023-04-10T14:45:10.000Z"),
"Downloads": 12470,
"Sales": 4,
"Expenses": 6100.95,
"NewCustomer": false,
"Salesman": "Emily"
},
{
"Country": "GERMANY",
"Company": "Siemens",
"Date": new Date("2023-05-08T08:20:00.000Z"),
"Downloads": 3320,
"Sales": 5,
"Expenses": 2700.30,
"NewCustomer": false,
"Salesman": "Max"
},
{
"Country": "JAPAN",
"Company": "Toyota",
"Date": new Date("2023-06-12T12:35:25.000Z"),
"Downloads": 27500,
"Sales": 6,
"Expenses": 4800.75,
"NewCustomer": true,
"Salesman": "Yuki"
},
{
"Country": "INDIA",
"Company": "TCS",
"Date": new Date("2024-07-19T09:25:15.000Z"),
"Downloads": 18250,
"Sales": 7,
"Expenses": 6200.40,
"NewCustomer": true,
"Salesman": "Ravi"
},
{
"Country": "CANADA",
"Company": "Shopify",
"Date": new Date("2024-08-23T07:15:45.000Z"),
"Downloads": 9500,
"Sales": 8,
"Expenses": 3800.20,
"NewCustomer": false,
"Salesman": "Sophia"
},
{
"Country": "AUSTRALIA",
"Company": "Atlassian",
"Date": new Date("2025-09-30T05:40:35.000Z"),
"Downloads": 14600,
"Sales": 9,
"Expenses": 5100.55,
"NewCustomer": true,
"Salesman": "James"
},
{
"Country": "FRANCE",
"Company": "L'Oreal",
"Date": new Date("2025-10-25T16:50:45.000Z"),
"Downloads": 13750,
"Sales": 10,
"Expenses": 4500.70,
"NewCustomer": false,
"Salesman": "Marie"
}
];
return dataManager.addTable('Sales2', {
data: records
});
}