面积函数迷你图

面积函数迷你图可以用来展示随着时间的推移数值的变化趋势。

你可以通过面积函数创建一个面积函数迷你图,例如: =AREASPARKLINE(points, min?, max?, line1?, line2?, colorPositive?, colorNegative?). 这个函数有以下这些参数: points: 表示一片数据区域,例如 "D1:D6"。如果这片区域中哪个单元格的值不是一个合法的数字,那么会它的值被视为0。 min:(可选的参数)迷你图的值域下限。 这片区域的最小值和你设置的值域下限中更小的起作用。 默认值是这片数据区域的最小值。 max:(可选参数)迷你图的值域上限。这片区域中的最大值和你设置的值域上限中更大的起作用。默认值是这篇数据区域的最大值。 line1:(可选参数)表示一个水平线在垂直方向的位置的值;默认情况下是不存在的这根线的。 line2:(可选参数)表示另外一个水平线在垂直方向的位置的值;默认情况下也是不存在这根线的。 colorPositive:(可选参数)表示值是正数的区域填充颜色;默认值是"#787878"。 colorNegative:(可选参数)表示值是负数的区域填充颜色;默认值是"#CB0000"。
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); initSpread(spread); }; function initSpread(spread) { var spreadNS = GC.Spread.Sheets; var sheet = spread.sheets[0]; sheet.suspendPaint(); sheet.addSpan(0, 0, 1, 5); sheet.getCell(0, 0).value("Sales by State").font("20px Arial").hAlign(spreadNS.HorizontalAlign.center).vAlign(spreadNS.VerticalAlign.center); var table1 = sheet.tables.add("table1", 1, 0, 6, 5, spreadNS.Tables.TableThemes.medium4); table1.rowFilter().filterButtonVisible(false); sheet.setValue(1, 0, "State"); sheet.setValue(1, 1, "Sale of 2012 year"); sheet.setValue(1, 2, "Sale of 2013 year"); sheet.setValue(1, 3, "Sale of 2014 year"); sheet.setValue(1, 4, "Diagram"); sheet.setValue(2, 0, "Idaho"); sheet.setValue(2, 1, 10000); sheet.setValue(2, 2, -9000); sheet.setValue(2, 3, 15000); sheet.setValue(3, 0, "Montana"); sheet.setValue(3, 1, 1000); sheet.setValue(3, 2, 10000); sheet.setValue(3, 3, 15000); sheet.setValue(4, 0, "Oregon"); sheet.setValue(4, 1, 10000); sheet.setValue(4, 2, 7000); sheet.setValue(4, 3, 0); sheet.setValue(5, 0, "Washington"); sheet.setValue(5, 1, 1000); sheet.setValue(5, 2, 10000); sheet.setValue(5, 3, 5000); sheet.setValue(6, 0, "Utah"); sheet.setValue(6, 1, -5000); sheet.setValue(6, 2, 5000); sheet.setValue(6, 3, 12000); sheet.setFormatter(-1, 1, "$#,##0"); sheet.setFormatter(-1, 2, "$#,##0"); sheet.setFormatter(-1, 3, "$#,##0"); sheet.setFormula(2, 4, '=AREASPARKLINE(B3:D3,,,0,10000,"yellowgreen","red")'); sheet.setFormula(3, 4, '=AREASPARKLINE(B4:D4,,,0,10000,"yellowgreen","red")'); sheet.setFormula(4, 4, '=AREASPARKLINE(B5:D5,,,0,10000,"yellowgreen","red")'); sheet.setFormula(5, 4, '=AREASPARKLINE(B6:D6,,,0,10000,"yellowgreen","red")'); sheet.setFormula(6, 4, '=AREASPARKLINE(B7:D7,,,0,10000,"yellowgreen","red")'); sheet.setRowHeight(0, 50); sheet.setRowHeight(1, 25); for (var i = 2; i < 7; i++) { sheet.setRowHeight(i, 45); } sheet.setColumnWidth(0, 100); sheet.setColumnWidth(1, 120); sheet.setColumnWidth(2, 120); sheet.setColumnWidth(3, 120); sheet.setColumnWidth(4, 200); sheet.resumePaint(); };
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta name="spreadjs culture" content="zh-cn" /> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity/spread-sheets-resources-zh/dist/gc.spread.sheets.resources.zh.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; }