月スパークライン

月スパークラインは、データの傾向を特定したい場合に便利です。

<p>月スパークラインを作成するには、数式内でMonthSparkline関数を使用します。<strong>=MONTHSPARKLINE(year, month, dataRange, emptyColor, startColor, middleColor, endColor)</strong>または<strong>=MONTHSPARKLINE(year, month, dataRange, colorRange)</strong>となります。</p> <p>この関数には、以下のパラメータを指定できます。</p> <p><strong>year</strong> : 4桁の年数(「2015」など)</p> <p><strong>month</strong> : 月数(「3」など)</p> <p><strong>dataRange</strong> : 最初の列が日付であり、次の列が数値となる範囲を表す参照(「A1:B400」など)</p> <p><strong>emptyColor</strong> : 値のない日、またはゼロ値の日を表す色文字列(「lightgray」など)</p> <p><strong>startColor</strong> : 最小値に当たる日を表す色文字列(「lightgreen」など)</p> <p><strong>middleColor</strong> : 最小値と最大値の平均値に当たる日を表す色文字列(「green」など)</p> <p><strong>endColor</strong> : 最大値に当たる日を表す色文字列(「darkgreen」など)</p> <p><strong>colorRange</strong> : データが色文字列となる範囲を表す参照</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.setFormatter(-1, 3, "MM/DD/YYYY"); sheet.setColumnWidth(0, 100, 3); sheet.setColumnWidth(1, 50, 3); sheet.setColumnWidth(2, 30, 3); sheet.setColumnWidth(3, 100, 3); sheet.setColumnWidth(4, 50, 3); sheet.addSpan(3, 6, 4, 1); sheet.addSpan(9, 6, 4, 1); for (var row = 0; row < 31; row++) { sheet.setValue(row, 0, new Date(2015, 0, row + 1)); sheet.setValue(row, 1, Math.round(Math.random() * 100)); } for (var row = 0; row < 28; row++) { sheet.setValue(row, 3, new Date(2015, 1, row + 1)); sheet.setValue(row, 4, Math.round(Math.random() * 100)); } sheet.setFormula(3, 6, '=MonthSparkline(2015, 1, A1:B31, "lightgray", "lightgreen", "green", "darkgreen")'); sheet.setFormula(7, 6, '=TEXT(DATE(2015,1, 1),"mmmm")'); sheet.setFormula(9, 6, '=MONTHSPARKLINE(2015,2,D1:E31,"lightgray","lightgreen","green","darkgreen")'); sheet.setFormula(13, 6, '=TEXT(DATE(2015,2, 1),"mmmm")'); sheet.resumePaint(); } function initColorRangeSheet(spread) { var sheet = spread.sheets[1]; sheet.name("Use colorRange"); sheet.suspendPaint(); sheet.setFormatter(-1, 0, "MM/DD/YYYY"); sheet.setFormatter(-1, 3, "MM/DD/YYYY"); sheet.setColumnWidth(0, 100, 3); sheet.setColumnWidth(1, 50, 3); sheet.setColumnWidth(2, 30, 3); sheet.setColumnWidth(3, 100, 3); sheet.setColumnWidth(4, 50, 3); sheet.addSpan(3, 6, 4, 1); sheet.addSpan(9, 6, 4, 1); for (var row = 0; row < 31; row++) { sheet.setValue(row, 0, new Date(2015, 0, row + 1)); sheet.setValue(row, 1, Math.round(Math.random() * 100)); sheet.setValue(row, 2, getRandomColor()); } for (var row = 0; row < 28; row++) { sheet.setValue(row, 3, new Date(2015, 1, row + 1)); sheet.setValue(row, 4, Math.round(Math.random() * 100)); sheet.setValue(row, 5, getRandomColor()); } sheet.setFormula(3, 6, '=MONTHSPARKLINE(2015,1,A1:B31,C1:C31)'); sheet.setFormula(7, 6, '=TEXT(DATE(2015,1, 1),"mmmm")'); sheet.setFormula(9, 6, '=MONTHSPARKLINE(2015,2,D1:E31,F1:F31)'); sheet.setFormula(13, 6, '=TEXT(DATE(2015,2, 1),"mmmm")'); sheet.resumePaint(); } function getRandomColor() { var colorList = ["lightgray", "red", "green", "darkgreen", "blue", "yellow", "orange", "pink", "gray", "black"]; return colorList[Math.round(Math.random() * 10)]; }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="ja-jp" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/ja/purejs/node_modules/@grapecity/spread-sheets-resources-ja/dist/gc.spread.sheets.resources.ja.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; }