漏斗图

你可以使用漏斗图来展示销售渠道中每个阶段的销售前景数量或者产品电子邮件活动的销售数量。

SpreadJS支持漏斗图. 使用 GC.Spread.Sheets.Charts.ChartType.funnel 属性获得图表类型. 漏斗图展示了流程中多个阶段的值。 你可以在SpreadJS中添加漏斗图表,并且使用图表API更改样式。
window.onload = function () { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), {sheetCount: 2}); initSpread(spread); }; function initSpread(spread) { var sheets = spread.sheets; spread.suspendPaint(); // custom sheet style setSheet(sheets); setData(sheets[0], 'funnelChart'); initFunnel(sheets[0], GC.Spread.Sheets.Charts.ChartType.funnel); setData(sheets[1], 'customStyle'); var customFunnelChart = initFunnel(sheets[1], GC.Spread.Sheets.Charts.ChartType.funnel); setCustomStyle(customFunnelChart); spread.resumePaint(); } function setSheet(sheets) { var columnWidths = [20, 100, 100]; for (var i = 0; i < sheets.length; i++) { sheets[i].options.gridline.showHorizontalGridline = false; sheets[i].options.gridline.showVerticalGridline = false; sheets[i].getRange(1, 1, 6, 2) .hAlign(GC.Spread.Sheets.HorizontalAlign.center) .setBorder(new GC.Spread.Sheets.LineBorder('black', GC.Spread.Sheets.LineStyle.thin), { all: true }); sheets[i].getRange(1, 1, 1, 2).font('bold normal 10pt Arial'); for (var j = 0; j < columnWidths.length; j++) { sheets[i].setColumnWidth(j, columnWidths[j]); } } } function initFunnel(sheet, chartType) { sheet.resumePaint(); return sheet.charts.add((sheet.name() + chartType), chartType, 400, 0, 500, 400, "B2:C7"); } function setCustomStyle(chart) { var chartArea = chart.chartArea(); chartArea.backColor = { type: GC.Spread.Sheets.Charts.PatternType.dottedPercent20, foregroundColor: "rgb(0,176,80)", backgroundColor: "background 1 0", }; chart.chartArea(chartArea); var dataLabels = chart.dataLabels(); dataLabels.showValue = true; dataLabels.color = 'white'; chart.dataLabels(dataLabels); var seriesCollection = chart.series(); var series1 = seriesCollection.get(0); series1.backColor = "green"; seriesCollection.set(0, series1); var title = chart.title(); title.text = "Product Email Campaign"; title.fontSize = 16; chart.title(title); } function setData(sheet, sheetName) { sheet.name(sheetName); sheet.suspendPaint(); var dataArray = [ ['Stage', 'Users'], ['Sent', 5676], ['Viewed', 3872], ['Clicked', 1668], ['Add to Cart', 640], ['Purchased', 565], ]; sheet.setArray(1, 1, dataArray); }
<!doctype html> <html style="height:100%;font-size:14px;"> <head> <meta charset="utf-8" /> <meta name="spreadjs culture" content="zh-cn" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" type="text/css" href="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets/dist/gc.spread.sheets.all.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-shapes/dist/gc.spread.sheets.shapes.min.js" type="text/javascript"></script> <script src="$DEMOROOT$/zh/purejs/node_modules/@grapecity-software/spread-sheets-charts/dist/gc.spread.sheets.charts.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" class="sample-tutorial"></div> </div> </body> </html>
.sample-tutorial { position: relative; height: 100%; overflow: hidden; } body { position: absolute; top: 0; bottom: 0; left: 0; right: 0; }