Area Chart

Data that's arranged in columns or rows on a worksheet can be plotted in an area chart. Area charts can be used to plot change over time and draw attention to the total value across a trend by showing the sum of the plotted values.

SpreadJS supports area, stacked area and 100% stacked area charts. Use the GC.Spread.Sheets.Charts.ChartType.area property to get the chart type. You can add an area chart to Spread and change its style using the chart API. Area: Area charts show trends over time. Stacked Area: Stacked area charts show the trend of the contribution of each value over time or other categorical data. 100% Stacked Area: One-hundred percent stacked area charts show the trend of the percentage that each value contributes over time or other categorical data.
<template> <div class="sample-tutorial"> <gc-spread-sheets class="sample-spreadsheets" @workbookInitialized="initSpread"> <gc-worksheet /> <gc-worksheet /> <gc-worksheet /> </gc-spread-sheets> </div> </template> <script setup> import GC from "@mescius/spread-sheets"; import { ref } from "vue"; import "@mescius/spread-sheets-vue"; import "@mescius/spread-sheets-charts"; const spreadRef = ref(null); function initSpread(spread) { spreadRef.value = spread; let chartType = [{ type: GC.Spread.Sheets.Charts.ChartType.area, desc: "area", }, { type: GC.Spread.Sheets.Charts.ChartType.areaStacked, desc: "areaStacked", }, { type: GC.Spread.Sheets.Charts.ChartType.areaStacked100, desc: "areaStacked100", }]; let sheets = spread.sheets; spread.suspendPaint(); initArea(sheets[0], chartType[0].desc, chartType[0].type); initArea(sheets[1], chartType[1].desc, chartType[1].type); initArea(sheets[2], chartType[2].desc, chartType[2].type); spread.resumePaint(); } function initArea(sheet, sheetName, chartType) { sheet.name(sheetName); sheet.suspendPaint(); //prepare data for chart let dataArray = [ ["", "1750", "1800", "1850", "1900", "1950", "2000", "2050"], ["Asia", 502, 635, 809, 947, 1402, 3634, 5268], ["Africa", 106, 107, 111, 133, 221, 767, 1766], ["America", 18, 31, 54, 156, 339, 818, 1201], ["Europe", 163, 203, 276, 408, 547, 729, 628], ["Oceania", 2, 2, 2, 6, 13, 30, 46] ]; sheet.setArray(0, 0, dataArray); sheet.resumePaint(); let chart = sheet.charts.add((sheet.name() + 'Chart1'), chartType, 0, 120, 800, 300, "A1:H6", GC.Spread.Sheets.Charts.RowCol.rows); let series = chart.series().get(); let colorArray = ['rgba(158, 200, 242, 0.7)', 'rgba(245, 87, 31, 0.7)', 'rgba(173, 255, 131, 0.7)', 'rgba(255, 178, 50, 0.7)', 'rgba(93, 93, 93, 0.7)']; let colorLineArray = ['rgba(158, 200, 242)', 'rgba(245, 87, 31)', 'rgba(173, 255, 131)', 'rgba(255, 178, 50)', 'rgba(93, 93, 93)']; for (let i = 0; i < series.length; i++) { series[i].backColor = colorArray[i]; series[i].border.color = colorLineArray[i]; series[i].border.width = 2; chart.series().set(i, series[i]); } let axes = chart.axes(); axes.primaryValue.lineStyle.color = 'grey'; axes.primaryValue.majorTickPosition = GC.Spread.Sheets.Charts.TickMark.outside; axes.primaryValue.majorUnit = 1000; chart.axes(axes); chart.title({ text: "The Continents History and Forecast of Population Growth", fontSize: 18 }); chart.axes({ primaryValue: { title: { text: "Units: one million" } } }); } </script> <style scoped> .sample-tutorial { position: relative; height: 100%; overflow: hidden; } .sample-spreadsheets { width: 100%; height: 100%; overflow: hidden; float: left; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } #app { height: 100%; } </style>
<!DOCTYPE html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <title>SpreadJS VUE</title> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/vue3/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/vue3/node_modules/systemjs/dist/system.src.js"></script> <script src="./systemjs.config.js"></script> <script src="./compiler.js" type="module"></script> <script> var System = SystemJS; System.import("./src/app.js"); System.import('$DEMOROOT$/en/lib/vue3/license.js'); </script> </head> <body> <div id="app"></div> </body> </html>
(function (global) { SystemJS.config({ transpiler: 'plugin-babel', babelOptions: { es2015: true }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, packageConfigPaths: [ './node_modules/*/package.json', "./node_modules/@mescius/*/package.json", "./node_modules/@babel/*/package.json", "./node_modules/@vue/*/package.json" ], map: { 'vue': "npm:vue/dist/vue.esm-browser.js", 'tiny-emitter': 'npm:tiny-emitter/index.js', 'plugin-babel': 'npm:systemjs-plugin-babel/plugin-babel.js', "systemjs-babel-build": "npm:systemjs-plugin-babel/systemjs-babel-browser.js", '@mescius/spread-sheets': 'npm:@mescius/spread-sheets/index.js', '@mescius/spread-sheets-resources-en': 'npm:@mescius/spread-sheets-resources-en/index.js', '@mescius/spread-sheets-vue': 'npm:@mescius/spread-sheets-vue/index.js', '@mescius/spread-sheets-shapes': 'npm:@mescius/spread-sheets-shapes/index.js', '@mescius/spread-sheets-charts': 'npm:@mescius/spread-sheets-charts/index.js', }, meta: { '*.css': { loader: 'systemjs-plugin-css' }, '*.vue': { loader: "../plugin-vue/index.js" } } }); })(this);