Histogram

A Histogram sparkline makes it easier to see the quality distribution or sales performance distribution.

You can create a Histogram sparkline using the HistogramSparkline function in a formula: =HISTOGRAMSPARKLINE(dataRange,continuous?,paintLabel?,scale?,barWidth?,barColor?,labelColor?,edgeColor?). The function has the following parameters: dataRange: It's a range or calc array,such as "A1:C6" or "{1,2,2,3,3}". If a cell value isn't a valid number, it will be ignore. continuous: (optional) If it's true, the histogram is continuous. If it's false, the histogram is discrete. paintLabel: (optional) Boolean that represents whether to show the data label. scale: (optional) Number that represents the data binning width when histogram is continuous. (value > 0) barWidth: (optional) Number that represents the percent of bar width according to the average bar width. (value > 0 && value <= 1) barColor: (optional) String that represents the bar color. labelFontStyle: (optional) String that represents the data label font style. It supports custom font style, font weight, font family, font size. labelColor: (optional) String that represents the data label font color. It support CSS color. edgeColor: (optional) String that represents the color of bar edge.
window.onload = () => { var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss")); initSpread(spread); } function initSpread(spread) { spread.fromJSON(data); var sheet = spread.getSheet(0); spread.suspendPaint(); for(var i=0; i<7;i++){ var column = String.fromCharCode(65 + i); sheet.setFormula(3, i, 'HISTOGRAMSPARKLINE('+column+'4:'+column+ '50,TRUE,TRUE,10,1,"#DDDDDD","normal normal 8pt Calibri", "#000000", "#C0C0C0")'); i++; } spread.resumePaint(); }
<!DOCTYPE html> <html lang="en"> <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/@mescius/spread-sheets/styles/gc.spread.sheets.excel2013white.css"> <script src="$DEMOROOT$/en/purejs/node_modules/@mescius/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="$DEMOROOT$/spread/source/data/histogramSparkline.js"></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; }