Month

A Month sparkline is useful for spotting data trends within a month.

Description
app.component.ts
index.html
app.component.html
styles.css
Copy to CodeMine

You can create a Month sparkline using the MonthSparkline function in a formula: =MONTHSPARKLINE(year, month, dataRange, emptyColor, startColor, middleColor, endColor)*. OR *=MONTHSPARKLINE(year, month, dataRange, colorRange).

The function has the following parameters:

  • year : The full year number, such as 2015.

  • month : The month number, such as 3.

  • dataRange : The reference represents a range where the first column is date and the second column is number, such as 'A1:B400'.

  • emptyColor : The color string represents days that have no value or zero value, such as 'lightgray'.

  • startColor : The color string represents the day where the value is the minimum value, such as 'lightgreen'.

  • middleColor : The color string represents the day where the value is the average of minimum and maximum, such as 'green'.

  • endColor : The color string represents the day where the value is the maximum value, such as 'darkgreen'.

  • colorRange : The reference represents a range where the data is a color string.

You can create a Month sparkline using the MonthSparkline function in a formula: =MONTHSPARKLINE(year, month, dataRange, emptyColor, startColor, middleColor, endColor)*. OR *=MONTHSPARKLINE(year, month, dataRange, colorRange). The function has the following parameters: year : The full year number, such as 2015. month : The month number, such as 3. dataRange : The reference represents a range where the first column is date and the second column is number, such as 'A1:B400'. emptyColor : The color string represents days that have no value or zero value, such as 'lightgray'. startColor : The color string represents the day where the value is the minimum value, such as 'lightgreen'. middleColor : The color string represents the day where the value is the average of minimum and maximum, such as 'green'. endColor : The color string represents the day where the value is the maximum value, such as 'darkgreen'. colorRange : The reference represents a range where the data is a color string.
import { Component, NgModule, enableProdMode } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { SpreadSheetsModule } from '@mescius/spread-sheets-angular'; import GC from '@mescius/spread-sheets'; import './styles.css'; @Component({ selector: 'app-component', templateUrl: 'src/app.component.html' }) export class AppComponent { spread: GC.Spread.Sheets.Workbook; hostStyle = { width: '100%', height: '100%', overflow: 'hidden', float: 'left' }; initColorRangeSheet(spread: GC.Spread.Sheets.Workbook) { let sheet = spread.sheets[1]; sheet.name("ColorRange"); sheet.suspendPaint(); sheet.setColumnWidth(0, 80); sheet.setColumnWidth(1, 70); sheet.setColumnWidth(2, 70); sheet.setColumnWidth(3, 30); sheet.setColumnWidth(4, 80); sheet.setColumnWidth(5, 70); sheet.setColumnWidth(6, 70); sheet.setColumnWidth(7, 30); sheet.setColumnWidth(8, 90); sheet.getRange(0,0,1,9).backColor("#999999").foreColor("#FFFFFF"); sheet.setFormatter(-1, 0, "yyyy-MM-dd"); sheet.setFormatter(-1, 4, "yyyy-MM-dd"); sheet.addSpan(2, 8,5 , 1); sheet.addSpan(9, 8, 5, 1); var currentYear = new Date().getFullYear(); for (let row = 1; row < 29; row++) { sheet.setValue(row, 0, new Date(currentYear, 0, row )); sheet.setValue(row, 1, Math.round(Math.random() * 100)); sheet.setValue(row, 2, this.getRandomColor()); } for (let row = 1; row < 29; row++) { sheet.setValue(row, 4, new Date(currentYear, 1, row )); sheet.setValue(row, 5, Math.round(Math.random() * 100)); sheet.setValue(row, 6, this.getRandomColor()); } sheet.setText(0,0,"January"); sheet.setText(0,1,"Value"); sheet.setText(0,2,"Color"); sheet.setText(0,4,"February"); sheet.setText(0,5,"Value"); sheet.setText(0,6,"Color"); sheet.setText(0,8,"Diagram"); sheet.setFormula(2, 8, '=MONTHSPARKLINE('+currentYear+',1,A2:B31,C2:C32)'); sheet.setFormula(7, 8, '=TEXT(DATE('+currentYear+',1, 1),"mmmm")'); sheet.setFormula(9, 8, '=MONTHSPARKLINE('+currentYear+',2,E2:F29,G2:G29)'); sheet.setFormula(14, 8, '=TEXT(DATE('+currentYear+',2, 1),"mmmm")'); sheet.resumePaint(); } getRandomColor() { var colorList = ["#82bc00", "#9fc94c", "#00C2D6", "#d2e4a7", "#e9f2d2", "#ffedd3", "#ffdba8", "#ffc97d", "#feb850", "#f7a711","#00c2d6"]; return colorList[Math.round(Math.random() * 10)]; } initSpread($event: any) { this.spread = $event.spread; let spread = this.spread; let sheet = spread.sheets[0]; sheet.name("No ColorRange"); sheet.suspendPaint(); sheet.setColumnWidth(0, 80); sheet.setColumnWidth(1, 60); sheet.setColumnWidth(2, 30); sheet.setColumnWidth(3, 80); sheet.setColumnWidth(4, 60); sheet.setColumnWidth(5, 30); sheet.setColumnWidth(6, 90); sheet.getRange(0,0,1,7).backColor("#999999").foreColor("#FFFFFF"); sheet.setFormatter(-1, 0, "yyyy-MM-dd"); sheet.setFormatter(-1, 3, "yyyy-MM-dd"); sheet.addSpan(2, 6, 5, 1); sheet.addSpan(9, 6, 5, 1); var currentYear = new Date().getFullYear(); for (let row = 1; row <= 31; row++) { sheet.setValue(row, 0, new Date(currentYear, 0, row)); sheet.setValue(row, 1, Math.round(Math.random() * 100)); } for (let row = 1; row <= 28; row++) { sheet.setValue(row, 3, new Date(currentYear, 1, row)); sheet.setValue(row, 4, Math.round(Math.random() * 100)); } sheet.setText(0,0,"January"); sheet.setText(0,1,"Value"); sheet.setText(0,3,"February"); sheet.setText(0,4,"Value"); sheet.setText(0,6,"Diagram"); sheet.setFormula(2, 6, '=MONTHSPARKLINE('+currentYear+', 1, A2:B32, "#6d6d6d", "#c4c4c4", "#979797", "#f3f3f3")'); sheet.setFormula(7, 6, '=TEXT(DATE('+currentYear+',1, 1),"mmmm")'); sheet.setFormula(9, 6, '=MONTHSPARKLINE('+currentYear+',2,D2:E29, "#6d6d6d", "#c4c4c4", "#979797", "#f3f3f3")'); sheet.setFormula(14, 6, '=TEXT(DATE('+currentYear+',2, 1),"mmmm")'); sheet.resumePaint(); this.initColorRangeSheet(spread); } } @NgModule({ imports: [BrowserModule, SpreadSheetsModule], declarations: [AppComponent], exports: [AppComponent], bootstrap: [AppComponent] }) export class AppModule { } enableProdMode(); // Bootstrap application with hash style navigation and global services. platformBrowserDynamic().bootstrapModule(AppModule);
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/en/angular/node_modules/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <!-- Polyfills --> <script src="$DEMOROOT$/en/angular/node_modules/core-js/client/shim.min.js"></script> <script src="$DEMOROOT$/en/angular/node_modules/zone.js/fesm2015/zone.min.js"></script> <!-- SystemJS --> <script src="$DEMOROOT$/en/angular/node_modules/systemjs/dist/system.js"></script> <script src="systemjs.config.js"></script> <script> // workaround to load 'rxjs/operators' from the rxjs bundle System.import('rxjs').then(function (m) { System.import('@angular/compiler'); System.set(SystemJS.resolveSync('rxjs/operators'), System.newModule(m.operators)); System.import('$DEMOROOT$/en/lib/angular/license.ts'); System.import('./src/app.component'); }); </script> </head> <body> <app-component></app-component> </body> </html>
<div class="sample-tutorial"> <gc-spread-sheets [hostStyle]="hostStyle" (workbookInitialized)="initSpread($event)"> <gc-worksheet></gc-worksheet> <gc-worksheet></gc-worksheet> </gc-spread-sheets> </div>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; } .sample-spreadsheets { height: 100%; }
(function (global) { System.config({ transpiler: 'ts', typescriptOptions: { tsconfig: true }, meta: { 'typescript': { "exports": "ts" }, '*.css': { loader: 'css' } }, paths: { // paths serve as alias 'npm:': 'node_modules/' }, // map tells the System loader where to look for things map: { 'core-js': 'npm:core-js/client/shim.min.js', 'zone': 'npm:zone.js/fesm2015/zone.min.js', 'rxjs': 'npm:rxjs/dist/bundles/rxjs.umd.min.js', '@angular/core': 'npm:@angular/core/fesm2022', '@angular/common': 'npm:@angular/common/fesm2022/common.mjs', '@angular/compiler': 'npm:@angular/compiler/fesm2022/compiler.mjs', '@angular/platform-browser': 'npm:@angular/platform-browser/fesm2022/platform-browser.mjs', '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/fesm2022/platform-browser-dynamic.mjs', '@angular/common/http': 'npm:@angular/common/fesm2022/http.mjs', '@angular/router': 'npm:@angular/router/fesm2022/router.mjs', '@angular/forms': 'npm:@angular/forms/fesm2022/forms.mjs', 'jszip': 'npm:jszip/dist/jszip.min.js', 'typescript': 'npm:typescript/lib/typescript.js', 'ts': './plugin.js', 'tslib':'npm:tslib/tslib.js', 'css': 'npm:systemjs-plugin-css/css.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-angular': 'npm:@mescius/spread-sheets-angular/fesm2020/mescius-spread-sheets-angular.mjs', '@grapecity/jsob-test-dependency-package/react-components': 'npm:@grapecity/jsob-test-dependency-package/react-components/index.js' }, // packages tells the System loader how to load when no filename and/or no extension packages: { src: { defaultExtension: 'ts' }, rxjs: { defaultExtension: 'js' }, "node_modules": { defaultExtension: 'js' }, "node_modules/@angular": { defaultExtension: 'mjs' }, "@mescius/spread-sheets-angular": { defaultExtension: 'mjs' }, '@angular/core': { defaultExtension: 'mjs', main: 'core.mjs' } } }); })(this);