Year

A year sparkline is useful for spotting annual trends in your data.

<p>You can create a year sparkline using the YearSparkline function in a formula: <strong>=YEARSPARKLINE(year, dataRange, emptyColor, startColor, middleColor, endColor)</strong>. OR <strong>=YEARSPARKLINE(year, dataRange, colorRange)</strong>.</p> <p>The function has the following parameters:</p> <p><strong>year</strong> : The full year number, such as 2015.</p> <p><strong>dataRange</strong> : The reference represents a range where the first column is date and the second column is number, such as 'A1:B400'.</p> <p><strong>emptyColor</strong> : The color string represents the days that have no value or zero value, such as 'lightgray'.</p> <p><strong>startColor</strong> : The color string represents the day where the value is the minimum value, such as 'lightgreen'.</p> <p><strong>middleColor</strong> : The color string represents the day where the value is the average of the minimum and maximum, such as 'green'.</p> <p><strong>endColor</strong> : The color string represents the day where the value is the maximum value, such as 'darkgreen'.</p> <p><strong>colorRange</strong> : The reference represents a range where the data is a color string.</p>
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 2 }); initNormalSheet(spread); initColorRangeSheet(spread); }; function initNormalSheet(spread) { var sheet = spread.sheets[0]; sheet.suspendPaint(); sheet.setFormatter(-1, 0, "MM/DD/YYYY"); sheet.setColumnWidth(0, 75); sheet.setColumnWidth(1, 25); sheet.setColumnWidth(2, 25); sheet.setColumnWidth(3, 600); sheet.addSpan(4, 3, 4, 10); sheet.setRowCount(365); var rowCount = sheet.getRowCount(); for (var row = 0; row < rowCount; row++) { sheet.setValue(row, 0, new Date(2016, 0, row + 1)); sheet.setValue(row, 1, Math.round(Math.random() * 100)); } sheet.setFormula(4, 3, '=YearSparkline(2016, A1:B' + rowCount + ', "lightgray", "lightgreen", "green", "darkgreen")'); sheet.resumePaint(); } function initColorRangeSheet(spread) { var sheet = spread.sheets[1]; sheet.name("Use colorRange"); sheet.suspendPaint(); sheet.setFormatter(-1, 0, "MM/DD/YYYY"); sheet.setColumnWidth(0, 75); sheet.setColumnWidth(1, 25); sheet.setColumnWidth(2, 100); sheet.setColumnWidth(3, 600); sheet.setValue(1, 3, "lightgray"); sheet.setValue(2, 3, "lightgreen"); sheet.setValue(3, 3, "green"); sheet.setValue(4, 3, "darkgreen"); sheet.addSpan(6, 3, 4, 10); sheet.setRowCount(365); var rowCount = sheet.getRowCount(); var colorList = ["lightgray", "red", "green", "darkgreen", "blue", "yellow", "orange", "pink", "gray", "black"]; for (var row = 0; row < rowCount; row++) { sheet.setValue(row, 0, new Date(2016, 0, row + 1)); sheet.setValue(row, 1, Math.round(Math.random() * 100)); sheet.setValue(row, 2, colorList[Math.round(Math.random() * 10)]) } sheet.setFormula(6, 3, '=YearSparkline(2016, A1:B' + rowCount + ', C1:C365)'); sheet.resumePaint(); }
<!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/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/spread/source/js/license.js" type="text/javascript"></script> <script src="app.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <div class="sample-tutorial"> <div id="ss" style="width:100%;height:100%"></div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }